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

A class for compressed row matrices. This is a distributable object. More...

#include <matrices.h>

+ Inheritance diagram for oomph::CRDoubleMatrix:

Classes

struct  CRDoubleMatrixComparisonHelper
 Create a struct to provide a comparison function for std::sort. More...
 

Public Member Functions

 CRDoubleMatrix ()
 Default constructor. More...
 
 CRDoubleMatrix (const LinearAlgebraDistribution *distribution_pt, const unsigned &ncol, const Vector< double > &value, const Vector< int > &column_index, const Vector< int > &row_start)
 Constructor: vector of values, vector of column indices, vector of row starts and number of rows and columns. More...
 
 CRDoubleMatrix (const LinearAlgebraDistribution *distribution_pt)
 Constructor: just stores the distribution but does not build the matrix. More...
 
 CRDoubleMatrix (const CRDoubleMatrix &matrix)
 Copy constructor. More...
 
void operator= (const CRDoubleMatrix &)
 Broken assignment operator. More...
 
virtual ~CRDoubleMatrix ()
 Destructor. More...
 
const Vector< int > get_index_of_diagonal_entries () const
 Access function: returns the vector Index_of_diagonal_entries. The i-th entry of the vector contains the index of the last entry below or on the diagonal. If there are no entries below or on the diagonal then the corresponding entry is -1. If, however, there are no entries in the row then the entry is irrelevant and is kept as the initialised value; 0. More...
 
bool entries_are_sorted (const bool &doc_unordered_entries=false) const
 Runs through the column index vector and checks if the entries follow the regular lexicographical ordering of matrix entries, i.e. it will check (at the i-th row of the matrix) if the entries in the column index vector associated with this row are in increasing order. More...
 
void sort_entries ()
 Sorts the entries associated with each row of the matrix in the column index vector and the value vector into ascending order and sets up the Index_of_diagonal_entries vector. More...
 
void build (const LinearAlgebraDistribution *distribution_pt, const unsigned &ncol, const Vector< double > &value, const Vector< int > &column_index, const Vector< int > &row_start)
 build method: vector of values, vector of column indices, vector of row starts and number of rows and columns. More...
 
void build (const LinearAlgebraDistribution *distribution_pt)
 rebuild the matrix - assembles an empty matrix will a defined distribution More...
 
void build (const unsigned &ncol, const Vector< double > &value, const Vector< int > &column_index, const Vector< int > &row_start)
 keeps the existing distribution and just matrix that is stored More...
 
void build_without_copy (const unsigned &ncol, const unsigned &nnz, double *value, int *column_index, int *row_start)
 keeps the existing distribution and just matrix that is stored without copying the matrix data More...
 
void redistribute (const LinearAlgebraDistribution *const &dist_pt)
 
void clear ()
 clear 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 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...
 
void sparse_indexed_output_with_offset (std::string filename)
 Indexed output function to print a matrix to a file as i,j,a(i,j) for a(i,j)!=0 only. Specify filename. This uses acual global row numbers. More...
 
double operator() (const unsigned long &i, const unsigned long &j) const
 
int * row_start ()
 Access to C-style row_start array. More...
 
const int * row_start () const
 Access to C-style row_start array (const version) More...
 
int * column_index ()
 Access to C-style column index array. More...
 
const int * column_index () const
 Access to C-style column index array (const version) More...
 
double * value ()
 Access to C-style value array. More...
 
const double * value () const
 Access to C-style value array (const version) More...
 
unsigned long nnz () const
 Return the number of nonzero entries (the local nnz) More...
 
virtual void ludecompose ()
 LU decomposition using SuperLU if matrix is not distributed or distributed onto a single processor. More...
 
virtual void lubksub (DoubleVector &rhs)
 LU back solve for given RHS. More...
 
void multiply (const DoubleVector &x, DoubleVector &soln) const
 Multiply the matrix by the vector x: soln=Ax. More...
 
void multiply_transpose (const DoubleVector &x, DoubleVector &soln) const
 Multiply the transposed matrix by the vector x: soln=A^T x. More...
 
