Cantera  2.3.0
Public Member Functions | Protected Attributes | List of all members
GeneralMatrix Class Referenceabstract

Generic matrix. More...

#include <GeneralMatrix.h>

Inheritance diagram for GeneralMatrix:
[legend]

Public Member Functions

 GeneralMatrix (int matType=-1)
 Base Constructor. More...
 
virtual GeneralMatrixduplMyselfAsGeneralMatrix () const =0
 Duplicator member function. More...
 
virtual void zero ()=0
 Zero the matrix elements. More...
 
virtual void mult (const doublereal *b, doublereal *prod) const =0
 Multiply A*b and write result to prod. More...
 
virtual void leftMult (const doublereal *const b, doublereal *const prod) const =0
 Multiply b*A and write result to prod. More...
 
virtual int factor ()=0
 Factors the A matrix, overwriting A. More...
 
virtual int factorQR ()
 Factors the A matrix using the QR algorithm, overwriting A. More...
 
virtual doublereal rcondQR ()
 Returns an estimate of the inverse of the condition number for the matrix. More...
 
virtual doublereal rcond (doublereal a1norm)=0
 Returns an estimate of the inverse of the condition number for the matrix. More...
 
virtual void useFactorAlgorithm (int fAlgorithm)
 Change the way the matrix is factored. More...
 
virtual int factorAlgorithm () const =0
 Return the factor algorithm used. More...
 
virtual doublereal oneNorm () const =0
 Calculate the one norm of the matrix. More...
 
virtual size_t nRows () const =0
 Return the number of rows in the matrix. More...
 
virtual size_t nRowsAndStruct (size_t *const iStruct=0) const =0
 Return the size and structure of the matrix. More...
 
virtual void clearFactorFlag ()
 clear the factored flag More...
 
virtual int solve (doublereal *b, size_t nrhs=1, size_t ldb=0)=0
 Solves the Ax = b system returning x in the b spot. More...
 
virtual bool factored () const
 true if the current factorization is up to date with the matrix More...
 
virtual doublereal * ptrColumn (size_t j)=0
 Return a pointer to the top of column j, columns are assumed to be contiguous in memory. More...
 
virtual doublereal & operator() (size_t i, size_t j)=0
 Index into the (i,j) element. More...
 
virtual doublereal operator() (size_t i, size_t j) const =0
 Constant Index into the (i,j) element. More...
 
virtual vector_fp::iterator begin ()=0
 Return an iterator pointing to the first element. More...
 
virtual vector_fp::const_iterator begin () const =0
 Return a const iterator pointing to the first element. More...
 
virtual doublereal *const * colPts ()=0
 Return a vector of const pointers to the columns. More...
 
virtual size_t checkRows (doublereal &valueSmall) const =0
 Check to see if we have any zero rows in the Jacobian. More...
 
virtual size_t checkColumns (doublereal &valueSmall) const =0
 Check to see if we have any zero columns in the Jacobian. More...
 

Protected Attributes

int m_factored
 Indicates whether the matrix is factored. More...
 

Detailed Description

Generic matrix.

Definition at line 21 of file GeneralMatrix.h.

Constructor & Destructor Documentation

◆ GeneralMatrix()

GeneralMatrix ( int  matType = -1)
inlineexplicit

Base Constructor.

Definition at line 25 of file GeneralMatrix.h.

References Cantera::warn_deprecated().

Member Function Documentation

◆ duplMyselfAsGeneralMatrix()

virtual GeneralMatrix* duplMyselfAsGeneralMatrix ( ) const
pure virtual

Duplicator member function.

This function will duplicate the matrix given a generic GeneralMatrix

Returns
a pointer to the newly created object

Implemented in BandMatrix, and SquareMatrix.

◆ zero()

virtual void zero ( )
pure virtual

Zero the matrix elements.

Implemented in BandMatrix, and SquareMatrix.

◆ mult()

virtual void mult ( const doublereal *  b,
doublereal *  prod 
) const
pure virtual

Multiply A*b and write result to prod.

Parameters
bVector to do the rh multiplication
prodOUTPUT vector to receive the result

Implemented in BandMatrix.

◆ leftMult()

virtual void leftMult ( const doublereal *const  b,
doublereal *const  prod 
) const
pure virtual

Multiply b*A and write result to prod.

Parameters
bVector to do the lh multiplication
prodOUTPUT vector to receive the result

Implemented in BandMatrix, and SquareMatrix.

◆ factor()

virtual int factor ( )
pure virtual

Factors the A matrix, overwriting A.

We flip m_factored boolean to indicate that the matrix is now A-1.

Implemented in BandMatrix, and SquareMatrix.

◆ factorQR()

virtual int factorQR ( )
inlinevirtual

Factors the A matrix using the QR algorithm, overwriting A.

we set m_factored to 2 to indicate the matrix is now QR factored

Returns
the info variable from LAPACK

Reimplemented in SquareMatrix.

Definition at line 71 of file GeneralMatrix.h.

◆ rcondQR()

virtual doublereal rcondQR ( )
inlinevirtual

Returns an estimate of the inverse of the condition number for the matrix.

The matrix must have been previously factored using the QR algorithm

