Cantera  2.0
Public Member Functions | Public 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)
 Base Constructor.
 
 GeneralMatrix (const GeneralMatrix &right)
 Copy Constructor.
 
GeneralMatrixoperator= (const GeneralMatrix &right)
 Assignment operator.
 
virtual ~GeneralMatrix ()
 Destructor. Does nothing.
 
virtual GeneralMatrixduplMyselfAsGeneralMatrix () const =0
 Duplicator member function.
 
virtual void zero ()=0
 Zero the matrix elements.
 
virtual void mult (const doublereal *b, doublereal *prod) const =0
 Multiply A*b and write result to prod.
 
virtual void leftMult (const doublereal *const b, doublereal *const prod) const =0
 Multiply b*A and write result to prod.
 
virtual int factor ()=0
 Factors the A matrix, overwriting A.
 
virtual int factorQR ()=0
 Factors the A matrix using the QR algorithm, overwriting A.
 
virtual doublereal rcondQR ()=0
 Returns an estimate of the inverse of the condition number for the matrix.
 
virtual doublereal rcond (doublereal a1norm)=0
 Returns an estimate of the inverse of the condition number for the matrix.
 
virtual void useFactorAlgorithm (int fAlgorithm)=0
 Change the way the matrix is factored.
 
virtual int factorAlgorithm () const =0
 Return the factor algorithm used.
 
virtual doublereal oneNorm () const =0
 Calculate the one norm of the matrix.
 
virtual size_t nRows () const =0
 Return the number of rows in the matrix.
 
virtual size_t nRowsAndStruct (size_t *const iStruct=0) const =0
 Return the size and structure of the matrix.
 
virtual void clearFactorFlag ()=0
 clear the factored flag
 
virtual int solve (doublereal *b)=0
 Solves the Ax = b system returning x in the b spot.
 
virtual bool factored () const =0
 true if the current factorization is up to date with the matrix
 
virtual doublereal * ptrColumn (size_t j)=0
 Return a pointer to the top of column j, columns are assumed to be contiguous in memory.
 
virtual doublereal & operator() (size_t i, size_t j)=0
 Index into the (i,j) element.
 
virtual doublereal operator() (size_t i, size_t j) const =0
 Constant Index into the (i,j) element.
 
virtual void copyData (const GeneralMatrix &y)=0
 Copy the data from one array into another without doing any checking.
 
virtual vector_fp::iterator begin ()=0
 Return an iterator pointing to the first element.
 
virtual vector_fp::const_iterator begin () const =0
 Return a const iterator pointing to the first element.
 
virtual doublereal *const * colPts ()=0
 Return a vector of const pointers to the columns.
 
virtual size_t checkRows (doublereal &valueSmall) const =0
 Check to see if we have any zero rows in the jacobian.
 
virtual size_t checkColumns (doublereal &valueSmall) const =0
 Check to see if we have any zero columns in the jacobian.
 

Public Attributes

int matrixType_
 Matrix type.
 

Detailed Description

Generic matrix.

Definition at line 23 of file GeneralMatrix.h.

Constructor & Destructor Documentation

GeneralMatrix ( int  matType)

Base Constructor.

Parameters
matTypeMatrix type 0 full 1 banded

Definition at line 18 of file GeneralMatrix.cpp.

GeneralMatrix ( const GeneralMatrix right)

Copy Constructor.

Parameters
rightObject to be copied

Definition at line 23 of file GeneralMatrix.cpp.

~GeneralMatrix ( )
virtual

Destructor. Does nothing.

Definition at line 37 of file GeneralMatrix.cpp.

Member Function Documentation

GeneralMatrix & operator= ( const GeneralMatrix right)

Assignment operator.

Parameters
rightObject to be copied

Definition at line 28 of file GeneralMatrix.cpp.

References GeneralMatrix::matrixType_.

Referenced by SquareMatrix::operator=(), and BandMatrix::operator=().

virtual GeneralMatrix* duplMyselfAsGeneralMatrix ( ) const
pure virtual

Duplicator member function.

This function will duplicate the matrix given a generic GeneralMatrix pointer

Returns
Returns a pointer to the malloced object

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve(), and NonlinearSolver::solve_nonlinear_problem().

virtual void zero ( )
pure virtual

Zero the matrix elements.

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

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, and SquareMatrix.

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.

virtual int factor ( )
pure virtual

Factors the A matrix, overwriting A.

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual int factorQR ( )
pure virtual

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
Returns the info variable from lapack

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual doublereal rcondQR ( )
pure virtual

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
returns the inverse of the condition number

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

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
returns the inverse of the condition number

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual void useFactorAlgorithm ( int  fAlgorithm)
pure virtual

Change the way the matrix is factored.

Parameters
fAlgorithminteger 0 LU factorization 1 QR factorization

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual int factorAlgorithm ( ) const
pure virtual

Return the factor algorithm used.

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual doublereal oneNorm ( ) const
pure virtual

Calculate the one norm of the matrix.

Returns the one norm of the matrix

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve().

virtual size_t nRows ( ) const
pure virtual

Return the number of rows in the matrix.

Implemented in SquareMatrix, and BandMatrix.

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

Return the size and structure of the matrix.

This is inherited from GeneralMatrix

Parameters
iStructOUTPUT Pointer to a vector of ints that describe the structure of the matrix.
Returns
returns the number of rows and columns in the matrix.

Implemented in SquareMatrix, and BandMatrix.

Referenced by NonlinearSolver::beuler_jac(), and NonlinearSolver::scaleMatrix().

virtual void clearFactorFlag ( )
pure virtual

clear the factored flag

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::beuler_jac().

virtual int solve ( doublereal *  b)
pure virtual

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

Parameters
bVector for the rhs of the equation system

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::doAffineNewtonSolve(), BEulerInt::doNewtonSolve(), and NonlinearSolver::doNewtonSolve().

virtual bool factored ( ) const
pure virtual

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

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::calcSolnToResNormVector(), NonlinearSolver::doAffineNewtonSolve(), BEulerInt::doNewtonSolve(), and NonlinearSolver::scaleMatrix().

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
Returns a pointer to the top of the column

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::beuler_jac(), BandMatrix::copyData(), and NonlinearSolver::scaleMatrix().

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 SquareMatrix, and BandMatrix.

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.

virtual void copyData ( const GeneralMatrix y)
pure virtual

Copy the data from one array into another without doing any checking.

This differs from the assignment operator as no resizing is done and memcpy() is used.

Parameters
yArray to be copied

Implemented in BandMatrix, and SquareMatrix.

Referenced by NonlinearSolver::beuler_jac().

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.

Referenced by NonlinearSolver::doAffineNewtonSolve(), BEulerInt::doNewtonSolve(), and NonlinearSolver::scaleMatrix().

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.

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
returns a vector of pointers to the top of the columns of the matrices.

Implemented in BandMatrix, and SquareMatrix.

Referenced by ResidJacEval::evalJacobian().

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.

Referenced by NonlinearSolver::beuler_jac().

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.

Referenced by NonlinearSolver::beuler_jac().

Member Data Documentation

int matrixType_

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