void multiply (const CRDoubleMatrix &matrix_in, CRDoubleMatrix &result) const
 Function to multiply this matrix by the CRDoubleMatrix matrix_in. In a serial matrix, there are 4 methods available: Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinox Epetra Matrix Matrix Mulitply (ml based) If Trilinos is installed then Method 4 is employed by default, otherwise Method 2 is employed by default. In a distributed matrix, only Trilinos Epetra Matrix Matrix multiply is available. More...
 
void matrix_reduction (const double &alpha, CRDoubleMatrix &reduced_matrix)
 For every row, find the maximum absolute value of the entries in this row. Set all values that are less than alpha times this maximum to zero and return the resulting matrix in reduced_matrix. Note: Diagonal entries are retained regardless of their size. More...
 
unsigned & serial_matrix_matrix_multiply_method ()
 Access function to Serial_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for serial matrices. Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinos Epetra Matrix Matrix multiply (ML based). More...
 
const unsigned & serial_matrix_matrix_multiply_method () const
 Read only access function (const version) to Serial_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for serial matrices. Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinos Epetra Matrix Matrix multiply (ML based). More...
 
unsigned & distributed_matrix_matrix_multiply_method ()
 Access function to Distributed_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for distributed matrices. Method 1: Trilinos Epetra Matrix Matrix multiply. Method 2: Trilinos Epetra Matrix Matrix multiply (ML based). More...
 
const unsigned & distributed_matrix_matrix_multiply_method () const
 Read only access function (const version) to Distributed_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for distributed matrices. Method 1: Trilinos Epetra Matrix Matrix multiply. Method 2: Trilinos Epetra Matrix Matrix multiply (ML based). More...
 
bool built () const
 access function to the Built flag - indicates whether the matrix has been build - i.e. the distribution has been defined and the matrix assembled. More...
 
CRDoubleMatrixglobal_matrix () const
 if this matrix is distributed then a the equivalent global matrix is built using new and returned. The calling method is responsible for the destruction of the new matrix. More...
 
void get_matrix_transpose (CRDoubleMatrix *result) const
 Returns the transpose of this matrix. More...
 
double inf_norm () const
 returns the inf-norm of this matrix More...
 
Vector< double > diagonal_entries () const
 returns a Vector of diagonal entries of this matrix. This only works with square matrices. This condition may be relaxed in the future if need be. More...
 
void add (const CRDoubleMatrix &matrix_in, CRDoubleMatrix &result_matrix) const
 element-wise addition of this matrix with matrix_in. More...
 
- Public Member Functions inherited from oomph::Matrix< double, CRDoubleMatrix >
 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...
 
double 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...
 
double & 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...
 
virtual void output (std::ostream &outfile) const
 Output function to print a matrix row-by-row, in the form a(0,0) a(0,1) ... a(1,0) a(1,1) ... ... to the stream outfile. Broken virtual since it might not be sensible to implement this for some sparse matrices. 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...
 
- Public Member Functions inherited from oomph::DoubleMatrixBase
 DoubleMatrixBase ()
 (Empty) constructor. More...
 
 DoubleMatrixBase (const DoubleMatrixBase &matrix)
 Broken copy constructor. More...
 
void operator= (const DoubleMatrixBase &)
 Broken assignment operator. More...
 
virtual ~DoubleMatrixBase ()
 virtual (empty) destructor More...
 
LinearSolver *& linear_solver_pt ()
 Return a pointer to the linear solver object. More...
 
LinearSolver *const & linear_solver_pt () const
 Return a pointer to the linear solver object (const version) More...
 
