📄 matrix_symcomplexsparse.cxx
字号:
imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::") + string("Matrix_SymComplexSparse(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("There are ") + to_str(imag_nz_) + " values (imaginary part) but " + to_str(imag_ind.GetLength()) + " row or column indices."); } if (real_ptr.GetLength() - 1 != i) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::") + string("Matrix_SymComplexSparse(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("The vector of start indices (real part)") + " contains " + to_str(real_ptr.GetLength()-1) + string(" row or column start indices (plus the") + " number of non-zero entries) but there are " + to_str(i) + " rows or columns (" + to_str(i) + " by " + to_str(i) + " matrix)."); } if (imag_ptr.GetLength() - 1 != i) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::") + string("Matrix_SymComplexSparse(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("The vector of start indices (imaginary part)") + " contains " + to_str(imag_ptr.GetLength()-1) + string(" row or column start indices (plus the") + " number of non-zero entries) but there are " + to_str(i) + " rows or columns (" + to_str(i) + " by " + to_str(i) + " matrix)."); } if ( (static_cast<long int>(2 * real_nz_ - 2) / static_cast<long int>(i + 1) >= static_cast<long int>(i)) || (static_cast<long int>(2 * imag_nz_ - 2) / static_cast<long int>(i + 1) >= static_cast<long int>(i)) ) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::") + string("Matrix_SymComplexSparse(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("There are more values (") + to_str(real_values.GetLength()) + " values for the real part and " + to_str(real_values.GetLength()) + " values for" + string(" the imaginary part) than elements in the") + " matrix (" + to_str(i) + " by " + to_str(i) + ")."); }#endif this->real_ptr_ = real_ptr.GetData(); this->imag_ptr_ = imag_ptr.GetData(); this->real_ind_ = real_ind.GetData(); this->imag_ind_ = imag_ind.GetData(); this->real_data_ = real_values.GetData(); this->imag_data_ = imag_values.GetData(); real_ptr.Nullify(); imag_ptr.Nullify(); real_ind.Nullify(); imag_ind.Nullify(); real_values.Nullify(); imag_values.Nullify(); } /************** * DESTRUCTOR * **************/ //! Destructor. template <class T, class Prop, class Storage, class Allocator> inline Matrix_SymComplexSparse<T, Prop, Storage, Allocator> ::~Matrix_SymComplexSparse() { this->m_ = 0; this->n_ = 0;#ifdef SELDON_CHECK_MEMORY try {#endif if (real_ptr_ != NULL) { free(real_ptr_); real_ptr_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { real_ptr_ = NULL; }#endif#ifdef SELDON_CHECK_MEMORY try {#endif if (imag_ptr_ != NULL) { free(imag_ptr_); imag_ptr_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { imag_ptr_ = NULL; }#endif#ifdef SELDON_CHECK_MEMORY try {#endif if (real_ind_ != NULL) { free(real_ind_); real_ind_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { real_ind_ = NULL; }#endif#ifdef SELDON_CHECK_MEMORY try {#endif if (imag_ind_ != NULL) { free(imag_ind_); imag_ind_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { imag_ind_ = NULL; }#endif#ifdef SELDON_CHECK_MEMORY try {#endif if (this->real_data_ != NULL) { this->allocator_.deallocate(this->real_data_, real_nz_); this->real_data_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { this->real_nz_ = 0; this->real_data_ = NULL; }#endif#ifdef SELDON_CHECK_MEMORY try {#endif if (this->imag_data_ != NULL) { this->allocator_.deallocate(this->imag_data_, imag_nz_); this->imag_data_ = NULL; } #ifdef SELDON_CHECK_MEMORY } catch (...) { this->imag_nz_ = 0; this->imag_data_ = NULL; }#endif this->real_nz_ = 0; this->imag_nz_ = 0; } //! Clears the matrix. /*! This methods is equivalent to the destructor. On exit, the matrix is empty (0x0). */ template <class T, class Prop, class Storage, class Allocator> inline void Matrix_SymComplexSparse<T, Prop, Storage, Allocator>::Clear() { this->~Matrix_SymComplexSparse(); } /********************* * MEMORY MANAGEMENT * *********************/ //! Redefines the matrix. /*! It clears the matrix and sets it to a new matrix defined 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 Storage, class Allocator> template <class Storage0, class Allocator0, class Storage1, class Allocator1, class Storage2, class Allocator2> void Matrix_SymComplexSparse<T, Prop, Storage, Allocator>:: SetData(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) { this->m_ = i; this->n_ = i; real_nz_ = real_values.GetLength(); imag_nz_ = imag_values.GetLength(); #ifdef SELDON_CHECK_DIMENSIONS // Checks whether vector sizes are acceptable. if (real_ind.GetLength() != real_nz_) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::SetData(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("There are ") + to_str(real_nz_) + " values (real part) but " + to_str(real_ind.GetLength()) + " row or column indices."); } if (imag_ind.GetLength() != imag_nz_) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::SetData(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("There are ") + to_str(imag_nz_) + " values (imaginary part) but " + to_str(imag_ind.GetLength()) + " row or column indices."); } if (real_ptr.GetLength() - 1 != i) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::SetData(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("The vector of start indices (real part)") + " contains " + to_str(real_ptr.GetLength() - 1) + string(" row or column start indices (plus the") + " number of non-zero entries) but there are " + to_str(i) + " rows or columns (" + to_str(i) + " by " + to_str(i) + " matrix)."); } if (imag_ptr.GetLength() - 1 != i) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::SetData(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("The vector of start indices (imaginary part)") + " contains " + to_str(imag_ptr.GetLength()-1) + string(" row or column start indices (plus the") + " number of non-zero entries) but there are " + to_str(i) + " rows or columns (" + to_str(i) + " by " + to_str(i) + " matrix)."); } if ( (static_cast<long int>(2 * real_nz_ - 2) / static_cast<long int>(i) >= static_cast<long int>(i + 1)) || (static_cast<long int>(2 * imag_nz_ - 2) / static_cast<long int>(i) >= static_cast<long int>(i + 1)) ) { this->m_ = 0; this->n_ = 0; real_nz_ = 0; imag_nz_ = 0; real_ptr_ = NULL; imag_ptr_ = NULL; real_ind_ = NULL; imag_ind_ = NULL; this->real_data_ = NULL; this->imag_data_ = NULL; throw WrongDim(string("Matrix_SymComplexSparse::SetData(int, int, ") + string("const Vector&, const Vector&, const Vector&") + ", const Vector&, const Vector&, const Vector&)", string("There are more values (") + to_str(real_values.GetLength()) + " values for the real part and " + to_str(real_values.GetLength()) + string(" values") + string(" for the imaginary part) than elements in") + " the matrix (" + to_str(i) + " by " + to_str(i) + ")."); }#endif this->real_ptr_ = real_ptr.GetData(); this->imag_ptr_ = imag_ptr.GetData(); this->real_ind_ = real_ind.GetData(); this->imag_ind_ = imag_ind.GetData(); this->real_data_ = real_values.GetData(); this->imag_data_ = imag_values.GetData(); real_ptr.Nullify(); imag_ptr.Nullify(); real_ind.Nullify(); imag_ind.Nullify(); real_values.Nullify(); imag_values.Nullify(); } //! Redefines the matrix. /*! It clears the matrix and sets it to a new matrix defined by arrays '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). \param i number of rows. \param j number of columns. \param real_nz number of non-zero entries (real part). \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_nz number of non-zero entries (imaginary 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 On exit, arrays 'real_values', 'real_ptr', 'real_ind', 'imag_values', 'imag_ptr' and 'imag_ind' are managed by the matrix. For example, it means that the destructor will release those arrays; therefore, the user mustn't release those arrays. Moreover 'j' is assumed to be equal to 'i' so that 'j' is discarded. */ template <class T, class Prop, class Storage, class Allocator> inline void Matrix_SymComplexSparse<T, Prop, Storage, Allocator>:: SetData(int i, int j, int real_nz, typename Matrix_SymComplexSparse<T, Prop, Storage, Allocator> ::pointer real_values, int* real_ptr, int* real_ind, int imag_nz, typename Matrix_SymComplexSparse<T, Prop, Storage, Allocator> ::pointer imag_values, int* imag_ptr, int* imag_ind) { this->Clear(); this->m_ = i; this->n_ = i; this->real_nz_ = real_nz; this->imag_nz_ = imag_nz; real_data_ = real_values; imag_data_ = imag_values; real_ind_ = real_ind; imag_ind_ = imag_ind;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -