Diffpack Documentation


Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

LinEqMatrix Class Reference

coefficient matrix in a system of linear equations. More...

#include <LinEqMatrix.h>

Inheritance diagram for LinEqMatrix::

HandleId List of all members.

Public Methods

 LinEqMatrix ()
 LinEqMatrix (int nblockrows, int nblockcolumns)
 LinEqMatrix (const LinEqMatrix &M)
 LinEqMatrix (Matrix(NUMT) &mat)
 ~LinEqMatrix ()
void size (int &nblockrows, int &nblockcolumns) const
int getNoRows () const
int getNoColumns () const
bool redim (int nblockrows=1, int nblockcolumns=1)
bool redim (const LinEqMatrix_prm &matprm)
bool redim (const LinEqMatrix &M)
void optimizeDataStructure ()
int getWork (const MatrixWork work_tp=MATVEC_WORK) const
real getStorage () const
bool ok () const
bool single () const
TransposeMode transposeMode (int i=1, int j=1) const
Matrix(NUMT)& mat (int i=1, int j=1)
const Matrix(NUMT)& mat (int i=1, int j=1) const
void attach (const Matrix(NUMT) &mat, int i=1, int j=1, TransposeMode tpmode=NOT_TRANSPOSED)
LinEqMatrix& operator= (const LinEqMatrix &M)
LinEqMatrix& operator= (NUMT a)
void assemble (const Mat(NUMT) &em, const VecSimple(int) &idx_row_trans, const VecSimple(int) &idx_col_trans, int elm_no, int i=1, int j=1)
void assemble (const Mat(NUMT) &em, const VecSimple(int) &idx_trans, int elm_no, int i=1, int j=1)
bool blockCompatible (const LinEqVector &x, const LinEqVector &b, TransposeMode tpmode=NOT_TRANSPOSED) const
void prod (const LinEqVector &x, LinEqVector &y, TransposeMode tpmode=NOT_TRANSPOSED, bool add_to_yb=false) const
void resetFact ()
bool factorize (const FactStrategy &fstrategy)
void forwBack (LinEqVector &b, LinEqVector &x)
void SSOR1it (LinEqVector &xnew, const LinEqVector &xold, const LinEqVector &b, real omega, TransposeMode tpmode=NOT_TRANSPOSED) const
void SSORsolve (LinEqVector &y, const LinEqVector &c, real omega, TransposeMode tpmode=NOT_TRANSPOSED) const
void SOR1it (LinEqVector &xnew, const LinEqVector &xold, const LinEqVector &b, real omega, TransposeMode tpmode=NOT_TRANSPOSED) const
void SORsolve (LinEqVector &y, const LinEqVector &c, real omega, TransposeMode tpmode=NOT_TRANSPOSED) const
void Jacobi1it (LinEqVector &xnew, const LinEqVector &xold, const LinEqVector &b, TransposeMode tpmode=NOT_TRANSPOSED) const
void Jacobisolve (LinEqVector &y, const LinEqVector &c, TransposeMode tpmode=NOT_TRANSPOSED) const
const MatDense(NUMT)& getMatDense (int i=1, int j=1) const
MatDense(NUMT)& getMatDense (int i=1, int j=1)
const MatBand(NUMT)& getMatBand (int i=1, int j=1) const
MatBand(NUMT)& getMatBand (int i=1, int j=1)
const MatDiag(NUMT)& getMatDiag (int i=1, int j=1) const
MatDiag(NUMT)& getMatDiag (int i=1, int j=1)
const MatTri(NUMT)& getMatTri (int i=1, int j=1) const
MatTri(NUMT)& getMatTri (int i=1, int j=1)
const MatStructSparse(NUMT)& getMatStructSparse (int i=1, int j=1) const
MatStructSparse(NUMT)& getMatStructSparse (int i=1, int j=1)
const MatSparse(NUMT)& getMatSparse (int i=1, int j=1) const
MatSparse(NUMT)& getMatSparse (int i=1, int j=1)
void debugPrint (Os os, const char *header) const

Friends

