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>
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... | |
DenseMatrix & | operator= (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... | |
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. 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... | |
![]() | |
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... | |
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 | |
![]() | |
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... | |
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.
|
inline |
Empty constructor, simply assign the lengths N and M to 0.
Definition at line 422 of file matrices.h.
|
inline |
Copy constructor: Deep copy!
Definition at line 425 of file matrices.h.
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.
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.
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.
|
inlinevirtual |
Destructor, clean up the matrix data.
Definition at line 501 of file matrices.h.
|
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()().
|
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()().
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.
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.
|
inline |
Initialize all values in the matrix to val.
Definition at line 523 of file matrices.h.
Referenced by oomph::PeriodicOrbitTemporalMesh< oomph::SpectralPeriodicOrbitElement< NNODE_1D > >::assemble_residuals_and_jacobian(), oomph::FSIHermiteBeamElement::dposition_dlagrangian_at_local_coordinate(), oomph::FSIDiagHermiteShellElement::dposition_dlagrangian_at_local_coordinate(), oomph::GeneralisedElement::get_djacobian_and_dmass_matrix_dparameter(), oomph::GeneralisedElement::get_djacobian_dparameter(), oomph::GeneralisedElement::get_hessian_vector_products(), oomph::PeriodicOrbitBaseElement::get_inner_product_matrix(), oomph::GeneralisedElement::get_jacobian(), oomph::Problem::get_jacobian(), oomph::GeneralisedElement::get_jacobian_and_mass_matrix(), oomph::GeneralisedElement::get_mass_matrix(), oomph::PseudoBucklingRingElement::get_residuals_generic(), and oomph::TimeStepper::make_steady().
|
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::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::DenseMatrix< bool >::DenseMatrix(), 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< CRDoubleMatrix >::get_blocks(), oomph::PoroelasticityEquations< 2 >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< 2 >::get_stress(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::ncol(), oomph::TimeStepper::ntstorage(), oomph::DenseMatrix< bool >::operator=(), oomph::BoundaryNodeBase::set_coordinates_on_boundary(), oomph::NewmarkBDF< NSTEPS >::set_weights(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::LinearisedNavierStokesEquations::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().
|
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::GeneralisedHookean::calculate_second_piola_kirchhoff_stress(), oomph::IsotropicStrainEnergyFunctionConstitutiveLaw::calculate_second_piola_kirchhoff_stress(), oomph::CRDoubleMatrixHelpers::concatenate(), oomph::CRDoubleMatrixHelpers::concatenate_without_communication(), oomph::DenseMatrix< bool >::DenseMatrix(), 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::DisplacementBasedFoepplvonKarmanEquations::fill_in_contribution_to_jacobian_and_mass_matrix(), oomph::CRDoubleMatrixHelpers::gershgorin_eigenvalue_estimate(), oomph::BlockPreconditioner< CRDoubleMatrix >::get_blocks(), oomph::PoroelasticityEquations< 2 >::get_strain(), oomph::PVDEquationsBase< DIM >::get_strain(), oomph::LinearElasticityEquationsBase< DIM >::get_strain(), oomph::PoroelasticityEquations< 2 >::get_stress(), oomph::LinearElasticityEquations< DIM >::get_stress(), oomph::TimeStepper::highest_derivative(), oomph::CRDoubleMatrixHelpers::inf_norm(), oomph::ConstitutiveLaw::is_matrix_square(), oomph::DenseDoubleMatrix::nrow(), oomph::DenseMatrix< bool >::operator=(), oomph::SecondInvariantHelper::second_invariant(), oomph::LagrangeEnforcedFlowPreconditioner::setup(), oomph::LinearisedAxisymmetricNavierStokesEquations::strain_rate(), oomph::PolarNavierStokesEquations::strain_rate(), oomph::LinearisedNavierStokesEquations::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().
|
inline |
Copy assignment.
Definition at line 443 of file matrices.h.
|
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.
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.
|
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.
|
inline |
Resize to a square nxn matrix; any values already present will be transfered
Definition at line 511 of file matrices.h.
Referenced by oomph::SpectralElement::assign_all_generic_local_eqn_numbers(), oomph::PMLElementBase< 2 >::compute_laplace_matrix_and_det(), oomph::DenseDoubleMatrix::eigenvalues_by_jacobi(), oomph::PeriodicOrbitEquations::fill_in_generic_residual_contribution_orbit(), oomph::RefineableNavierStokesBoussinesqElement< NST_ELEMENT, AD_ELEMENT >::get_dbody_force_nst_dexternal_element_data(), oomph::NavierStokesBoussinesqElement< NST_ELEMENT, AD_ELEMENT >::get_dbody_force_nst_dexternal_element_data(), oomph::Problem::get_fd_jacobian(), oomph::Problem::get_jacobian(), oomph::IMRBase::IMRBase(), oomph::KirchhoffLoveShellEquations::KirchhoffLoveShellEquations(), oomph::DenseDoubleMatrix::matrix_reduction(), oomph::ContinuationStorageScheme::modify_storage(), oomph::DenseComplexMatrix::multiply(), oomph::DenseDoubleMatrix::multiply(), oomph::DenseMatrix< bool >::resize(), oomph::PseudoElasticPreconditioner::setup(), oomph::BinaryTree::setup_static_data(), oomph::QuadTree::setup_static_data(), oomph::OcTree::setup_static_data(), oomph::HSL_MA42::solve(), 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 2743 of file matrices.h.
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.
|
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.
|
protected |
Number of columns.
Definition at line 417 of file matrices.h.
|
protected |
Internal representation of matrix as a pointer to data.
Definition at line 411 of file matrices.h.
|
protected |
Number of rows.
Definition at line 414 of file matrices.h.