Returns
the inverse of the condition number

Reimplemented in SquareMatrix.

Definition at line 81 of file GeneralMatrix.h.

◆ rcond()

virtual doublereal rcond ( doublereal  a1norm)
pure virtual

Returns an estimate of the inverse of the condition number for the matrix.

The matrix must have been previously factored using the LU algorithm

Parameters
a1normNorm of the matrix
Returns
the inverse of the condition number

Implemented in BandMatrix, and SquareMatrix.

◆ useFactorAlgorithm()

virtual void useFactorAlgorithm ( int  fAlgorithm)
inlinevirtual

Change the way the matrix is factored.

Parameters
fAlgorithminteger 0 LU factorization 1 QR factorization

Reimplemented in SquareMatrix.

Definition at line 100 of file GeneralMatrix.h.

◆ factorAlgorithm()

virtual int factorAlgorithm ( ) const
pure virtual

Return the factor algorithm used.

Implemented in BandMatrix, and SquareMatrix.

◆ oneNorm()

virtual doublereal oneNorm ( ) const
pure virtual

Calculate the one norm of the matrix.

Implemented in BandMatrix, and SquareMatrix.

◆ nRows()

virtual size_t nRows ( ) const
pure virtual

Return the number of rows in the matrix.

Implemented in BandMatrix, and SquareMatrix.

◆ nRowsAndStruct()

virtual size_t nRowsAndStruct ( size_t *const  iStruct = 0) const
pure virtual

Return the size and structure of the matrix.

Parameters
iStructOUTPUT Pointer to a vector of ints that describe the structure of the matrix.
Returns
the number of rows and columns in the matrix.
Deprecated:
Unused. To be removed after Cantera 2.3.

Implemented in BandMatrix, and SquareMatrix.

◆ clearFactorFlag()

virtual void clearFactorFlag ( )
inlinevirtual

clear the factored flag

Definition at line 123 of file GeneralMatrix.h.

References GeneralMatrix::m_factored.

◆ solve()

virtual int solve ( doublereal *  b,
size_t  nrhs = 1,
size_t  ldb = 0 
)
pure virtual

Solves the Ax = b system returning x in the b spot.

Parameters
bVector for the RHS of the equation system
nrhsNumber of right-hand sides to solve, default 1
ldbLeading dimension of the right-hand side array. Defaults to nRows()

Implemented in BandMatrix, and SquareMatrix.

◆ factored()

virtual bool factored ( ) const
inlinevirtual

true if the current factorization is up to date with the matrix

Definition at line 137 of file GeneralMatrix.h.

References GeneralMatrix::m_factored.

◆ ptrColumn()

virtual doublereal* ptrColumn ( size_t  j)
pure virtual

Return a pointer to the top of column j, columns are assumed to be contiguous in memory.

Parameters
jValue of the column
Returns
a pointer to the top of the column

Implemented in BandMatrix, and SquareMatrix.

◆ operator()() [1/2]

virtual doublereal& operator() ( size_t  i,
size_t  j 
)
pure virtual

Index into the (i,j) element.

Parameters
irow
jcolumn
Returns
a changeable reference to the matrix entry

Implemented in BandMatrix, and SquareMatrix.

◆ operator()() [2/2]

virtual doublereal operator() ( size_t  i,
size_t  j 
) const
pure virtual

Constant Index into the (i,j) element.

Parameters
irow
jcolumn
Returns
an unchangeable reference to the matrix entry

Implemented in SquareMatrix, and BandMatrix.

◆ begin() [1/2]

virtual vector_fp::iterator begin ( )
pure virtual

Return an iterator pointing to the first element.

We might drop this later

Implemented in BandMatrix, and SquareMatrix.

◆ begin() [2/2]

virtual vector_fp::const_iterator begin ( ) const
pure virtual

Return a const iterator pointing to the first element.

We might drop this later

Implemented in BandMatrix, and SquareMatrix.

◆ colPts()

virtual doublereal* const* colPts ( )
pure virtual

Return a vector of const pointers to the columns.

Note the value of the pointers are protected by their being const. However, the value of the matrix is open to being changed.

Returns
a vector of pointers to the top of the columns of the matrices.

Implemented in BandMatrix.

◆ checkRows()

virtual size_t checkRows ( doublereal &  valueSmall) const
pure virtual

Check to see if we have any zero rows in the Jacobian.

This utility routine checks to see if any rows are zero. The smallest row is returned along with the largest coefficient in that row

Parameters
valueSmallOUTPUT value of the largest coefficient in the smallest row
Returns
index of the row that is most nearly zero

Implemented in BandMatrix, and SquareMatrix.

◆ checkColumns()

virtual size_t checkColumns ( doublereal &  valueSmall) const
pure virtual

Check to see if we have any zero columns in the Jacobian.

This utility routine checks to see if any columns are zero. The smallest column is returned along with the largest coefficient in that column

Parameters
valueSmallOUTPUT value of the largest coefficient in the smallest column
Returns
index of the column that is most nearly zero

Implemented in BandMatrix, and SquareMatrix.

Member Data Documentation

◆ m_factored

int m_factored
protected

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