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

//////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////// 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. 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)
 Resize to a square nxn matrix; any values already present will be transfered. More...
 
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)=delete
 Broken copy constructor. More...
 
void operator= (const Matrix &)=delete
 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 385 of file matrices.h.

Constructor & Destructor Documentation

◆ DenseMatrix() [1/5]

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

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

Definition at line 399 of file matrices.h.

◆ DenseMatrix() [2/5]

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

◆ DenseMatrix() [3/5]

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

Constructor to build a square n by n matrix.

////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////

Constructor to build a square n by n matrix

Definition at line 2906 of file matrices.h.

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

◆ DenseMatrix() [4/5]

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

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

◆ DenseMatrix() [5/5]

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

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

◆ ~DenseMatrix()

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

Destructor, clean up the matrix data.

Definition at line 478 of file matrices.h.

References oomph::DenseMatrix< T >::Matrixdata.

Member Function Documentation

◆ entry()

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 447 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()().

◆ get_entry()

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 457 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()().

◆ indexed_output() [1/2]

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

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

◆ indexed_output() [2/2]

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

◆ initialise()

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

◆ ncol()

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

References oomph::DenseMatrix< T >::M.

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< MATRIX >::clear_block_preconditioner_base(), oomph::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::DenseMatrix< T >::DenseMatrix(), oomph::FiniteElement::dJ_eulerian_dnodal_coordinates(), oomph::DenseDoubleMatrix::eigenvalues_by_jacobi(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::extrapolated_strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::extrapolated_strain_rate(), oomph::CRDoubleMatrixHelpers::gershgorin_eigenvalue_estimate(), oomph::BlockPreconditioner< MATRIX >::get_blocks(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< DIM >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::PoroelasticityEquations< DIM >::get_stress(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::ncol(), oomph::TimeStepper::ntstorage(), oomph::DenseMatrix< T >::operator=(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::AxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::strain_rate(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::NavierStokesEquations< DIM >::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::SpaceTimeNavierStokesEquations< DIM >::strain_rate(), oomph::SpaceTimeNavierStokesMixedOrderEquations< DIM >::strain_rate(), oomph::LinearisedNavierStokesEquations::strain_rate(), and oomph::PolarNavierStokesEquations::strain_rate_by_r().

◆ nrow()

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

References oomph::DenseMatrix< T >::N.

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< MATRIX >::clear_block_preconditioner_base(), oomph::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::DenseMatrix< T >::DenseMatrix(), oomph::FiniteElement::dJ_eulerian_dnodal_coordinates(), oomph::DenseDoubleMatrix::eigenvalues_by_jacobi(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::extrapolated_strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::extrapolated_strain_rate(), oomph::AxisymmetricNavierStokesEquations::fill_in_contribution_to_hessian_vector_products(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::fill_in_contribution_to_hessian_vector_products(), oomph::DisplacementBasedFoepplvonKarmanEquations::fill_in_contribution_to_jacobian_and_mass_matrix(), oomph::CRDoubleMatrixHelpers::gershgorin_eigenvalue_estimate(), oomph::BlockPreconditioner< MATRIX >::get_blocks(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< DIM >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::PoroelasticityEquations< DIM >::get_stress(), oomph::TimeStepper::highest_derivative(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::nrow(), oomph::DenseMatrix< T >::operator=(), oomph::SecondInvariantHelper::second_invariant(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::AxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianAxisymmetricNavierStokesEquations::strain_rate(), oomph::GeneralisedNewtonianNavierStokesEquations< DIM >::strain_rate(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::NavierStokesEquations< DIM >::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::SpaceTimeNavierStokesEquations< DIM >::strain_rate(), oomph::SpaceTimeNavierStokesMixedOrderEquations< DIM >::strain_rate(), oomph::LinearisedNavierStokesEquations::strain_rate(), and oomph::PolarNavierStokesEquations::strain_rate_by_r().

◆ operator=()

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

◆ output() [1/2]

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

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

◆ output() [2/2]

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

References oomph::CommandLineArgs::output().

◆ output_bottom_right_zero_helper()

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

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

Definition at line 3124 of file matrices.h.

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

◆ resize() [1/3]

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

◆ resize() [2/3]

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

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

◆ resize() [3/3]

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

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

◆ sparse_indexed_output_helper()

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

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

Member Data Documentation

◆ M

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

◆ Matrixdata

template<class T >
T* oomph::DenseMatrix< T >::Matrixdata
protected

◆ N

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

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