void solve (DoubleVector &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...
 
void solve (const DoubleVector &rhs, DoubleVector &soln)
 Complete LU solve (Nothing gets overwritten!). The default should not need to be overwritten. More...
 
void solve (Vector< 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...
 
void solve (const Vector< double > &rhs, Vector< double > &soln)
 Complete LU solve (Nothing gets overwritten!). The default should not need to be overwritten. More...
 
virtual void residual (const DoubleVector &x, const DoubleVector &b, DoubleVector &residual_)
 Find the residual, i.e. r=b-Ax the residual. More...
 
virtual double max_residual (const DoubleVector &x, const DoubleVector &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::DistributableLinearAlgebraObject
 DistributableLinearAlgebraObject ()
 Default constructor - create a distribution. More...
 
 DistributableLinearAlgebraObject (const DistributableLinearAlgebraObject &matrix)
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)
 Broken assignment operator. More...
 
virtual ~DistributableLinearAlgebraObject ()
 Destructor. More...
 
LinearAlgebraDistributiondistribution_pt () const
 access to the LinearAlgebraDistribution More...
 
unsigned nrow () const
 access function to the number of global rows. More...
 
unsigned nrow_local () const
 access function for the num of local rows on this processor. More...
 
unsigned nrow_local (const unsigned &p) const
 access function for the num of local rows on this processor. More...
 
unsigned first_row () const
 access function for the first row on this processor More...
 
unsigned first_row (const unsigned &p) const
 access function for the first row on this processor More...
 
bool distributed () const
 distribution is serial or distributed More...
 
bool distribution_built () const
 
void build_distribution (const LinearAlgebraDistribution *const dist_pt)
 setup the distribution of this distributable linear algebra object More...
 
void build_distribution (const LinearAlgebraDistribution &dist)
 setup the distribution of this distributable linear algebra object More...
 

Public Attributes

struct oomph::CRDoubleMatrix::CRDoubleMatrixComparisonHelper Comparison_struct
 

Private Attributes

Vector< int > Index_of_diagonal_entries
 Vector whose i'th entry contains the index of the last entry below or on the diagonal of the i'th row of the matrix. More...
 
unsigned Serial_matrix_matrix_multiply_method
 Flag to determine which matrix-matrix multiplication method is used (for serial (or global) matrices) More...
 
unsigned Distributed_matrix_matrix_multiply_method
 Flag to determine which matrix-matrix multiplication method is used (for distributed matrices) More...
 
CRMatrix< double > CR_matrix
 Storage for the Matrix in CR Format. More...
 
bool Built
 Flag to indicate whether the matrix has been built - i.e. the distribution has been setup AND the matrix has been assembled. More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::Matrix< double, CRDoubleMatrix >
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 Member Functions inherited from oomph::DistributableLinearAlgebraObject
void clear_distribution ()
 clear the distribution of this distributable linear algebra object More...
 
- Protected Attributes inherited from oomph::DoubleMatrixBase
LinearSolverLinear_solver_pt
 
LinearSolverDefault_linear_solver_pt
 

Detailed Description

A class for compressed row matrices. This is a distributable object.

Definition at line 872 of file matrices.h.

Constructor & Destructor Documentation

◆ CRDoubleMatrix() [1/4]

oomph::CRDoubleMatrix::CRDoubleMatrix ( )

Default constructor.

Definition at line 1238 of file matrices.cc.

References oomph::DoubleMatrixBase::Default_linear_solver_pt, and oomph::DoubleMatrixBase::Linear_solver_pt.

◆ CRDoubleMatrix() [2/4]

oomph::CRDoubleMatrix::CRDoubleMatrix ( const LinearAlgebraDistribution distribution_pt,
const unsigned &  ncol,
const Vector< double > &  value,
const Vector< int > &  column_index,
const Vector< int > &  row_start 
)

Constructor: vector of values, vector of column indices, vector of row starts and number of rows and columns.

Constructor: Takes the distribution and the number of columns, as well as the vector of values, vector of column indices,vector of row starts.

Definition at line 1336 of file matrices.cc.

References oomph::DoubleMatrixBase::Default_linear_solver_pt, oomph::DoubleMatrixBase::Linear_solver_pt, oomph::CCDoubleMatrix::ncol(), and oomph::LinearAlgebraDistribution::nrow_local().

◆ CRDoubleMatrix() [3/4]

oomph::CRDoubleMatrix::CRDoubleMatrix ( const LinearAlgebraDistribution distribution_pt)

Constructor: just stores the distribution but does not build the matrix.

Constructor: just stores the distribution but does not build the matrix

Definition at line 1310 of file matrices.cc.

References oomph::DoubleMatrixBase::Default_linear_solver_pt, and oomph::DoubleMatrixBase::Linear_solver_pt.

◆ CRDoubleMatrix() [4/4]

oomph::CRDoubleMatrix::CRDoubleMatrix ( const CRDoubleMatrix matrix)

◆ ~CRDoubleMatrix()

oomph::CRDoubleMatrix::~CRDoubleMatrix ( )
virtual

Destructor.

Definition at line 1367 of file matrices.cc.

References oomph::DoubleMatrixBase::Default_linear_solver_pt.

Member Function Documentation

◆ add()

void oomph::CRDoubleMatrix::add ( const CRDoubleMatrix matrix_in,
CRDoubleMatrix result_matrix 
) const

◆ build() [1/3]

void oomph::CRDoubleMatrix::build ( const LinearAlgebraDistribution distribution_pt,
const unsigned &  ncol,
const Vector< double > &  value,
const Vector< int > &  column_index,
const Vector< int > &  row_start 
)

◆ build() [2/3]

void oomph::CRDoubleMatrix::build ( const LinearAlgebraDistribution distribution_pt)

rebuild the matrix - assembles an empty matrix will a defined distribution

Rebuild the matrix - assembles an empty matrix with a defined distribution.

Definition at line 1377 of file matrices.cc.

◆ build() [3/3]

void oomph::CRDoubleMatrix::build ( const unsigned &  ncol,
const Vector< double > &  value,
const Vector< int > &  column_index,
const Vector< int > &  row_start 
)

keeps the existing distribution and just matrix that is stored

method to rebuild the matrix, but not the distribution

Definition at line 1714 of file matrices.cc.

◆ build_without_copy()

void oomph::CRDoubleMatrix::build_without_copy ( const unsigned &  ncol,
const unsigned &  nnz,
double *  value,
int *  column_index,
int *  row_start 
)

◆ built()

bool oomph::CRDoubleMatrix::built ( ) const
inline

◆ clear()

void oomph::CRDoubleMatrix::clear ( )

◆ column_index() [1/2]

int* oomph::CRDoubleMatrix::column_index ( )
inline

◆ column_index() [2/2]

const int* oomph::CRDoubleMatrix::column_index ( ) const
inline

Access to C-style column index array (const version)

Definition at line 1059 of file matrices.h.

◆ diagonal_entries()

Vector< double > oomph::CRDoubleMatrix::diagonal_entries ( ) const

returns a Vector of diagonal entries of this matrix. This only works with square matrices. This condition may be relaxed in the future if need be.

Return the diagonal entries of the matrix. This only works with square matrices. This condition may be relaxed in the future if need be.

Definition at line 3442 of file matrices.cc.

References i, oomph::CCDoubleMatrix::ncol(), and oomph::CCDoubleMatrix::nrow().

Referenced by oomph::LagrangeEnforcedFlowPreconditioner::setup().

◆ distributed_matrix_matrix_multiply_method() [1/2]

unsigned& oomph::CRDoubleMatrix::distributed_matrix_matrix_multiply_method ( )
inline

Access function to Distributed_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for distributed matrices. Method 1: Trilinos Epetra Matrix Matrix multiply. Method 2: Trilinos Epetra Matrix Matrix multiply (ML based).

Definition at line 1158 of file matrices.h.

Referenced by oomph::CRDoubleMatrixHelpers::deep_copy().

◆ distributed_matrix_matrix_multiply_method() [2/2]

const unsigned& oomph::CRDoubleMatrix::distributed_matrix_matrix_multiply_method ( ) const
inline

Read only access function (const version) to Distributed_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for distributed matrices. Method 1: Trilinos Epetra Matrix Matrix multiply. Method 2: Trilinos Epetra Matrix Matrix multiply (ML based).

Definition at line 1169 of file matrices.h.

◆ entries_are_sorted()

bool oomph::CRDoubleMatrix::entries_are_sorted ( const bool &  doc_unordered_entries = false) const

Runs through the column index vector and checks if the entries follow the regular lexicographical ordering of matrix entries, i.e. it will check (at the i-th row of the matrix) if the entries in the column index vector associated with this row are in increasing order.

Runs through the column index vector and checks if the entries are arranged arbitrarily or if they follow the regular lexicographical of matrices. If a boolean argument is provided with the assignment TRUE then information on the first entry which is not in the correct position will also be given.

Definition at line 1390 of file matrices.cc.

References i, oomph::CCDoubleMatrix::nrow(), and oomph::oomph_info.

◆ get_index_of_diagonal_entries()

const Vector<int> oomph::CRDoubleMatrix::get_index_of_diagonal_entries ( ) const
inline

Access function: returns the vector Index_of_diagonal_entries. The i-th entry of the vector contains the index of the last entry below or on the diagonal. If there are no entries below or on the diagonal then the corresponding entry is -1. If, however, there are no entries in the row then the entry is irrelevant and is kept as the initialised value; 0.

Definition at line 912 of file matrices.h.

References oomph::Global_string_for_annotation::string().

◆ get_matrix_transpose()

void oomph::CRDoubleMatrix::get_matrix_transpose ( CRDoubleMatrix result) const

◆ global_matrix()

CRDoubleMatrix * oomph::CRDoubleMatrix::global_matrix ( ) const

if this matrix is distributed then a the equivalent global matrix is built using new and returned. The calling method is responsible for the destruction of the new matrix.

if this matrix is distributed then the equivalent global matrix is built using new and returned. The calling method is responsible for the destruction of the new matrix.

Definition at line 2458 of file matrices.cc.

References build_without_copy(), i, oomph::CCDoubleMatrix::ncol(), oomph::SparseMatrix< double, CCMatrix< double > >::nnz(), oomph::CCDoubleMatrix::nrow(), and oomph::SparseMatrix< double, CCMatrix< double > >::value().

Referenced by oomph::ILUZeroPreconditioner< CRDoubleMatrix >::setup().

◆ inf_norm()

double oomph::CRDoubleMatrix::inf_norm ( ) const

returns the inf-norm of this matrix

Compute infinity (maximum) norm of matrix.

Definition at line 3392 of file matrices.cc.

References i, and oomph::SparseMatrix< double, CCMatrix< double > >::value().

Referenced by oomph::PseudoElasticPreconditionerScalingHelperOld::s_inf_norm().

◆ lubksub()

void oomph::CRDoubleMatrix::lubksub ( DoubleVector rhs)
virtual

LU back solve for given RHS.

Do back-substitution.

Definition at line 1772 of file matrices.cc.

References oomph::DoubleVector::built(), oomph::DoubleMatrixBase::Default_linear_solver_pt, and oomph::DistributableLinearAlgebraObject::distribution_pt().

◆ ludecompose()

void oomph::CRDoubleMatrix::ludecompose ( )
virtual

LU decomposition using SuperLU if matrix is not distributed or distributed onto a single processor.

Do LU decomposition.

Definition at line 1749 of file matrices.cc.

References oomph::DoubleMatrixBase::Default_linear_solver_pt.

◆ matrix_reduction()

void oomph::CRDoubleMatrix::matrix_reduction ( const double &  alpha,
CRDoubleMatrix reduced_matrix 
)

For every row, find the maximum absolute value of the entries in this row. Set all values that are less than alpha times this maximum to zero and return the resulting matrix in reduced_matrix. Note: Diagonal entries are retained regardless of their size.

For every row, find the maximum absolute value of the entries in this row. Set all values that are less than alpha times this maximum to zero and return the resulting matrix in reduced_matrix. Note: Diagonal entries are retained regardless of their size.

Definition at line 2392 of file matrices.cc.

References oomph::CCMatrix< double >::build(), i, oomph::CCDoubleMatrix::ncol(), and oomph::SparseMatrix< double, CCMatrix< double > >::value().

◆ multiply() [1/2]

void oomph::CRDoubleMatrix::multiply ( const DoubleVector x,
DoubleVector soln 
) const
virtual

◆ multiply() [2/2]

void oomph::CRDoubleMatrix::multiply ( const CRDoubleMatrix matrix_in,
CRDoubleMatrix result 
) const

Function to multiply this matrix by the CRDoubleMatrix matrix_in. In a serial matrix, there are 4 methods available: Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinox Epetra Matrix Matrix Mulitply (ml based) If Trilinos is installed then Method 4 is employed by default, otherwise Method 2 is employed by default. In a distributed matrix, only Trilinos Epetra Matrix Matrix multiply is available.

Function to multiply this matrix by the CRDoubleMatrix matrix_in. In a serial matrix, there are 4 methods available: Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinox Epetra Matrix Matrix Mulitply (ml based) If Trilinos is installed then Method 4 is employed by default, otherwise Method 2 is employed by default. In a distributed matrix, only Trilinos Epetra Matrix Matrix multiply is available.

Definition at line 2017 of file matrices.cc.

References build(), build_without_copy(), built(), column_index(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_built(), oomph::DistributableLinearAlgebraObject::distribution_pt(), i, oomph::SparseMatrix< double, CCMatrix< double > >::M, oomph::TrilinosEpetraHelpers::multiply(), oomph::SparseMatrix< double, CCMatrix< double > >::N, ncol(), oomph::SparseMatrix< double, CCMatrix< double > >::Nnz, oomph::CCDoubleMatrix::nrow(), row_start(), oomph::SparseMatrix< double, CCMatrix< double > >::Value, oomph::SparseMatrix< double, CCMatrix< double > >::value(), and value().

◆ multiply_transpose()

void oomph::CRDoubleMatrix::multiply_transpose ( const DoubleVector x,
DoubleVector soln 
) const
virtual

◆ ncol()

unsigned long oomph::CRDoubleMatrix::ncol ( ) const
inlinevirtual

◆ nnz()

unsigned long oomph::CRDoubleMatrix::nnz ( ) const
inline

◆ nrow()

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

◆ operator()()

double oomph::CRDoubleMatrix::operator() ( const unsigned long &  i,
const unsigned long &  j 
) const
inlinevirtual

Overload the round-bracket access operator for read-only access. In a distributed matrix i refers to the local row index.

Implements oomph::DoubleMatrixBase.

Definition at line 1045 of file matrices.h.

◆ operator=()

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

Broken assignment operator.

Definition at line 898 of file matrices.h.

References oomph::BrokenCopy::broken_assign().

◆ output_bottom_right_zero_helper()

void oomph::CRDoubleMatrix::output_bottom_right_zero_helper ( std::ostream &  outfile) const
inlinevirtual

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< double, CRDoubleMatrix >.

Definition at line 1006 of file matrices.h.

◆ redistribute()

void oomph::CRDoubleMatrix::redistribute ( const LinearAlgebraDistribution *const &  dist_pt)

◆ row_start() [1/2]

int* oomph::CRDoubleMatrix::row_start ( )
inline

◆ row_start() [2/2]

const int* oomph::CRDoubleMatrix::row_start ( ) const
inline

Access to C-style row_start array (const version)

Definition at line 1053 of file matrices.h.

◆ serial_matrix_matrix_multiply_method() [1/2]

unsigned& oomph::CRDoubleMatrix::serial_matrix_matrix_multiply_method ( )
inline

Access function to Serial_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for serial matrices. Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinos Epetra Matrix Matrix multiply (ML based).

Definition at line 1127 of file matrices.h.

Referenced by oomph::CRDoubleMatrixHelpers::deep_copy().

◆ serial_matrix_matrix_multiply_method() [2/2]

const unsigned& oomph::CRDoubleMatrix::serial_matrix_matrix_multiply_method ( ) const
inline

Read only access function (const version) to Serial_matrix_matrix_multiply_method, the flag which determines the matrix matrix multiplication method used for serial matrices. Method 1: First runs through this matrix and matrix_in to find the storage requirements for result - arrays of the correct size are then allocated before performing the calculation. Minimises memory requirements but more costly. Method 2: Grows storage for values and column indices of result 'on the fly' using an array of maps. Faster but more memory intensive. Method 3: Grows storage for values and column indices of result 'on the fly' using a vector of vectors. Not particularly impressive on the platforms we tried... Method 4: Trilinos Epetra Matrix Matrix multiply. Method 5: Trilinos Epetra Matrix Matrix multiply (ML based).

Definition at line 1148 of file matrices.h.

◆ sort_entries()

void oomph::CRDoubleMatrix::sort_entries ( )

Sorts the entries associated with each row of the matrix in the column index vector and the value vector into ascending order and sets up the Index_of_diagonal_entries vector.

This helper function sorts the entries in the column index vector and the value vector. During the construction of the matrix the entries were most likely assigned in an arbitrary order. As a result, it cannot be assumed that the entries in the column index vector corresponding to each row of the matrix have been arranged in increasing order. During the setup an additional vector will be set up; Index_of_diagonal_entries. The i-th entry of this vector contains the index of the last entry below or on the diagonal. If there are no entries below or on the diagonal then the corresponding entry is -1. If, however, there are no entries in the row then the entry is irrelevant and is kept as the initialised value; 0.

Definition at line 1473 of file matrices.cc.

References i, oomph::CCDoubleMatrix::nrow(), and oomph::SparseMatrix< double, CCMatrix< double > >::value().

Referenced by oomph::GS< CRDoubleMatrix >::setup_helper().

◆ sparse_indexed_output_helper()

void oomph::CRDoubleMatrix::sparse_indexed_output_helper ( std::ostream &  outfile) const
inlinevirtual

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

Implements oomph::Matrix< double, CRDoubleMatrix >.

Definition at line 1013 of file matrices.h.

◆ sparse_indexed_output_with_offset()

void oomph::CRDoubleMatrix::sparse_indexed_output_with_offset ( std::string  filename)
inline

Indexed output function to print a matrix to a file as i,j,a(i,j) for a(i,j)!=0 only. Specify filename. This uses acual global row numbers.

Definition at line 1021 of file matrices.h.

References oomph::LinearAlgebraDistribution::first_row(), and i.

Referenced by oomph::NavierStokesSchurComplementPreconditioner::setup().

◆ value() [1/2]

double* oomph::CRDoubleMatrix::value ( )
inline

◆ value() [2/2]

const double* oomph::CRDoubleMatrix::value ( ) const
inline

Access to C-style value array (const version)

Definition at line 1065 of file matrices.h.

Member Data Documentation

◆ Built

bool oomph::CRDoubleMatrix::Built
private

Flag to indicate whether the matrix has been built - i.e. the distribution has been setup AND the matrix has been assembled.

Definition at line 1217 of file matrices.h.

◆ Comparison_struct

struct oomph::CRDoubleMatrix::CRDoubleMatrixComparisonHelper oomph::CRDoubleMatrix::Comparison_struct

◆ CR_matrix

CRMatrix<double> oomph::CRDoubleMatrix::CR_matrix
private

Storage for the Matrix in CR Format.

Definition at line 1213 of file matrices.h.

◆ Distributed_matrix_matrix_multiply_method

unsigned oomph::CRDoubleMatrix::Distributed_matrix_matrix_multiply_method
private

Flag to determine which matrix-matrix multiplication method is used (for distributed matrices)

Definition at line 1210 of file matrices.h.

◆ Index_of_diagonal_entries

Vector<int> oomph::CRDoubleMatrix::Index_of_diagonal_entries
private

Vector whose i'th entry contains the index of the last entry below or on the diagonal of the i'th row of the matrix.

Definition at line 1202 of file matrices.h.

◆ Serial_matrix_matrix_multiply_method

unsigned oomph::CRDoubleMatrix::Serial_matrix_matrix_multiply_method
private

Flag to determine which matrix-matrix multiplication method is used (for serial (or global) matrices)

Definition at line 1206 of file matrices.h.


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