Osoperator<< (Os &os, const LinEqMatrix &m)

Detailed Description

coefficient matrix in a system of linear equations.

NAME: LinEqMatrix - coefficient matrix in a system of linear equations

DESCRIPTION:

The class implements a (block) matrix and constitutes the basic matrix class to be used by (iterative) equation solvers in the "LinEqSolver" hierarchy. Most operations are simplified if there is only one block present.

The class allocates a matrix of "HandleT(Matrix(NUMT)" instances, where each matrix represents a block.

Sometimes it is desired to trace the life of big matrix and vector objects. The class "LinEqMatrix" and "LinEqVector" have functionality for this. If the user gives the command line argument "+traceLinEqMb 4.2", all matrices and vectors that are larger than 4.2 Mb (storage as determined by "Matrix getStorage") will be traced. More precisely, the "HandleId traceMe" function in the matrix or vector will be called every time a matrix is created or redimensioned, with an argument (name for "traceMe") that reflects the current size of the matrix. This feature is only active if the preprocessor variable "SAFETY_CHECKS" is defined (that is the case if the program is compiled with "MODE=nopt"). Using the trace functionality, one can follow the life of large matrix and vector objects, managed by "LinEqMatrix" or "LinEqVector" instances, to get more insight into the memory requirements of an application.


Constructor & Destructor Documentation

LinEqMatrix::LinEqMatrix ( ) [inline]
 

There are four constructors. One is empty and allocates no internal data structure. Further initialization is then required: either a call to the "redim" function with two "int"s (the numbers of blocks) as arguments and then calls to "attach", or a call to "redim(LinEqMatrix_prm)". In the latter case, the "redim" function allocates memory for all the matrices according to the sizes given in the parameter object of class "LinEqMatrix_prm". Another alternative is to call "redim(LinEqMatrix)", where the allocation is based on an already existing "LinEqMatrix" structure. Note that the "redim" function that takes two "int"s as arguments allocates an internal matrix of handles. These handles are empty and must be rebound to objects of type "Matrix(NUMT)" by calling the "attach" function. The other "redim" functions allocate both the matrix of handles and "Matrix(NUMT)" objects that are rebound to the handles. To ensure correct behaviour of a "LinEqMatrix" object no handles are allowed to be empty.

In addition to the default constructor, there are other constructors accepting the number of blocks, a preallocated "LinEqmatrix" object or a "Matrix(NUMT)" object. In the first of these cases, attachment or some redimensioning of each block is required. The third option implies that the "LinEqMatrix" object consists of a single block.

Deallocation of everything that is allocated in "LinEqMatrix" objects will automatically take place when the "LinEqMatrix" object goes out of scope since then all handles will be deleted and the handles will delete the "Matrix(NUMT)" objects if there are no other handle to these objects. Further initialization of the class is not necessary, except that the matrices must be filled by proper "NUMT" values.

LinEqMatrix::LinEqMatrix ( int nblockrows,
int nblockcolumns )
 

LinEqMatrix::LinEqMatrix ( const LinEqMatrix & M )
 

See documentation of one of the overloaded constructor.

LinEqMatrix::LinEqMatrix ( Matrix(NUMT) & mat )
 

See documentation of one of the overloaded constructor.

LinEqMatrix::~LinEqMatrix ( )
 


Member Function Documentation

