34 #ifndef OOMPH_COMPLEX_MATRICES_HEADER 35 #define OOMPH_COMPLEX_MATRICES_HEADER 39 #include <oomph-lib-config.h> 80 virtual unsigned long nrow()
const=0;
83 virtual unsigned long ncol()
const=0;
91 virtual std::complex<double>
operator()(
const unsigned long &
i,
92 const unsigned long &j)
100 "ludecompose() has not been written for this matrix class\n",
101 OOMPH_CURRENT_FUNCTION,
102 OOMPH_EXCEPTION_LOCATION);
113 "lubksub() has not been written for this matrix class\n",
114 OOMPH_CURRENT_FUNCTION,
115 OOMPH_EXCEPTION_LOCATION);
122 virtual void solve(
Vector<std::complex<double> > &rhs);
126 virtual void solve(
const Vector<std::complex<double> > &rhs,
127 Vector<std::complex<double> > &soln);
131 const Vector<std::complex<double> > &b,
138 const Vector<std::complex<double> > &rhs)
140 unsigned long n=rhs.size();
144 for (
unsigned long i=0;i<n;i++)
146 ans = std::max(ans,std::abs(res[i]));
153 Vector<std::complex<double> > &soln)=0;
157 Vector<std::complex<double> > &soln)=0;
172 virtual std::complex<double>
operator()(
const unsigned long &
i,
173 const unsigned long &j)
const;
176 virtual std::complex<double>&
operator()(
const unsigned long &i,
177 const unsigned long &j);
180 Vector<std::complex<double> > &result);
183 Vector<std::complex<double> > &result)
190 const Vector<std::complex<double> > &b,
194 void resize(
const unsigned&
N,
const unsigned& M);
196 void resize(
const unsigned& N,
const unsigned& M, std::complex<double> z);
198 unsigned long nrow()
const {
return Matrixdata.size(); }
200 unsigned long ncol()
const {
return Matrixdata.size(); }
230 void delete_lu_factors();
236 Index(0), LU_factors(0),
237 Overwrite_matrix_storage(false) {}
242 Overwrite_matrix_storage(false) {}
247 Overwrite_matrix_storage(false) {}
252 const std::complex<double> &initial_val) :
254 Index(0), LU_factors(0),
255 Overwrite_matrix_storage(false) {}
260 diagonal_matrix.
nrow(),
std::complex<double>(0.0,0.0)),
261 Index(0), LU_factors(0), Overwrite_matrix_storage(false)
263 for (
unsigned i=0;
i<diagonal_matrix.
nrow();
i++)
265 this->entry(
i,
i) = diagonal_matrix(
i,
i);
284 inline unsigned long nrow()
const 288 inline unsigned long ncol()
const 294 const unsigned long &j)
300 const unsigned long &j)
318 const Vector<std::complex<double> >& rhs,
323 Vector<std::complex<double> > &soln);
327 Vector<std::complex<double> > &soln);
333 void scale(
const double& c);
336 void scale(
const std::complex<double>& c);
360 Doc_stats_during_solve=
false;
369 const unsigned long &n,
370 const unsigned long &m) :
371 CRMatrix<
std::complex<double> >(value,column_index,row_start,n,m),
372 F_factors(0), Info(0)
375 Doc_stats_during_solve=
false;
404 inline unsigned long nrow()
const 408 inline unsigned long ncol()
const 413 const unsigned long &j)
423 void clean_up_memory();
427 const Vector<std::complex<double> > &b,
432 Vector<std::complex<double> > &soln);
437 Vector<std::complex<double> > &soln);
453 public CCMatrix<std::complex<double> >
475 Doc_stats_during_solve=
false;
486 const unsigned long &n,
487 const unsigned long &m) :
488 CCMatrix<
std::complex<double> >(value,row_index,column_start,n,m),
489 F_factors(0), Info(0)
492 Doc_stats_during_solve=
false;
519 inline unsigned long nrow()
const 523 inline unsigned long ncol()
const 529 const unsigned long &j)
539 void clean_up_memory();
543 const Vector<std::complex<double> > &b,
549 Vector<std::complex<double> > &soln);
554 Vector<std::complex<double> > &soln);
virtual double max_residual(const Vector< std::complex< double > > &x, const Vector< std::complex< double > > &rhs)
Find the maximum residual r=b-Ax – generic version, can be overloaded for specific derived classes w...
Vector< std::complex< double > > Matrixdata
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
virtual void multiply_transpose(const Vector< std::complex< double > > &x, Vector< std::complex< double > > &soln)=0
Multiply the transposed matrix by the vector x: soln=A^T x.
Abstract base class for matrices of complex doubles – adds abstract interfaces for solving...
CRComplexMatrix(const Vector< std::complex< double > > &value, const Vector< int > &column_index, const Vector< int > &row_start, const unsigned long &n, const unsigned long &m)
Constructor: Pass vector of values, vector of column indices, vector of row starts and number of colu...
DenseComplexMatrix(const unsigned long &n, const unsigned long &m)
Constructor to build a matrix with n rows and m columns.
bool Doc_stats_during_solve
Flag to indicate if stats are to be displayed during solution of linear system with SuperLU...
unsigned long ncol() const
Return the number of columns of the matrix.
virtual ~ComplexMatrixBase()
virtual (empty) destructor
Vector< long > * Index
Pointer to storage for the index of permutations in the LU solve.
std::complex< double > operator()(const unsigned long &i, const unsigned long &j) const
Overload the const version of the round-bracket access operator for read-only access.
virtual ~CCComplexMatrix()
Destructor: Kill the LU factors if they have been setup.
std::complex< double > operator()(const unsigned long &i, const unsigned long &j) const
Overload the round-bracket access operator for read-only access.
ComplexMatrixBase()
(Empty) constructor.
CCComplexMatrix(const Vector< std::complex< double > > &value, const Vector< int > &row_index, const Vector< int > &column_start, const unsigned long &n, const unsigned long &m)
Constructor: Pass vector of values, vector of row indices, vector of column starts and number of rows...
A class for compressed row matrices.
bool Doc_stats_during_solve
Flag to indicate if stats are to be displayed during solution of linear system with SuperLU...
virtual unsigned long nrow() const =0
Return the number of rows of the matrix.
unsigned long nrow() const
Return the number of rows of the matrix.
DenseComplexMatrix(const DenseComplexMatrix &matrix)
Broken copy constructor.
DiagonalComplexMatrix(const unsigned long n, std::complex< double > &z)
unsigned long nrow() const
Return the number of rows of the matrix.
void disable_doc_stats()
the solve
CRComplexMatrix()
Default constructor.
void enable_doc_stats()
Set flag to indicate that stats are to be displayed during solution of linear system with SuperLU...
virtual ~CRComplexMatrix()
Destructor: Kill the LU decomposition if it has been computed.
void * F_factors
Storage for the LU factors as required by SuperLU.
int Info
Info flag for the SuperLU solver.
CCComplexMatrix(const CCComplexMatrix &matrix)
Broken copy constructor.
void multiply_transpose(const Vector< std::complex< double > > &x, Vector< std::complex< double > > &result)
Multiply the transposed matrix by the vector x: soln=A^T x.
void disable_doc_stats()
the solve
void operator=(const ComplexMatrixBase &)
Broken assignment operator.
void operator=(const DenseComplexMatrix &)
Broken assignment operator.
virtual std::complex< double > operator()(const unsigned long &i, const unsigned long &j) const =0
Round brackets to give access as a(i,j) for read only (we're not providing a general interface for co...
bool Overwrite_matrix_storage
A class for compressed column matrices: a sparse matrix format The class is passed as the MATRIX_TYPE...
virtual void residual(const Vector< std::complex< double > > &x, const Vector< std::complex< double > > &b, Vector< std::complex< double > > &residual)=0
Find the residual, i.e. r=b-Ax the residual.
int Info
Info flag for the SuperLU solver.
ComplexMatrixBase(const ComplexMatrixBase &matrix)
Broken copy constructor.
DenseComplexMatrix(const unsigned long &n, const unsigned long &m, const std::complex< double > &initial_val)
Constructor to build a matrix with n rows and m columns, with initial value initial_val.
std::complex< double > * LU_factors
Pointer to storage for the LU decomposition.
void operator=(const CCComplexMatrix &)
Broken assignment operator.
virtual void multiply(const Vector< std::complex< double > > &x, Vector< std::complex< double > > &soln)=0
Multiply the matrix by the vector x: soln=Ax.
void * F_factors
Storage for the LU factors as required by SuperLU.
unsigned long ncol() const
Return the number of columns of the matrix.
CRComplexMatrix(const CRComplexMatrix &matrix)
Broken copy constructor.
A class for compressed row matrices, a sparse storage format Once again the recursive template trick ...
virtual void residual(const Vector< std::complex< double > > &x, const Vector< std::complex< double > > &b, Vector< std::complex< double > > &residual)
Find the residual, i.e. r=b-Ax the residual.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
virtual void lubksub(Vector< std::complex< double > > &rhs)
LU backsubstitue a previously LU-decomposed matrix; The passed rhs will be over-written with the solu...
DenseComplexMatrix(const unsigned long &n)
Constructor to build a square n by n matrix.
unsigned long nrow() const
Return the number of rows of the matrix.
A class for compressed column matrices that store doubles.
Class for dense matrices, storing all the values of the matrix as a pointer to a pointer with assorte...
unsigned long ncol() const
Return the number of columns of the matrix.
DenseComplexMatrix()
Empty constructor, simply assign the lengths N and M to 0.
unsigned long ncol() const
Return the number of columns of the matrix.
CCComplexMatrix()
Default constructor.
std::complex< double > operator()(const unsigned long &i, const unsigned long &j) const
Overload the round-bracket access operator to provide read-only (const) access to the data...
void operator=(const CRComplexMatrix &)
Broken assignment operator.
DenseComplexMatrix(const DiagonalComplexMatrix &diagonal_matrix)
Constructor to build a dense matrix from a diagonal matrix.
std::complex< double > & operator()(const unsigned long &i, const unsigned long &j)
Overload the non-const version of the round-bracket access operator for read-write access...
virtual void solve(Vector< std::complex< double > > &rhs)
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution)...
DiagonalComplexMatrix(const unsigned long n)
unsigned long nrow() const
Return the number of rows of the matrix.
virtual int ludecompose()
LU decomposition of the matrix using the appropriate linear solver. Return the sign of the determinan...
Class of matrices containing double complex, and stored as a DenseMatrix<complex<double> >...
void enable_doc_stats()
Set flag to indicate that stats are to be displayed during solution of linear system with SuperLU...
virtual unsigned long ncol() const =0
Return the number of columns of the matrix.