Public Member Functions | Protected Attributes | List of all members
oomph::DenseMatrix< T > Class Template Reference

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 <communicator.h>

+ Inheritance diagram for oomph::DenseMatrix< T >:

Public Member Functions

 DenseMatrix ()
 Empty constructor, simply assign the lengths N and M to 0. More...
 
 DenseMatrix (const DenseMatrix &source_matrix)
 Copy constructor: Deep copy! More...
 
DenseMatrixoperator= (const DenseMatrix &source_matrix)
 Copy assignment. More...
 
T & entry (const unsigned long &i, const unsigned long &j)
 The access function that will be called by the read-write round-bracket operator. More...
 
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...
 
 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 T &initial_val)
 Constructor to build a matrix with n rows and m columns, with initial value initial_val. 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 T &initial_value)
 Resize to a non-square n x m matrix and initialize the new values to initial_value. More...
 
void initialise (const T &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, DenseMatrix< T > >
 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...
 

Protected Attributes

T * 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...
 

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. More...
 

Detailed Description

template<class T>
class oomph::DenseMatrix< T >

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 50 of file communicator.h.

Constructor & Destructor Documentation

template<class T>
oomph::DenseMatrix< T >::DenseMatrix ( )
inline

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

Definition at line 422 of file matrices.h.

template<class T>
oomph::DenseMatrix< T >::DenseMatrix ( const DenseMatrix< T > &  source_matrix)
inline

Copy constructor: Deep copy!

Definition at line 425 of file matrices.h.

template<class T >
oomph::DenseMatrix< T >::DenseMatrix ( const unsigned long &  n)

Constructor to build a square n by n matrix.

Definition at line 2693 of file matrices.h.

References oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T >
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 2710 of file matrices.h.

References oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T>
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 2727 of file matrices.h.

References oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T>
virtual oomph::DenseMatrix< T >::~DenseMatrix ( )
inlinevirtual

Destructor, clean up the matrix data.

Definition at line 501 of file matrices.h.

Member Function Documentation

template<class T>
T& oomph::DenseMatrix< T >::entry ( const unsigned long &  i,
const unsigned long &  j 
)
inline

The access function that will be called by the read-write round-bracket operator.

Definition at line 470 of file matrices.h.

Referenced by oomph::DenseDoubleMatrix::operator()().

template<class T>
T oomph::DenseMatrix< T >::get_entry ( const unsigned long &  i,
const unsigned long &  j 
) const
inline

The access function the will be called by the read-only (const version) round-bracket operator.

Definition at line 480 of file matrices.h.

Referenced by oomph::DenseDoubleMatrix::operator()().

template<class T >
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 2868 of file matrices.h.

References i, and oomph::QuadTreeNames::N.

template<class T >
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 2888 of file matrices.h.

template<class T>
void oomph::DenseMatrix< T >::initialise ( const T &  val)
inline
template<class T>
unsigned long oomph::DenseMatrix< T >::ncol ( ) const
inlinevirtual

Return the number of columns of the matrix.

Implements oomph::Matrix< T, DenseMatrix< T > >.

Definition at line 507 of file matrices.h.

Referenced by oomph::ConstitutiveLaw::are_matrices_of_equal_dimensions(), oomph::ConstitutiveLaw::calculate_contravariant(), oomph::ConstitutiveLaw::calculate_d_contravariant_dG(), oomph::ConstitutiveLaw::calculate_d_second_piola_kirchhoff_stress_dG(), oomph::BlockPreconditioner< CRDoubleMatrix >::clear_block_preconditioner_base(), oomph::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::FiniteElement::dJ_eulerian_dnodal_coordinates(), oomph::DenseDoubleMatrix::eigenvalues_by_jacobi(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::extrapolated_strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::extrapolated_strain_rate(), oomph::CRDoubleMatrixHelpers::gershgorin_eigenvalue_estimate(), oomph::BlockPreconditioner< MATRIX >::get_blocks(), oomph::PoroelasticityEquations< DIM >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< DIM >::get_stress(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::ncol(), oomph::BoundaryNodeBase::set_coordinates_on_boundary(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::strain_rate(), oomph::AxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::strain_rate(), oomph::NavierStokesEquations< DIM >::strain_rate(), and oomph::PolarNavierStokesEquations::strain_rate_by_r().

template<class T>
unsigned long oomph::DenseMatrix< T >::nrow ( ) const
inlinevirtual

Return the number of rows of the matrix.

Implements oomph::Matrix< T, DenseMatrix< T > >.

Definition at line 504 of file matrices.h.

Referenced by oomph::ConstitutiveLaw::are_matrices_of_equal_dimensions(), oomph::HelmholtzMGPreconditioner< DIM >::block_preconditioner_self_test(), oomph::GeneralisedHookean::calculate_second_piola_kirchhoff_stress(), oomph::IsotropicStrainEnergyFunctionConstitutiveLaw::calculate_second_piola_kirchhoff_stress(), oomph::BlockPreconditioner< CRDoubleMatrix >::clear_block_preconditioner_base(), oomph::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::FiniteElement::dJ_eulerian_dnodal_coordinates(), oomph::DenseDoubleMatrix::eigenvalues_by_jacobi(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::extrapolated_strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::extrapolated_strain_rate(), oomph::AxisymmetricNavierStokesEquations::fill_in_contribution_to_hessian_vector_products(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::fill_in_contribution_to_hessian_vector_products(), oomph::FoepplvonKarmanDisplacementEquations::fill_in_contribution_to_jacobian_and_mass_matrix(), oomph::CRDoubleMatrixHelpers::gershgorin_eigenvalue_estimate(), oomph::BlockPreconditioner< MATRIX >::get_blocks(), oomph::PoroelasticityEquations< DIM >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< DIM >::get_stress(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::nrow(), oomph::SecondInvariantHelper::second_invariant(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::strain_rate(), oomph::AxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::strain_rate(), oomph::NavierStokesEquations< DIM >::strain_rate(), and oomph::PolarNavierStokesEquations::strain_rate_by_r().

template<class T>
DenseMatrix& oomph::DenseMatrix< T >::operator= ( const DenseMatrix< T > &  source_matrix)
inline

Copy assignment.

Definition at line 443 of file matrices.h.

template<class T >
void oomph::DenseMatrix< T >::output ( std::ostream &  outfile) const
virtual

Output function to print a matrix row-by-row to the stream outfile.

Reimplemented from oomph::Matrix< T, DenseMatrix< T > >.

Definition at line 2831 of file matrices.h.

References i, and oomph::QuadTreeNames::N.

template<class T >
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 2852 of file matrices.h.

References oomph::output().

template<class T >
void oomph::DenseMatrix< T >::output_bottom_right_zero_helper ( std::ostream &  outfile) const
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).

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 2904 of file matrices.h.

References oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T>
void oomph::DenseMatrix< T >::resize ( const unsigned long &  n)
inline
template<class T >
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 2743 of file matrices.h.

References i, oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T>
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 2789 of file matrices.h.

References i, oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

template<class T >
void oomph::DenseMatrix< T >::sparse_indexed_output_helper ( std::ostream &  outfile) const
virtual

Indexed output function to print a matrix to the stream outfile as i,j,a(i,j) for a(i,j)!=0 only.

Sparse indexed output as i,j,a(i,j) for a(i,j)!=0 only.

Implements oomph::Matrix< T, DenseMatrix< T > >.

Definition at line 2923 of file matrices.h.

References i, oomph::QuadTreeNames::N, and oomph::ElementGeometry::T.

Member Data Documentation

template<class T>
unsigned long oomph::DenseMatrix< T >::M
protected
template<class T>
T* oomph::DenseMatrix< T >::Matrixdata
protected
template<class T>
unsigned long oomph::DenseMatrix< T >::N
protected

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