void LinEqMatrix::Jacobi1it ( LinEqVector & xnew,
const LinEqVector & xold,
const LinEqVector & b,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

as "SSOR1it", but is related to the Jacobi iteration.

void LinEqMatrix::Jacobisolve ( LinEqVector & y,
const LinEqVector & c,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

as "SSOR1solve", but is related to the Jacobi (diagonal) splitting.

void LinEqMatrix::SOR1it ( LinEqVector & xnew,
const LinEqVector & xold,
const LinEqVector & b,
real omega,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

as "SSOR1it", but is related to the SOR iteration.

void LinEqMatrix::SORsolve ( LinEqVector & y,
const LinEqVector & c,
real omega,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

as "SSOR1solve", but is related to the SOR splitting.

void LinEqMatrix::SSOR1it ( LinEqVector & xnew,
const LinEqVector & xold,
const LinEqVector & b,
real omega,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

performs one single iteration of SSOR on the system "Ax=b" where "A" refers to the current matrix object (and on "tpmode"). The parameters "xnew" and "xold" denote the previous and next iterates, respectively.

void LinEqMatrix::SSORsolve ( LinEqVector & y,
const LinEqVector & c,
real omega,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

solves the system "My=c", where "M" denotes the SSOR splitting matrix based on the current matrix object (and on "tpmode").

void LinEqMatrix::assemble ( const Mat(NUMT) & em,
const VecSimple(int) & idx_trans,
int elm_no,
int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

void LinEqMatrix::assemble ( const Mat(NUMT) & em,
const VecSimple(int) & idx_row_trans,
const VecSimple(int) & idx_col_trans,
int elm_no,
int i = 1,
int j = 1 )
 

adds a small matrix to a large, global matrix. The elements are assembled according to index transformation vectors. The routine is useful when programming finite element methods. See class "Mat" or "Matrix" for more details (the present function is just a simple call to the similar functions in the matrix classes).

void LinEqMatrix::attach ( const Matrix(NUMT) & mat,
int i = 1,
int j = 1,
TransposeMode tpmode = NOT_TRANSPOSED )
 

attach a "Matrix(NUMT)" handle as block.

bool LinEqMatrix::blockCompatible ( const LinEqVector & x,
const LinEqVector & b,
TransposeMode tpmode = NOT_TRANSPOSED ) const
 

compares the block size of its arguments "x" and "b" with the current matrix "A" to see that "Ax=b"` is possible with respect to blocking. If "tpmode" signifies the use of the transposed matrix or the conjugate transposed matrix, this check corresponds to "A^Tx=b" or "A^Hx=b"`, respectively.

void LinEqMatrix::debugPrint ( Os os,
const char * header ) const
 

prints the contents of a "LinEqMatrix" object block for block. Alternatively, printing can be done by calls like "v.mat(i,j).print(os)".

bool LinEqMatrix::factorize ( const FactStrategy & fstrategy )
 

computes a factorization of the matrix determined by the current "FactStrategy" parameter. The factorization overwrites the matrix entries. In case of pivoting, extra storage will be allocated and managed internally. The function returns a false value if the factorization failed. By its nature, due to the propagation of fill-in entries, matrix factorization is available only for single block storage.

void LinEqMatrix::forwBack ( LinEqVector & b,
LinEqVector & x )
 

a general interface to forward and backward substitution routines. Depending on the previously selected factorization type, the appropriate action is taken.

MatBand(NUMT) & LinEqMatrix::getMatBand ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatBand(NUMT) & LinEqMatrix::getMatBand ( int i = 1,
int j = 1 ) const
 

get a reference to a "MatBand" matrix (for a specified block, default block is (1,1)), the function involves casting of a "Matrix(NUMT)" pointer to a "MatBand(NUMT)" pointer. Note that use of the "getMat*" functions requires the programmer to know the matrix type at compile-time.

Do not use this routine to index a matrix, declare your own reference and use this routine to initialize that reference.

MatDense(NUMT) & LinEqMatrix::getMatDense ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatDense(NUMT) & LinEqMatrix::getMatDense ( int i = 1,
int j = 1 ) const
 

as "getMatBand", but a "MatDense" reference is returned.

MatDiag(NUMT) & LinEqMatrix::getMatDiag ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatDiag(NUMT) & LinEqMatrix::getMatDiag ( int i = 1,
int j = 1 ) const
 

as "getMatBand", but a "MatDiag" reference is returned.

MatSparse(NUMT) & LinEqMatrix::getMatSparse ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatSparse(NUMT) & LinEqMatrix::getMatSparse ( int i = 1,
int j = 1 ) const
 

as "getMatBand", but a "MatSparse" reference is returned.

MatStructSparse(NUMT) & LinEqMatrix::getMatStructSparse ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatStructSparse(NUMT) & LinEqMatrix::getMatStructSparse ( int i = 1,
int j = 1 ) const
 

as "getMatBand", but a "MatStructSparse" reference is returned.

MatTri(NUMT) & LinEqMatrix::getMatTri ( int i = 1,
int j = 1 )
 

See documentation of one of the overloaded functions.

const MatTri(NUMT) & LinEqMatrix::getMatTri ( int i = 1,
int j = 1 ) const
 

as "getMatBand", but a "MatTri" reference is returned.

int LinEqMatrix::getNoColumns ( ) const
 

returns the total number of columns (added up over all blocks).

int LinEqMatrix::getNoRows ( ) const
 

returns the total number of rows (added up over all blocks).

real LinEqMatrix::getStorage ( ) const
 

returns the total storage cost (added up over all blocks).

int LinEqMatrix::getWork ( const MatrixWork work_tp = MATVEC_WORK ) const
 

returns the total cost if the last issued matrix operation (added up over all blocks).

const Matrix(NUMT) & LinEqMatrix::mat ( int i = 1,
int j = 1 ) const [inline]
 

See documentation of one of the overloaded functions.

Matrix(NUMT) & LinEqMatrix::mat ( int i = 1,
int j = 1 ) [inline]
 

subscripting, returns a "Matrix(NUMT)" reference to a block. There are two such functions, one for read and one for write operations.

bool LinEqMatrix::ok ( ) const
 

returns "true" if the object is in an ok state. The value "false" is returned only if there are empty handles.

LinEqMatrix & LinEqMatrix::operator= ( NUMT a )
 

See documentation of one of the overloaded functions.

LinEqMatrix & LinEqMatrix::operator= ( const LinEqMatrix & M )
 

redimensions and initializes this "LinEqMatrix" object based on another existing "LinEqMatrix".

void LinEqMatrix::optimizeDataStructure ( )
 

calls "optimizeDataStructure" for each sub-block, resulting in tuning of the internal representations of the matrix blocks, e.g.\ by reducing the storage of zero entries in a sparse matrix pattern.

void LinEqMatrix::prod ( const LinEqVector & x,
LinEqVector & y,
TransposeMode tpmode = NOT_TRANSPOSED,
bool add_to_yb = false ) const
 

calculates the product of two matrices or a matrix and a vector, depending on the arguments of the function. The return type is void. Hence the result is available as one of the arguments to "prod". This gives the user of the function total control of the memory allocation associated with the result array. An "enum" "TransposeMode" can be given as argument in order to indicate whether the matrix itself, its transposed, or its conjugate transposed should be used in the product. A "bool" can be used to indicate, that the product should be added instead of overwritten.

bool LinEqMatrix::redim ( const LinEqMatrix & M )
 

See documentation of one of the overloaded functions.

bool LinEqMatrix::redim ( const LinEqMatrix_prm & matprm )
 

See documentation of one of the overloaded functions.

bool LinEqMatrix::redim ( int nblockrows = 1,
int nblockcolumns = 1 )
 

redimension the block matrix. If given a "LinEqMatrix_prm" or "LinEqmatrix" object, each block is also redimensioned according to indicated block sizes and formats.

void LinEqMatrix::resetFact ( )
 

flags the matrix as not factorized. This function must be called if the same matrix object is reused for new data after a factorization, otherwise it is impossible to factorize the new matrix.

bool LinEqMatrix::single ( ) const
 

returns "true" if there is only a single block.

void LinEqMatrix::size ( int & nblockrows,
int & nblockcolumns ) const [inline]
 

returns the number of blocks.

TransposeMode LinEqMatrix::transposeMode ( int i = 1,
int j = 1 ) const [inline]
 

returns a "TransposeMode" value indicating whether the specified block is to be treated as it is, as transposed or conjugate transposed.


Friends And Related Function Documentation

Os & operator<< ( Os & os,
const LinEqMatrix & m ) [friend]
 

see "debugPrint".


The documentation for this class was generated from the following file:
Copyright © 2003 inuTech GmbH. All rights reserved.