Public Member Functions | Private Member Functions | Private Attributes | List of all members
oomph::DenseComplexMatrix Class Reference

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>

+ Inheritance diagram for oomph::DenseComplexMatrix:

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 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...
 
- Public Member Functions inherited from oomph::ComplexMatrixBase
 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...
 
- Public Member Functions inherited from oomph::DenseMatrix< std::complex< double > >
 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...
 
DenseMatrixoperator= (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...
 
- Public Member Functions inherited from oomph::Matrix< T, MATRIX_TYPE >
 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...
 
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

- Protected Member Functions inherited from oomph::Matrix< T, MATRIX_TYPE >
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...
 
- Protected Attributes inherited from oomph::DenseMatrix< std::complex< double > >
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...
 

Detailed Description

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 168 of file complex_matrices.h.

Constructor & Destructor Documentation

oomph::DenseComplexMatrix::DenseComplexMatrix ( )
inline

Empty constructor, simply assign the lengths N and M to 0.

Definition at line 190 of file complex_matrices.h.

oomph::DenseComplexMatrix::DenseComplexMatrix ( const unsigned long &  n)
inline

Constructor to build a square n by n matrix.

Definition at line 195 of file complex_matrices.h.

oomph::DenseComplexMatrix::DenseComplexMatrix ( const unsigned long &  n,
const unsigned long &  m 
)
inline

Constructor to build a matrix with n rows and m columns.

Definition at line 200 of file complex_matrices.h.

oomph::DenseComplexMatrix::DenseComplexMatrix ( const unsigned long &  n,
const unsigned long &  m,
const std::complex< double > &  initial_val 
)
inline

Constructor to build a matrix with n rows and m columns, with initial value initial_val.

Definition at line 206 of file complex_matrices.h.

oomph::DenseComplexMatrix::DenseComplexMatrix ( const DenseComplexMatrix matrix)
inline

Broken copy constructor.

Definition at line 214 of file complex_matrices.h.

References oomph::BrokenCopy::broken_copy().

oomph::DenseComplexMatrix::~DenseComplexMatrix ( )
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 110 of file complex_matrices.cc.

References Index, and LU_factors.

Member Function Documentation

void oomph::DenseComplexMatrix::delete_lu_factors ( )
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 92 of file complex_matrices.cc.

References LU_factors, and Overwrite_matrix_storage.

Referenced by ludecompose().

void oomph::DenseComplexMatrix::lubksub ( Vector< std::complex< double > > &  rhs)
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 370 of file complex_matrices.cc.

References i, Index, LU_factors, oomph::DenseMatrix< std::complex< double > >::M, and oomph::DenseMatrix< std::complex< double > >::N.

int oomph::DenseComplexMatrix::ludecompose ( )
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 128 of file complex_matrices.cc.

References delete_lu_factors(), oomph::DenseMatrix< std::complex< double > >::entry(), i, Index, LU_factors, oomph::DenseMatrix< std::complex< double > >::M, oomph::DenseMatrix< std::complex< double > >::Matrixdata, oomph::DenseMatrix< std::complex< double > >::N, and Overwrite_matrix_storage.

void oomph::DenseComplexMatrix::multiply ( const Vector< std::complex< double > > &  x,
Vector< std::complex< double > > &  soln 
)
virtual
void oomph::DenseComplexMatrix::multiply_transpose ( const Vector< std::complex< double > > &  x,
Vector< std::complex< double > > &  soln 
)
virtual
unsigned long oomph::DenseComplexMatrix::ncol ( ) const
inlinevirtual

Return the number of columns of the matrix.

Implements oomph::ComplexMatrixBase.

Definition at line 231 of file complex_matrices.h.

unsigned long oomph::DenseComplexMatrix::nrow ( ) const
inlinevirtual

Return the number of rows of the matrix.

Implements oomph::ComplexMatrixBase.

Definition at line 227 of file complex_matrices.h.

std::complex<double> oomph::DenseComplexMatrix::operator() ( const unsigned long &  i,
const unsigned long &  j 
) const
inlinevirtual

Overload the const version of the round-bracket access operator for read-only access.

Implements oomph::ComplexMatrixBase.

Definition at line 236 of file complex_matrices.h.

References oomph::DenseMatrix< std::complex< double > >::get_entry().

std::complex<double>& oomph::DenseComplexMatrix::operator() ( const unsigned long &  i,
const unsigned long &  j 
)
inline

Overload the non-const version of the round-bracket access operator for read-write access.

Definition at line 242 of file complex_matrices.h.

References oomph::DenseMatrix< std::complex< double > >::entry().

void oomph::DenseComplexMatrix::operator= ( const DenseComplexMatrix )
inline

Broken assignment operator.

Definition at line 220 of file complex_matrices.h.

References oomph::BrokenCopy::broken_assign().

void oomph::DenseComplexMatrix::residual ( const Vector< std::complex< double > > &  x,
const Vector< std::complex< double > > &  rhs,
Vector< std::complex< double > > &  residual 
)
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 446 of file complex_matrices.cc.

References i, oomph::DenseMatrix< std::complex< double > >::M, oomph::DenseMatrix< std::complex< double > >::Matrixdata, and oomph::DenseMatrix< std::complex< double > >::N.

Member Data Documentation

Vector<long>* oomph::DenseComplexMatrix::Index
private

Pointer to storage for the index of permutations in the LU solve.

Definition at line 174 of file complex_matrices.h.

Referenced by lubksub(), ludecompose(), and ~DenseComplexMatrix().

std::complex<double>* oomph::DenseComplexMatrix::LU_factors
private

Pointer to storage for the LU decomposition.

Definition at line 177 of file complex_matrices.h.

Referenced by delete_lu_factors(), lubksub(), ludecompose(), and ~DenseComplexMatrix().

bool oomph::DenseComplexMatrix::Overwrite_matrix_storage
private

Boolean flag used to decided whether the LU decomposition is stored separately, or not

Definition at line 181 of file complex_matrices.h.

Referenced by delete_lu_factors(), and ludecompose().


The documentation for this class was generated from the following files: