⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix_symcomplexsparse.cxx

📁 Multivac 的Level set包
💻 CXX
📖 第 1 页 / 共 3 页
字号:
    real_ptr_ = real_ptr;    imag_ptr_ = imag_ptr;  }  /*******************   * BASIC FUNCTIONS *   *******************/    //! Returns the number of elements stored in memory.  /*!    Returns the number of elements stored in memory, i.e.    the cumulated number of non-zero entries of both the real and    the imaginary part.    \return The number of elements stored in memory.  */  template <class T, class Prop, class Storage, class Allocator>  int Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetDataSize() const  {    return real_nz_ + imag_nz_;  }  //! Returns (row or column) start indices for the real part.  /*!    Returns the array ('ptr_') of start indices for the real part.    \return The array of start indices for the real part.  */  template <class T, class Prop, class Storage, class Allocator>  int* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetRealPtr() const  {    return real_ptr_;  }  //! Returns (row or column) start indices for the imaginary part.  /*!    Returns the array ('ptr_') of start indices for the imaginary part.    \return The array of start indices for the imaginary part.  */  template <class T, class Prop, class Storage, class Allocator>  int* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetImagPtr() const  {    return imag_ptr_;  }  //! Returns (row or column) indices of non-zero entries for the real part.  /*!    Returns the array ('ind_') of (row or column) indices    of non-zero entries for the real part. This array defines non-zero    entries indices if coupled with (column or row) start indices.    \return The array of (row or column) indices of    non-zero entries for the real part.  */  template <class T, class Prop, class Storage, class Allocator>  int* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetRealInd() const  {    return real_ind_;  }  //! Returns (row or column) indices of non-zero entries for  //! the imaginary part.  /*!    Returns the array ('ind_') of (row or column) indices    of non-zero entries for the imaginary part. This array defines non-zero    entries indices if coupled with (column or row) start indices.    \return The array of (row or column) indices of    non-zero entries for the imaginary part.  */  template <class T, class Prop, class Storage, class Allocator>  int* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetImagInd() const  {    return imag_ind_;  }  //! Returns the length of the array of start indices for the real part.  /*!    \return The length of the array of start indices for the real part.  */  template <class T, class Prop, class Storage, class Allocator>  int Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetRealPtrSize() const  {    return (this->m_ + 1);  }    //! Returns the length of the array of start indices for the imaginary part.  /*!    \return The length of the array of start indices for the imaginary part.  */  template <class T, class Prop, class Storage, class Allocator>  int Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetImagPtrSize() const  {    return (this->m_ + 1);  }    //! Returns the length of the array of (column or row) indices for  //! the real part.  /*!    Returns the length of the array ('ind_') of (row or column) indices    of non-zero entries (that are stored) for the real part. This array    defines non-zero entries indices if coupled with (column or row)    start indices.    \return The length of the array of (column or row) indices for    the real part.    \note The length of the array of (column or row) indices is the    number of non-zero entries that are stored.  */  template <class T, class Prop, class Storage, class Allocator>  int Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetRealIndSize() const  {    return real_nz_;  }  //! Returns the length of the array of (column or row) indices  //! for the imaginary part.  /*!    Returns the length of the array ('ind_') of (row or column) indices    of non-zero entries (that are stored) for the imaginary part. This array    defines non-zero entries indices if coupled with (column or row)    start indices.    \return The length of the array of (column or row) indices    for the imaginary part.    \note The length of the array of (column or row) indices is the    number of non-zero entries that are stored.  */  template <class T, class Prop, class Storage, class Allocator>  int Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::GetImagIndSize() const  {    return imag_nz_;  }  //! Returns the array of values of the real part.  /*!    \return The array 'real_data_' of values of the real part..  */  template <class T, class Prop, class Storage, class Allocator>  T* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>::GetRealData() const  {    return real_data_;  }  //! Returns the array of values of the imaginary part.  /*!    \return The array 'imag_data_' of values of the imaginary part..  */  template <class T, class Prop, class Storage, class Allocator>  T* Matrix_SymComplexSparse<T, Prop, Storage, Allocator>::GetImagData() const  {    return imag_data_;  }  /**********************************   * ELEMENT ACCESS AND AFFECTATION *   **********************************/  //! Access operator.  /*!    Returns the value of element (i, j).    \param i row index.    \param j column index.    \return Element (i, j) of the matrix.  */  template <class T, class Prop, class Storage, class Allocator>  inline complex<typename Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::value_type>  Matrix_SymComplexSparse<T, Prop, Storage, Allocator>  ::operator() (int i, int j) const  {#ifdef SELDON_CHECK_BOUNDARIES    if (i < 0 || i >= this->m_)      throw WrongRow("Matrix_SymComplexSparse::operator()",		     string("Index should be in [0, ") + to_str(this->m_-1)		     + "], but is equal to " + to_str(i) + ".");    if (j < 0 || j >= this->n_)      throw WrongCol("Matrix_SymComplexSparse::operator()",		     string("Index should be in [0, ") + to_str(this->n_-1)		     + "], but is equal to " + to_str(j) + ".");#endif    int real_k, imag_k, l;    int real_a, real_b;    int imag_a, imag_b;    // Only the upper part is stored.    if (i > j)      {	l = i;	i = j;	j = l;      }    real_a = real_ptr_[Storage::GetFirst(i, j)];    real_b = real_ptr_[Storage::GetFirst(i, j) + 1];    imag_a = imag_ptr_[Storage::GetFirst(i, j)];    imag_b = imag_ptr_[Storage::GetFirst(i, j) + 1];        if (real_a != real_b)      {	l = Storage::GetSecond(i, j);	for (real_k = real_a;	     (real_k < real_b - 1) && (real_ind_[real_k] < l);	     real_k++);	if (imag_a != imag_b)	  {	    for (imag_k = imag_a;		 (imag_k < imag_b - 1) && (imag_ind_[imag_k] < l);		 imag_k++);	    if (real_ind_[real_k] == l)	      {		if (imag_ind_[imag_k] == l)		  return complex<T>(real_data_[real_k], imag_data_[imag_k]);		else		  return complex<T>(real_data_[real_k], T(0));	      }	    else	      if (imag_ind_[imag_k] == l)		return complex<T>(T(0), imag_data_[imag_k]);	      else		return complex<T>(T(0), T(0));	  }	else	  {	    if (real_ind_[real_k] == l)	      return complex<T>(real_data_[real_k], T(0));	    else	      return complex<T>(T(0), T(0));	  }      }    else      {	if (imag_a != imag_b)	  {	    l = Storage::GetSecond(i, j);	    for (imag_k = imag_a;		 (imag_k < imag_b - 1) && (imag_ind_[imag_k] < l);		 imag_k++);	    if (imag_ind_[imag_k] == l)	      return complex<T>(T(0), imag_data_[imag_k]);	    else	      return complex<T>(T(0), T(0));	  }	else	  return complex<T>(T(0), T(0));      }  }  /************************   * CONVENIENT FUNCTIONS *   ************************/  //! Displays the matrix on the standard output.  /*!    Displays elements on the standard output, in text format.    Each row is displayed on a single line and elements of    a row are delimited by tabulations.  */  template <class T, class Prop, class Storage, class Allocator>  void Matrix_SymComplexSparse<T, Prop, Storage, Allocator>::Print() const  {    for (int i = 0; i < this->m_; i++)      {	for (int j = 0; j < this->n_; j++)	  cout << (*this)(i, j) << "\t";	cout << endl;      }  }   /////////////////////////////////  // MATRIX<COLSYMCOMPLEXSPARSE> //  /////////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    Builds an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  Matrix<T, Prop, ColSymComplexSparse, Allocator>::Matrix()  throw():    Matrix_SymComplexSparse<T, Prop, ColSymComplexSparse, Allocator>()  {  }  //! Constructor.  /*! Builds a i by j matrix with real_nz and imag_nz non-zero (stored)    elements for the real part and the imaginary part respectively.    \param i number of rows.    \param j number of columns.    \param real_nz number of non-zero elements that are stored    for the real part.    \param imag_nz number of non-zero elements that are stored    for the imaginary part.    \note Matrix values are not initialized.    \warning 'j' is assumed to be equal to 'i' so that 'j' is discarded.  */  template <class T, class Prop, class Allocator>  Matrix<T, Prop, ColSymComplexSparse, Allocator>::Matrix(int i, int j,							  int real_nz,							  int imag_nz):    Matrix_SymComplexSparse<T, Prop,			    ColSymComplexSparse, Allocator>(i, j,							    real_nz, imag_nz)  {  }  //! Constructor.  /*!    Builds a i by j sparse matrix with non-zero values and indices    provided by 'real_values' (values of the real part), 'real_ptr'    (pointers for the real part), 'real_ind' (indices for the real part),    'imag_values' (values of the imaginary part), 'imag_ptr'    (pointers for the imaginary part) and 'imag_ind' (indices for the    imaginary part). Input vectors are released and are empty on exit.    \param i number of rows.    \param j number of columns.    \param real_values values of non-zero entries for the real part.    \param real_ptr row or column start indices for the real part.    \param real_ind row or column indices for the real part.    \param imag_values values of non-zero entries for the imaginary part.    \param imag_ptr row or column start indices for the imaginary part.    \param imag_ind row or column indices for the imaginary part.    \warning Input vectors 'real_values', 'real_ptr' and 'real_ind',    'imag_values', 'imag_ptr' and 'imag_ind' are empty on exit.    Moreover 'j' is assumed to be equal to 'i' so that 'j' is discarded.  */  template <class T, class Prop, class Allocator>  template <class Storage0, class Allocator0,	    class Storage1, class Allocator1,	    class Storage2, class Allocator2>  Matrix<T, Prop, ColSymComplexSparse, Allocator>::  Matrix(int i, int j,	 Vector<T, Storage0, Allocator0>& real_values,	 Vector<int, Storage1, Allocator1>& real_ptr,	 Vector<int, Storage2, Allocator2>& real_ind,	 Vector<T, Storage0, Allocator0>& imag_values,	 Vector<int, Storage1, Allocator1>& imag_ptr,	 Vector<int, Storage2, Allocator2>& imag_ind):    Matrix_SymComplexSparse<T, Prop,			    ColSymComplexSparse, Allocator>(i, j,							    real_values,							    real_ptr,							    real_ind,							    imag_values,							    imag_ptr,							    imag_ind)  {  }  /////////////////////////////////  // MATRIX<ROWSYMCOMPLEXSPARSE> //  /////////////////////////////////  /****************   * CONSTRUCTORS *   ****************/  //! Default constructor.  /*!    Builds an empty 0x0 matrix.  */  template <class T, class Prop, class Allocator>  Matrix<T, Prop, RowSymComplexSparse, Allocator>::Matrix()  throw():    Matrix_SymComplexSparse<T, Prop, RowSymComplexSparse, Allocator>()  {  }  /*! Builds a i by j matrix with real_nz and imag_nz non-zero (stored)    elements for the real part and the imaginary part respectively.    \param i number of rows.    \param j number of columns.    \param real_nz number of non-zero elements that are stored    for the real part.    \param imag_nz number of non-zero elements that are store    for the imaginary part.    \note Matrix values are not initialized.    \warning 'j' is assumed to be equal to 'i' so that 'j' is discarded.  */  template <class T, class Prop, class Allocator>  Matrix<T, Prop, RowSymComplexSparse, Allocator>  ::Matrix(int i, int j, int real_nz, int imag_nz):    Matrix_SymComplexSparse<T, Prop, RowSymComplexSparse, Allocator>(i, j,								     real_nz,								     imag_nz)  {  }  //! Constructor.  /*!    Builds a i by j sparse matrix with non-zero values and indices    provided by 'real_values' (values of the real part), 'real_ptr'    (pointers for the real part), 'real_ind' (indices for the real part),    'imag_values' (values of the imaginary part), 'imag_ptr'    (pointers for the imaginary part) and 'imag_ind' (indices for the    imaginary part). Input vectors are released and are empty on exit.    \param i number of rows.    \param j number of columns.    \param real_values values of non-zero entries for the real part.    \param real_ptr row or column start indices for the real part.    \param real_ind row or column indices for the real part.    \param imag_values values of non-zero entries for the imaginary part.    \param imag_ptr row or column start indices for the imaginary part.    \param imag_ind row or column indices for the imaginary part.    \warning Input vectors 'real_values', 'real_ptr' and 'real_ind',    'imag_values', 'imag_ptr' and 'imag_ind' are empty on exit.    Moreover 'j' is assumed to be equal to 'i' so that 'j' is discarded.  */  template <class T, class Prop, class Allocator>  template <class Storage0, class Allocator0,	    class Storage1, class Allocator1,	    class Storage2, class Allocator2>  Matrix<T, Prop, RowSymComplexSparse, Allocator>::  Matrix(int i, int j,	 Vector<T, Storage0, Allocator0>& real_values,	 Vector<int, Storage1, Allocator1>& real_ptr,	 Vector<int, Storage2, Allocator2>& real_ind,	 Vector<T, Storage0, Allocator0>& imag_values,	 Vector<int, Storage1, Allocator1>& imag_ptr,	 Vector<int, Storage2, Allocator2>& imag_ind):    Matrix_SymComplexSparse<T, Prop,			    RowSymComplexSparse, Allocator>(i, j,							    real_values,							    real_ptr,							    real_ind,							    imag_values,							    imag_ptr,							    imag_ind)  {  }} // namespace Seldon.#define SELDON_FILE_MATRIX_SYMCOMPLEXSPARSE_CXX#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -