Class of matrices containing double complex, and stored as a DenseMatrix<complex<double> >, but with solving functionality inherited from the abstract ComplexMatrix class. More...
#include <complex_matrices.h>
Public Member Functions | |
DenseComplexMatrix () | |
Empty constructor, simply assign the lengths N and M to 0. More... | |
DenseComplexMatrix (const unsigned long &n) | |
Constructor to build a square n by n matrix. More... | |
DenseComplexMatrix (const unsigned long &n, const unsigned long &m) | |
Constructor to build a matrix with n rows and m columns. More... | |
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. More... | |
DenseComplexMatrix (const DiagonalComplexMatrix &diagonal_matrix) | |
Constructor to build a dense matrix from a diagonal matrix. More... | |
DenseComplexMatrix (const DenseComplexMatrix &matrix) | |
Broken copy constructor. More... | |
void | operator= (const DenseComplexMatrix &) |
Broken assignment operator. More... | |
unsigned long | nrow () const |
Return the number of rows of the matrix. More... | |
unsigned long | ncol () const |
Return the number of columns of the matrix. More... | |
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. More... | |
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. More... | |
virtual | ~DenseComplexMatrix () |
Destructor, delete the storage for Index vector and LU storage (if any) More... | |
int | ludecompose () |
Overload the LU decomposition. For this storage scheme the matrix storage will be over-writeen by its LU decomposition. More... | |
void | lubksub (Vector< std::complex< double > > &rhs) |
Overload the LU back substitution. Note that the rhs will be overwritten with the solution vector. More... | |
void | residual (const Vector< std::complex< double > > &x, const Vector< std::complex< double > > &rhs, Vector< std::complex< double > > &residual) |
Find the residual of Ax=b, ie r=b-Ax for the "solution" x. More... | |
void | multiply (const Vector< std::complex< double > > &x, Vector< std::complex< double > > &soln) |
Multiply the matrix by the vector x: soln=Ax. More... | |
void | multiply_transpose (const Vector< std::complex< double > > &x, Vector< std::complex< double > > &soln) |
Multiply the transposed matrix by the vector x: soln=A^T x. More... | |
void | multiply (const DenseComplexMatrix &matrix_in, DenseComplexMatrix &result) |
Multiply this matrix by the DenseComplexMatrix matrix_in. More... | |
void | scale (const double &c) |
Scale this matrix by a double c. More... | |
void | scale (const std::complex< double > &c) |
Scale this matrix by a complex number c. More... | |
![]() | |
ComplexMatrixBase () | |
(Empty) constructor. More... | |
ComplexMatrixBase (const ComplexMatrixBase &matrix) | |
Broken copy constructor. More... | |
void | operator= (const ComplexMatrixBase &) |
Broken assignment operator. More... | |
virtual | ~ComplexMatrixBase () |
virtual (empty) destructor More... | |
virtual void | solve (Vector< std::complex< double > > &rhs) |
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution). The default should not need to be over-written. More... | |
virtual void | solve (const Vector< std::complex< double > > &rhs, Vector< std::complex< double > > &soln) |
Complete LU solve (Nothing gets overwritten!). The default should not need to be overwritten. More... | |
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 where the max. can be determined "on the fly". More... | |
![]() | |
DenseMatrix () | |
Empty constructor, simply assign the lengths N and M to 0. More... | |
DenseMatrix (const DenseMatrix &source_matrix) | |
Copy constructor: Deep copy! More... | |
DenseMatrix (const unsigned long &n) | |
Constructor to build a square n by n matrix. More... | |
DenseMatrix (const unsigned long &n, const unsigned long &m) | |
Constructor to build a matrix with n rows and m columns. More... | |
DenseMatrix (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. More... | |
DenseMatrix & | operator= (const DenseMatrix &source_matrix) |
Copy assignment. More... | |
std::complex< double > & | entry (const unsigned long &i, const unsigned long &j) |
The access function that will be called by the read-write round-bracket operator. More... | |
std::complex< double > | get_entry (const unsigned long &i, const unsigned long &j) const |
The access function the will be called by the read-only (const version) round-bracket operator. More... | |
virtual | ~DenseMatrix () |
Destructor, clean up the matrix data. More... | |
unsigned long | nrow () const |
Return the number of rows of the matrix. More... | |
unsigned long | ncol () const |
Return the number of columns of the matrix. More... | |
void | resize (const unsigned long &n) |
void | resize (const unsigned long &n, const unsigned long &m) |
Resize to a non-square n x m matrix; any values already present will be transfered. More... | |
void | resize (const unsigned long &n, const unsigned long &m, const std::complex< double > &initial_value) |
Resize to a non-square n x m matrix and initialize the new values to initial_value. More... | |
void | initialise (const std::complex< double > &val) |
Initialize all values in the matrix to val. More... | |
void | output (std::ostream &outfile) const |
Output function to print a matrix row-by-row to the stream outfile. More... | |
void | output (std::string filename) const |
Output function to print a matrix row-by-row to a file. Specify filename. More... | |
void | indexed_output (std::ostream &outfile) const |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) More... | |
void | indexed_output (std::string filename) const |
Indexed output function to print a matrix to a file as i,j,a(i,j). Specify filename. More... | |
void | output_bottom_right_zero_helper (std::ostream &outfile) const |
Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). More... | |
void | sparse_indexed_output_helper (std::ostream &outfile) const |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only. More... | |
![]() | |
Matrix () | |
(Empty) constructor More... | |
Matrix (const Matrix &matrix) | |
Broken copy constructor. More... | |
void | operator= (const Matrix &) |
Broken assignment operator. More... | |
virtual | ~Matrix () |
Virtual (empty) destructor. More... | |
T | operator() (const unsigned long &i, const unsigned long &j) const |
Round brackets to give access as a(i,j) for read only (we're not providing a general interface for component-wise write access since not all matrix formats allow efficient direct access!) The function uses the MATRIX_TYPE template parameter to call the get_entry() function which must be defined in all derived classes that are to be fully instantiated. More... | |
T & | operator() (const unsigned long &i, const unsigned long &j) |
Round brackets to give access as a(i,j) for read-write access. The function uses the MATRIX_TYPE template parameter to call the entry() function which must be defined in all derived classes that are to be fully instantiated. If the particular Matrix does not allow write access, the function should break with an error message. More... | |
void | sparse_indexed_output (std::ostream &outfile, const unsigned &precision=0, const bool &output_bottom_right_zero=false) const |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only with specified precision (if precision=0 then nothing is changed). If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). More... | |
void | sparse_indexed_output (std::string filename, const unsigned &precision=0, const bool &output_bottom_right_zero=false) const |
Indexed output function to print a matrix to the file named filename as i,j,a(i,j) for a(i,j)!=0 only with specified precision. If optional boolean flag is set to true we also output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python). More... | |
Private Member Functions | |
void | delete_lu_factors () |
Private Attributes | |
Vector< long > * | Index |
Pointer to storage for the index of permutations in the LU solve. More... | |
std::complex< double > * | LU_factors |
Pointer to storage for the LU decomposition. More... | |
bool | Overwrite_matrix_storage |
Additional Inherited Members | |
![]() | |
void | range_check (const unsigned long &i, const unsigned long &j) const |
Range check to catch when an index is out of bounds, if so, it issues a warning message and dies by throwing an OomphLibError . More... | |
![]() | |
std::complex< double > * | Matrixdata |
Internal representation of matrix as a pointer to data. More... | |
unsigned long | N |
Number of rows. More... | |
unsigned long | M |
Number of columns. More... | |
Class of matrices containing double complex, and stored as a DenseMatrix<complex<double> >, but with solving functionality inherited from the abstract ComplexMatrix class.
Definition at line 213 of file complex_matrices.h.
|
inline |
Empty constructor, simply assign the lengths N and M to 0.
Definition at line 235 of file complex_matrices.h.
|
inline |
Constructor to build a square n by n matrix.
Definition at line 240 of file complex_matrices.h.
|
inline |
Constructor to build a matrix with n rows and m columns.
Definition at line 245 of file complex_matrices.h.
|
inline |
Constructor to build a matrix with n rows and m columns, with initial value initial_val.
Definition at line 251 of file complex_matrices.h.
|
inline |
Constructor to build a dense matrix from a diagonal matrix.
Definition at line 258 of file complex_matrices.h.
References i, and oomph::DiagonalComplexMatrix::nrow().
|
inline |
Broken copy constructor.
Definition at line 271 of file complex_matrices.h.
References oomph::BrokenCopy::broken_copy().
|
virtual |
Destructor, delete the storage for Index vector and LU storage (if any)
Destructor clean up the LU factors that have been allocated.
Definition at line 190 of file complex_matrices.cc.
|
private |
Function that deletes the storage for the LU_factors, if it is not the same as the matrix storage
Delete the storage that has been allocated for the LU factors, if the matrix data is not itself being overwritten.
Definition at line 172 of file complex_matrices.cc.
|
virtual |
Overload the LU back substitution. Note that the rhs will be overwritten with the solution vector.
Back substitute an LU decomposed matrix.
Reimplemented from oomph::ComplexMatrixBase.
Definition at line 450 of file complex_matrices.cc.
References i, and oomph::QuadTreeNames::N.
|
virtual |
Overload the LU decomposition. For this storage scheme the matrix storage will be over-writeen by its LU decomposition.
LU decompose a matrix, over-writing it and recording the pivots numbers in the Index vector. Returns the sign of the determinant.
Reimplemented from oomph::ComplexMatrixBase.
Definition at line 208 of file complex_matrices.cc.
References i, and oomph::QuadTreeNames::N.
|
virtual |
Multiply the matrix by the vector x: soln=Ax.
Implements oomph::ComplexMatrixBase.
Definition at line 587 of file complex_matrices.cc.
References i, and oomph::QuadTreeNames::N.
Referenced by oomph::Conformal2DPMLElement::assemble_conformal_jacobian(), oomph::TangentiallyVaryingConformal2DPMLElement::assemble_conformal_jacobian(), and oomph::AnnularPMLElementBase::radial_to_cartesian_jacobian().
void oomph::DenseComplexMatrix::multiply | ( | const DenseComplexMatrix & | matrix_in, |
DenseComplexMatrix & | result | ||
) |
Multiply this matrix by the DenseComplexMatrix matrix_in.
Function to multiply this matrix by the DenseComplexMatrix matrix_in.
Definition at line 675 of file complex_matrices.cc.
References i, oomph::ComplexMatrixBase::ncol(), ncol(), oomph::ComplexMatrixBase::nrow(), nrow(), and oomph::DenseMatrix< T >::resize().
|
virtual |
Multiply the transposed matrix by the vector x: soln=A^T x.
Implements oomph::ComplexMatrixBase.
Definition at line 628 of file complex_matrices.cc.
References i, and oomph::QuadTreeNames::N.
|
inlinevirtual |
Return the number of columns of the matrix.
Implements oomph::ComplexMatrixBase.
Definition at line 288 of file complex_matrices.h.
References oomph::ComplexMatrixBase::ncol().
Referenced by oomph::PMLElementBase< 2 >::compute_laplace_matrix_and_det(), oomph::TangentiallyDiscontinuousConformal2DPMLElement::compute_transformed_normal_derivative(), and multiply().
|
inlinevirtual |
Return the number of rows of the matrix.
Implements oomph::ComplexMatrixBase.
Definition at line 284 of file complex_matrices.h.
References oomph::ComplexMatrixBase::nrow().
Referenced by oomph::PMLElementBase< 2 >::compute_laplace_matrix_and_det(), oomph::TangentiallyDiscontinuousConformal2DPMLElement::compute_transformed_normal_derivative(), and multiply().
|
inlinevirtual |
Overload the const version of the round-bracket access operator for read-only access.
Implements oomph::ComplexMatrixBase.
Definition at line 293 of file complex_matrices.h.
|
inline |
Overload the non-const version of the round-bracket access operator for read-write access.
Definition at line 299 of file complex_matrices.h.
References oomph::ComplexMatrixBase::lubksub(), oomph::ComplexMatrixBase::ludecompose(), oomph::ComplexMatrixBase::multiply(), oomph::ComplexMatrixBase::multiply_transpose(), and oomph::ComplexMatrixBase::residual().
|
inline |
Broken assignment operator.
Definition at line 277 of file complex_matrices.h.
References oomph::BrokenCopy::broken_assign().
|
virtual |
Find the residual of Ax=b, ie r=b-Ax for the "solution" x.
Find the residual of Ax=b, i.e. r=b-Ax.
Implements oomph::ComplexMatrixBase.
Definition at line 526 of file complex_matrices.cc.
References i, oomph::QuadTreeNames::N, and oomph::ComplexMatrixBase::residual().
void oomph::DenseComplexMatrix::scale | ( | const double & | c | ) |
Scale this matrix by a double c.
Scale the matrix by the real c.
Definition at line 719 of file complex_matrices.cc.
References i, and oomph::QuadTreeNames::N.
void oomph::DenseComplexMatrix::scale | ( | const std::complex< double > & | c | ) |
Scale this matrix by a complex number c.
Scale the matrix by the complex number c.
Definition at line 734 of file complex_matrices.cc.
References i, oomph::QuadTreeNames::N, and oomph::superlu_complex().
|
private |
Pointer to storage for the index of permutations in the LU solve.
Definition at line 219 of file complex_matrices.h.
|
private |
Pointer to storage for the LU decomposition.
Definition at line 222 of file complex_matrices.h.
|
private |
Boolean flag used to decided whether the LU decomposition is stored separately, or not
Definition at line 226 of file complex_matrices.h.