Class for dense matrices, storing all the values of the matrix as a pointer to a pointer with assorted output functions inherited from Matrix<T>. The curious recursive template pattern is used here to pass the specific class to the base class so that round bracket access can be inlined. More...
#include <matrices.h>
Inheritance diagram for oomph::DenseMatrix< T >:Public Member Functions | |
| DenseMatrix () | |
| Empty constructor, simply assign the lengths N and M to 0. | |
| DenseMatrix (const DenseMatrix &source_matrix) | |
| Copy constructor: Deep copy! | |
| DenseMatrix & | operator= (const DenseMatrix &source_matrix) |
| Copy assignment. | |
| T & | entry (const unsigned long &i, const unsigned long &j) |
| The access function that will be called by the read-write round-bracket operator. | |
| T | 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. | |
| DenseMatrix (const unsigned long &n) | |
| Constructor to build a square n by n matrix. | |
| DenseMatrix (const unsigned long &n, const unsigned long &m) | |
| Constructor to build a matrix with n rows and m columns. | |
| DenseMatrix (const unsigned long &n, const unsigned long &m, const T &initial_val) | |
| Constructor to build a matrix with n rows and m columns, with initial value initial_val. | |
| virtual | ~DenseMatrix () |
| Destructor, clean up the matrix data. | |
| unsigned long | nrow () const |
| Return the number of rows of the matrix. | |
| unsigned long | ncol () const |
| Return the number of columns of the matrix. | |
| void | resize (const unsigned long &n) |
| Resize to a square nxn matrix; any values already present will be transfered. | |
| 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. | |
| void | resize (const unsigned long &n, const unsigned long &m, const T &initial_value) |
| Resize to a non-square n x m matrix and initialize the new values to initial_value. | |
| void | initialise (const T &val) |
| Initialize all values in the matrix to val. | |
| void | output (std::ostream &outfile) const |
| Output function to print a matrix row-by-row to the stream outfile. | |
| void | output (std::string filename) const |
| Output function to print a matrix row-by-row to a file. Specify filename. | |
| void | indexed_output (std::ostream &outfile) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) | |
| 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. | |
| 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). | |
| void | sparse_indexed_output_helper (std::ostream &outfile, const double &cutoff=0.0) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only. Final optional argument specifies max. size of entries which are set to zero on output. | |
Public Member Functions inherited from oomph::Matrix< T, DenseMatrix< T > > | |
| Matrix () | |
| (Empty) constructor | |
| Matrix (const Matrix &matrix)=delete | |
| Broken copy constructor. | |
| void | operator= (const Matrix &)=delete |
| Broken assignment operator. | |
| virtual | ~Matrix () |
| Virtual (empty) destructor. | |
| 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. | |
| 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. | |
| void | sparse_indexed_output (std::ostream &outfile, const unsigned &precision=0, const bool &output_bottom_right_zero=false, const double &cutoff=0.0) 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). Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output (std::string filename, const unsigned &precision=0, const bool &output_bottom_right_zero=false, const double &cutoff=0.0) 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). Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output_with_cutoff (std::ostream &outfile, const double &cutoff=0.0) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output. | |
| void | sparse_indexed_output_with_cutoff (std::string filename, const double &cutoff=0.0) const |
| Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0. Final optional argument specifies max. size of entries which are set to zero on output. | |
Protected Attributes | |
| T * | Matrixdata |
| Internal representation of matrix as a pointer to data. | |
| unsigned long | N |
| Number of rows. | |
| unsigned long | M |
| Number of columns. | |
Additional Inherited Members | |
Protected Member Functions inherited from oomph::Matrix< T, DenseMatrix< T > > | |
| 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. | |
Class for dense matrices, storing all the values of the matrix as a pointer to a pointer with assorted output functions inherited from Matrix<T>. The curious recursive template pattern is used here to pass the specific class to the base class so that round bracket access can be inlined.
Definition at line 415 of file matrices.h.
|
inline |
Empty constructor, simply assign the lengths N and M to 0.
Definition at line 429 of file matrices.h.
|
inline |
Copy constructor: Deep copy!
Definition at line 432 of file matrices.h.
References i, oomph::DenseMatrix< T >::M, oomph::DenseMatrix< T >::Matrixdata, and oomph::DenseMatrix< T >::N.
| oomph::DenseMatrix< T >::DenseMatrix | ( | const unsigned long & | n | ) |
Constructor to build a square n by n matrix.
Definition at line 2998 of file matrices.h.
References oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
| oomph::DenseMatrix< T >::DenseMatrix | ( | const unsigned long & | n, |
| const unsigned long & | m | ||
| ) |
Constructor to build a matrix with n rows and m columns.
Definition at line 3016 of file matrices.h.
References oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
| oomph::DenseMatrix< T >::DenseMatrix | ( | const unsigned long & | n, |
| const unsigned long & | m, | ||
| const T & | initial_val | ||
| ) |
Constructor to build a matrix with n rows and m columns, with initial value initial_val.
Definition at line 3033 of file matrices.h.
References oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
|
inlinevirtual |
Destructor, clean up the matrix data.
Definition at line 508 of file matrices.h.
References oomph::DenseMatrix< T >::Matrixdata.
|
inline |
The access function that will be called by the read-write round-bracket operator.
Definition at line 477 of file matrices.h.
References i, oomph::DenseMatrix< T >::M, oomph::DenseMatrix< T >::Matrixdata, and oomph::Matrix< T, DenseMatrix< T > >::range_check().
Referenced by oomph::DenseDoubleMatrix::operator()().
|
inline |
The access function the will be called by the read-only (const version) round-bracket operator.
Definition at line 487 of file matrices.h.
References i, oomph::DenseMatrix< T >::M, oomph::DenseMatrix< T >::Matrixdata, and oomph::Matrix< T, DenseMatrix< T > >::range_check().
Referenced by oomph::DenseDoubleMatrix::operator()().
| void oomph::DenseMatrix< T >::indexed_output | ( | std::ostream & | outfile | ) | const |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j)
Indexed output as i,j,a(i,j)
Definition at line 3181 of file matrices.h.
References i, and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
| void oomph::DenseMatrix< T >::indexed_output | ( | std::string | filename | ) | const |
Indexed output function to print a matrix to a file as i,j,a(i,j). Specify filename.
Definition at line 3200 of file matrices.h.
References oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
|
inline |
Initialize all values in the matrix to val.
Definition at line 544 of file matrices.h.
References i, oomph::DenseMatrix< T >::M, oomph::DenseMatrix< T >::Matrixdata, and oomph::DenseMatrix< T >::N.
Referenced by oomph::DGElement::get_inverse_mass_matrix_times_residuals(), oomph::Problem::get_jacobian(), oomph::TimeStepper::make_steady(), and oomph::DGElement::pre_compute_mass_matrix().
|
inlinevirtual |
Return the number of columns of the matrix.
Implements oomph::Matrix< T, DenseMatrix< T > >.
Definition at line 521 of file matrices.h.
References oomph::DenseMatrix< T >::M.
Referenced by oomph::BlockPreconditioner< MATRIX >::clear_block_preconditioner_base(), oomph::DenseDoubleMatrix::ncol(), and oomph::TimeStepper::ntstorage().
|
inlinevirtual |
Return the number of rows of the matrix.
Implements oomph::Matrix< T, DenseMatrix< T > >.
Definition at line 515 of file matrices.h.
References oomph::DenseMatrix< T >::N.
Referenced by oomph::BlockPreconditioner< MATRIX >::clear_block_preconditioner_base(), oomph::TimeStepper::highest_derivative(), and oomph::DenseDoubleMatrix::nrow().
|
inline |
Copy assignment.
Definition at line 450 of file matrices.h.
References i, oomph::DenseMatrix< T >::M, oomph::DenseMatrix< T >::N, and oomph::DenseMatrix< T >::resize().
|
virtual |
Output function to print a matrix row-by-row to the stream outfile.
Reimplemented from oomph::Matrix< T, DenseMatrix< T > >.
Definition at line 3146 of file matrices.h.
References i, and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
| void oomph::DenseMatrix< T >::output | ( | std::string | filename | ) | const |
Output function to print a matrix row-by-row to a file. Specify filename.
Definition at line 3166 of file matrices.h.
References oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::output(), and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
|
virtual |
Output the "bottom right" entry regardless of it being zero or not (this allows automatic detection of matrix size in e.g. matlab, python).
Implements oomph::Matrix< T, DenseMatrix< T > >.
Definition at line 3216 of file matrices.h.
Resize to a square nxn matrix; any values already present will be transfered.
Definition at line 528 of file matrices.h.
References oomph::DenseMatrix< T >::resize().
Referenced by oomph::SpectralElement::assign_all_generic_local_eqn_numbers(), oomph::BDF< NSTEPS >::BDF(), oomph::BlockPreconditioner< MATRIX >::clear_block_preconditioner_base(), oomph::DGElement::get_inverse_mass_matrix_times_residuals(), oomph::Problem::get_jacobian(), oomph::IMRBase::IMRBase(), oomph::KirchhoffLoveShellEquations::KirchhoffLoveShellEquations(), oomph::ContinuationStorageScheme::modify_storage(), oomph::DenseMatrix< T >::operator=(), oomph::DGElement::pre_compute_mass_matrix(), oomph::DenseMatrix< T >::resize(), and oomph::TimeStepper::TimeStepper().
| void oomph::DenseMatrix< T >::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.
Resize to a non-square n_row x m_col matrix, where any values already present will be transfered.
Definition at line 3051 of file matrices.h.
References i, and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
| void oomph::DenseMatrix< T >::resize | ( | const unsigned long & | n, |
| const unsigned long & | m, | ||
| const T & | initial_value | ||
| ) |
Resize to a non-square n x m matrix and initialize the new values to initial_value.
Resize to a non-square n_row x m_col matrix and initialize the new entries to specified value.
Definition at line 3100 of file matrices.h.
References i, and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
|
virtual |
Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only. Final optional argument specifies max. size of entries which are set to zero on output.
Sparse indexed output as i,j,a(i,j) for a(i,j)!=0 only. Final optional argument specifies max. size of entries which are set to zero on output.
Implements oomph::Matrix< T, DenseMatrix< T > >.
Definition at line 3236 of file matrices.h.
References i, and oomph::TAdvectionDiffusionReactionElement< NREAGENT, DIM, NNODE_1D >::TAdvectionDiffusionReactionElement().
|
protected |
Number of columns.
Definition at line 425 of file matrices.h.
Referenced by oomph::DenseMatrix< T >::DenseMatrix(), oomph::DenseMatrix< T >::entry(), oomph::DenseMatrix< T >::get_entry(), oomph::DenseMatrix< T >::initialise(), oomph::DenseMatrix< T >::ncol(), and oomph::DenseMatrix< T >::operator=().
|
protected |
Internal representation of matrix as a pointer to data.
Definition at line 419 of file matrices.h.
Referenced by oomph::DenseMatrix< T >::DenseMatrix(), oomph::DenseMatrix< T >::entry(), oomph::DenseMatrix< T >::get_entry(), oomph::DenseMatrix< T >::initialise(), and oomph::DenseMatrix< T >::~DenseMatrix().
|
protected |
Number of rows.
Definition at line 422 of file matrices.h.
Referenced by oomph::DenseMatrix< T >::DenseMatrix(), oomph::DenseMatrix< T >::initialise(), oomph::DenseMatrix< T >::nrow(), and oomph::DenseMatrix< T >::operator=().