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 &)=delete
 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)
 The contents of the matrix are redistributed to match the new distribution. In a non-MPI build this method does nothing. NOTE 1: The current distribution and the new distribution must have the same number of global rows. NOTE 2: The current distribution and the new distribution must have the same Communicator. More...
 
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
 Overload the round-bracket access operator for read-only access. In a distributed matrix i refers to the local row index. More...
 
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)=delete
 Broken copy constructor. More...
 
void operator= (const Matrix &)=delete
 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)=delete
 Broken copy constructor. More...
 
void operator= (const DoubleMatrixBase &)=delete
 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)=delete
 Broken copy constructor. More...
 
void operator= (const DistributableLinearAlgebraObject &)=delete
 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
 if the communicator_pt is null then the distribution is not setup then false is returned, otherwise return true More...
 
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 885 of file matrices.h.

Constructor & Destructor Documentation

◆ CRDoubleMatrix() [1/4]

oomph::CRDoubleMatrix::CRDoubleMatrix ( )

Default constructor.

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

Default constructor

Definition at line 1214 of file matrices.cc.

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

Referenced by global_matrix().

◆ 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 1311 of file matrices.cc.

References oomph::CRMatrix< T >::build(), oomph::DistributableLinearAlgebraObject::build_distribution(), Built, column_index(), CR_matrix, oomph::DoubleMatrixBase::Default_linear_solver_pt, oomph::DoubleMatrixBase::Linear_solver_pt, ncol(), oomph::LinearAlgebraDistribution::nrow_local(), row_start(), Serial_matrix_matrix_multiply_method, and value().

◆ CRDoubleMatrix() [3/4]

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

◆ CRDoubleMatrix() [4/4]

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

◆ ~CRDoubleMatrix()

oomph::CRDoubleMatrix::~CRDoubleMatrix ( )
virtual

Destructor.

Definition at line 1343 of file matrices.cc.

References clear(), and oomph::DoubleMatrixBase::Default_linear_solver_pt.

Member Function Documentation

◆ add()

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

element-wise addition of this matrix with matrix_in.

Element-wise addition of this matrix with matrix_in.

Definition at line 3515 of file matrices.cc.

References build(), oomph::LinearAlgebraDistribution::built(), built(), column_index(), oomph::DistributableLinearAlgebraObject::distribution_pt(), i, ncol(), nrow(), oomph::DistributableLinearAlgebraObject::nrow_local(), row_start(), and value().

◆ build() [1/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 1353 of file matrices.cc.

References oomph::DistributableLinearAlgebraObject::build_distribution(), and clear().

◆ build() [2/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() [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 1694 of file matrices.cc.

References oomph::CRMatrix< T >::build(), Built, oomph::CRMatrix< T >::clean_up_memory(), column_index(), CR_matrix, oomph::DistributableLinearAlgebraObject::nrow_local(), row_start(), and value().

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

References oomph::CRMatrix< T >::column_index(), and CR_matrix.

◆ 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 3465 of file matrices.cc.

References built(), CR_matrix, oomph::DistributableLinearAlgebraObject::first_row(), oomph::CRMatrix< T >::get_entry(), i, ncol(), nrow(), and oomph::DistributableLinearAlgebraObject::nrow_local().

Referenced by oomph::ComplexDampedJacobi< MATRIX >::complex_smoother_setup(), and 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 1191 of file matrices.h.

References Distributed_matrix_matrix_multiply_method.

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

References Distributed_matrix_matrix_multiply_method.

◆ 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 1366 of file matrices.cc.

References column_index(), oomph::DistributableLinearAlgebraObject::distributed(), i, nrow(), oomph::oomph_info, and row_start().

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

References Index_of_diagonal_entries, and 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 2431 of file matrices.cc.

References build_without_copy(), column_index(), oomph::LinearAlgebraDistribution::communicator_pt(), CRDoubleMatrix(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_pt(), oomph::DistributableLinearAlgebraObject::first_row(), i, ncol(), nnz(), nrow(), oomph::DistributableLinearAlgebraObject::nrow_local(), row_start(), and value().

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

◆ inf_norm()

double oomph::CRDoubleMatrix::inf_norm ( ) const

◆ lubksub()

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

LU back solve for given RHS.

Do back-substitution.

Definition at line 1749 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 1728 of file matrices.cc.

References Built, and 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.

Definition at line 2365 of file matrices.cc.

References build(), oomph::CRMatrix< T >::column_index(), column_index(), CR_matrix, i, ncol(), oomph::DistributableLinearAlgebraObject::nrow_local(), oomph::CRMatrix< T >::row_start(), row_start(), oomph::SparseMatrix< T, MATRIX_TYPE >::value(), and value().

◆ multiply() [1/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.

Definition at line 1992 of file matrices.cc.

References build(), build_without_copy(), built(), Built, column_index(), oomph::DistributableLinearAlgebraObject::distributed(), oomph::DistributableLinearAlgebraObject::distribution_built(), oomph::DistributableLinearAlgebraObject::distribution_pt(), i, oomph::TrilinosEpetraHelpers::multiply(), oomph::QuadTreeNames::N, ncol(), nrow(), row_start(), Serial_matrix_matrix_multiply_method, and value().

◆ multiply() [2/2]

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

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

References CR_matrix, oomph::CRMatrix< T >::get_entry(), and i.

◆ operator=()

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

Broken assignment operator.

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

References CR_matrix, and oomph::CRMatrix< T >::output_bottom_right_zero_helper().

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

References CR_matrix, and oomph::CRMatrix< T >::row_start().

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

References Serial_matrix_matrix_multiply_method.

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

References Serial_matrix_matrix_multiply_method.

◆ 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 1449 of file matrices.cc.

References column_index(), Comparison_struct, oomph::DistributableLinearAlgebraObject::distributed(), i, Index_of_diagonal_entries, nrow(), row_start(), and value().

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

References CR_matrix, and oomph::CRMatrix< T >::sparse_indexed_output_helper().

◆ sparse_indexed_output_with_offset()

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

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

References CR_matrix, and oomph::SparseMatrix< T, MATRIX_TYPE >::value().

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

Referenced by build(), build_without_copy(), built(), clear(), CRDoubleMatrix(), ludecompose(), multiply(), and multiply_transpose().

◆ Comparison_struct

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

Referenced by sort_entries().

◆ CR_matrix

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

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

Referenced by distributed_matrix_matrix_multiply_method().

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

Referenced by get_index_of_diagonal_entries(), and sort_entries().

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

Referenced by CRDoubleMatrix(), multiply(), and serial_matrix_matrix_multiply_method().


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