SpMatrix Class Template Reference
[Vector and Matrix]
#include <SpMatrix.h>

Detailed Description
template<class T_>
class OFELI::SpMatrix< T_ >
To handle matrices in sparse storage format.
This template class enables to store and manipulate a sparse matrix, i.e. only nonzero terms are stored. Internally, the matrix is stored as a vector instance and uses for the definition of its graph a Vect<unsigned long> instance row_ptr and a Vect<size_t> instance col_ind that contains respectively addresses of first element of each row and column indices.
To illustrate this, consider the matrix
1 2 0
3 4 0
0 5 0
Such a matrix is stored in the valarray<double> instance {1,2,3,4,5}. The vectors row_ptr and col_ind are respectively: {1,3,5,6}, {1,2,1,2,2}
Template Argument :
- T_ data type (double, float, ...)
Public Member Functions | |
| void | Add (size_t i, size_t j, const T_ &x) |
| Add a value x to an entry of the matrix. | |
| void | Assembly (const Side *sd, const DMatrix< T_ > &a) |
| Assembly of side matrix into global matrix. | |
| void | Assembly (const Side *sd, T_ *a) |
| Assembly of side matrix into global matrix. | |
| void | Assembly (const Element *el, const DMatrix< T_ > &a) |
| Assembly of element matrix into global matrix. | |
| void | Assembly (const Element *el, T_ *a) |
| Assembly of element matrix into global matrix. | |
| void | DiagPrescribe (const class Mesh &mesh, Vect< T_ > &b, const Vect< T_ > &u) |
| Impose by a diagonal method an essential boundary condition. | |
| virtual int | Factor ()=0 |
| Factorize matrix. Available only if the storage class enables it. | |
| int | FactorAndSolve (Vect< T_ > &b) |
| Factorize matrix and solve the linear system. | |
| T_ * | getArray () const |
| Return C-Array. | |
| size_t | getColInd (size_t i) const |
| Return storage information. | |
| Vect< T_ > | getColumn (size_t j) const |
| Get j-th column vector. | |
| T_ | getDiag (size_t k) const |
| Return k-th diagonal entry of A. | |
| T_ | getEntry (size_t i, size_t j) const |
| Return entry (i,j) of matrix if this one is stored, 0 else. | |
| unsigned long | getLength () const |
| Return number of stored terms in matrix. | |
| void | getMesh (const class Mesh &mesh) |
| Get Mesh. | |
| size_t | getNbColumns () const |
| Return number of columns. | |
| size_t | getNbRows () const |
| Return number of rows. | |
| void | getPrintView (size_t &rmin, size_t &rmax, size_t &cmin, size_t &cmax) const |
| Return window data for matrix printing. | |
| Vect< T_ > | getRow (size_t i) const |
| Get i-th row vector. | |
| size_t | getRowPtr (size_t i) const |
| Return Row pointer at position i. | |
| size_t | getSize () const |
| Return matrix dimension (Number of rows and columns). | |
| bool | isDiagonal () const |
| Say if matrix is diagonal or not. | |
| bool | isFactorized () const |
| Say if matrix is factorized or not. | |
| void | Mult (const Vect< T_ > &v, Vect< T_ > &w) const |
| Multiply matrix by vector v and save in w. | |
| void | MultAdd (T_ a, const Vect< T_ > &v, Vect< T_ > &w) const |
| Multiply matrix by vector a*v and add to w. | |
| void | MultAdd (const Vect< T_ > &v, Vect< T_ > &w) const |
| Multiply matrix by vector v and add to w. | |
| const T_ | operator() (size_t i) const |
| Operator () with one argument (Constant version). | |
| T_ | operator() (size_t i, size_t j) const |
| Operator () (Constant version). | |
| T_ & | operator() (size_t i, size_t j) |
| Operator () (Non constant version). | |
| Matrix & | operator*= (const T_ &x) |
| Operator *=. | |
| Matrix & | operator+= (const T_ &x) |
| Operator +=. | |
| Matrix & | operator+= (const Matrix< T_ > &m) |
| Operator +=. | |
| Matrix & | operator-= (const T_ &x) |
| Operator -=. | |
| Matrix & | operator-= (const Matrix< T_ > &m) |
| Operator -=. | |
| void | operator= (const T_ &x) |
| Operator =. | |
| T_ & | operator[] (size_t k) |
| Operator [] (Non constant version). | |
| const T_ | operator[] (size_t i) const |
| Operator [] (Constant version). | |
| void | Prescribe (size_t dof, const class Mesh &mesh, Vect< T_ > &b, const Vect< T_ > &u, int flag=0) |
| Impose by a penalty method an essential boundary condition when only one DOF is treated. | |
| void | Prescribe (const class Mesh &mesh, Vect< T_ > &b, int flag=0) |
| Impose by a penalty method a homegeneous (=0) essential boundary condition. | |
| void | Prescribe (const class Mesh &mesh, Vect< T_ > &b, const Vect< T_ > &u, int flag=0) |
| Impose by a penalty method an essential boundary condition. | |
| void | PrescribeSide (const class Mesh &mesh) |
| Impose by a penalty method an essential boundary condition when DOFs are supported by sides. | |
| void | Resize (size_t nr, size_t nc) |
| Set size (number of rows) of matrix. | |
| void | Resize (size_t size) |
| Set size of matrix (case where it's a square matrix). | |
| void | Set (size_t i, size_t j, const T_ &x) |
| Assign a value to an entry of the matrix. | |
| void | setDiag () |
| Store diagonal entries in a separate internal vector. | |
| void | setDiagonal (const class Mesh &mesh) |
| Initialize matrix storage in the case where only diagonal terms are stored. | |
| virtual void | setMesh (const class Mesh &mesh, size_t dof=0, size_t type=0) |
| Determine mesh graph and initialize matrix. | |
| void | setOneDOF () |
| Activate 1-DOF per node option. | |
| void | setPenal (double p) |
| Set Penalty Parameter (For boundary condition prescription). | |
| void | setPrintView (size_t rmin, size_t rmax, size_t cmin, size_t cmax) |
| set a window for matrix printing | |
| void | setSides () |
| Activate Sides option. | |
| void | setSolver (Iteration solver=CG_SOLVER, Preconditioner prec=DIAG_PREC, int max_it=1000, double toler=1.e-8) |
| Choose solver and preconditioner for an iterative procedure. | |
| int | Solve (const Vect< T_ > &b, Vect< T_ > &x) |
| Solve the linear system of equations. | |
| int | Solve (Vect< T_ > &b) |
| Solve the linear system of equations. | |
| SpMatrix (const SpMatrix &m) | |
| Copy constructor. | |
| SpMatrix (const Vect< unsigned long > &row_ptr, const Vect< size_t > &col_ind, const Vect< T_ > &a) | |
| Constructor for a rectangle matrix. | |
| SpMatrix (const Vect< unsigned long > &row_ptr, const Vect< size_t > &col_ind) | |
| Constructor for a rectangle matrix. | |
| SpMatrix (size_t nr, size_t nc, const Vect< unsigned long > &row_ptr, const Vect< size_t > &col_ind, const Vect< T_ > &a) | |
| Constructor for a rectangle matrix. | |
| SpMatrix (size_t nr, size_t nc, const Vect< unsigned long > &row_ptr, const Vect< size_t > &col_ind) | |
| Constructor for a rectangle matrix. | |
| SpMatrix (const Vect< size_t > &I, const Vect< size_t > &J, const Vect< T_ > &a, size_t nr=0, size_t nc=0, int opt=1) | |
| Constructor for a square matrix using non zero row and column indices. | |
| SpMatrix (const Vect< size_t > &I, const Vect< size_t > &J, size_t nr=0, size_t nc=0, int opt=1) | |
| Constructor for a square matrix using non zero row and column indices. | |
| SpMatrix (const class Mesh &mesh, size_t dof=0, int type=0) | |
| Constructor using a Mesh instance. | |
| SpMatrix (size_t size) | |
| Constructor that initializes current instance as a dense matrix. | |
| SpMatrix (size_t nb_rows, size_t nb_cols) | |
| Constructor that initializes current instance as a dense matrix. | |
| SpMatrix () | |
| Default constructor. | |
| void | TMult (const Vect< T_ > &v, Vect< T_ > &w) const |
| Multiply transpose of matrix by vector v and save in w. | |
| ~SpMatrix (void) | |
| Destructor. | |
Constructor & Destructor Documentation
| SpMatrix | ( | ) |
Default constructor.
Initializes a zero-dimension matrix
| SpMatrix | ( | size_t | nb_rows, | |
| size_t | nb_cols | |||
| ) |
Constructor that initializes current instance as a dense matrix.
Normally, for a dense matrix this is not the good class. Matrix entries are set to 0.
- Parameters:
-
nb_rows [in] Number of matrix rows. nb_cols [in] Number of matrix columns.
| SpMatrix | ( | size_t | size | ) |
Constructor that initializes current instance as a dense matrix.
Normally, for a dense matrix this is not the right class.
- Parameters:
-
size [in] Number of matrix rows (and columns). Matrix entries are set to 0.
Constructor using a Mesh instance.
- Parameters:
-
[in] mesh Mesh instance from which matrix graph is extracted. [in] dof Option parameter, with default value 0.
dof=1 means that only one degree of freedom for each node (or element or side) is taken to determine matrix structure. The value dof=0 means that matrix structure is determined using all DOFs.[in] type An exotic argument that indicates (if nonzero) that an extended graph of the matrix is to extracted : An extended graph is the one for which a node is linked not only to its neighbor nodes but also to the neighbors of the neighbors.
Matrix entries are set to 0.
References SpMatrix::setMesh().
| SpMatrix | ( | const Vect< size_t > & | I, | |
| const Vect< size_t > & | J, | |||
| size_t | nr = 0, |
|||
| size_t | nc = 0, |
|||
| int | opt = 1 | |||
| ) |
Constructor for a square matrix using non zero row and column indices.
- Parameters:
-
[in] I Vector containing row indices [in] J Vector containing column indices [in] nr Number of rows of the matrix to construct. By default, nr is set to the maximal value taken from vector I. [in] nc Number of columns of the matrix to construct. By default, nc is set to the maximal value taken from vector J. [in] opt Flag indicating if vectors I and J are cleaned and ordered (opt=1) or not (opt=0). In the latter case, these vectors can contain the same contents more than once and are not necessarily ordered
| SpMatrix | ( | const Vect< size_t > & | I, | |
| const Vect< size_t > & | J, | |||
| const Vect< T_ > & | a, | |||
| size_t | nr = 0, |
|||
| size_t | nc = 0, |
|||
| int | opt = 1 | |||
| ) |
Constructor for a square matrix using non zero row and column indices.
- Parameters:
-
[in] I Vector containing row indices [in] J Vector containing column indices [in] a Vector containing matrix entries in the same order than the one given by I and J [in] nr Number of rows of the matrix to construct. By default, nr is set to the maximal value taken from vector I. [in] nc Number of columns of the matrix to construct. By default, nc is set to the maximal value taken from vector J. [in] opt Flag indicating if vectors I and J are cleaned and ordered (opt=1) or not (opt=0). In the latter case, these vectors can contain the same contents more than once and are not necessarily ordered
| SpMatrix | ( | size_t | nr, | |
| size_t | nc, | |||
| const Vect< unsigned long > & | row_ptr, | |||
| const Vect< size_t > & | col_ind | |||
| ) |
Constructor for a rectangle matrix.
- Parameters:
-
[in] nr Number of rows [in] nc Number of columns [in] row_ptr Vector of row pointers (See the above description of this class). [in] col_ind Vector of column indices (See the above description of this class).
Matrix entries are set to 0.
| SpMatrix | ( | size_t | nr, | |
| size_t | nc, | |||
| const Vect< unsigned long > & | row_ptr, | |||
| const Vect< size_t > & | col_ind, | |||
| const Vect< T_ > & | a | |||
| ) |
Constructor for a rectangle matrix.
- Parameters:
-
[in] nr Number of rows [in] nc Number of columns [in] row_ptr Vector of row pointers (See the above description of this class). [in] col_ind Vector of column indices (See the above description of this class).
[in] a C-Array containing matrix entries stored columnwise
Constructor for a rectangle matrix.
Matrix entries are set to 0.
- Parameters:
-
[in] row_ptr Vector of row pointers (See the above description of this class). [in] col_ind Vector of column indices (See the above description of this class).
| SpMatrix | ( | const Vect< unsigned long > & | row_ptr, | |
| const Vect< size_t > & | col_ind, | |||
| const Vect< T_ > & | a | |||
| ) |
Constructor for a rectangle matrix.
- Parameters:
-
[in] row_ptr Vector of row pointers (See the above description of this class). [in] col_ind Vector of column indices (See the above description of this class). [in] a Vect instance that contain matrix entries stored row by row.
Number of rows is extracted from vector row_ptr.
Member Function Documentation
| void Add | ( | size_t | i, | |
| size_t | j, | |||
| const T_ & | x | |||
| ) | [virtual] |
Add a value x to an entry of the matrix.
- Parameters:
-
[in] i Row index [in] j Column index
[in] x Constant value to add to a(i,j)
Implements Matrix.
Referenced by OFELI::Assembly(), and OFELI::SideAssembly().
Assembly of side matrix into global matrix.
Case where side matrix is given by a DMatrix instance.
References Matrix::Add(), Node::getDOF(), Node::getNbDOF(), Side::getNbNodes(), and Side::getPtrNode().
| void Assembly | ( | const Side * | sd, | |
| T_ * | a | |||
| ) | [inherited] |
Assembly of side matrix into global matrix.
Case where side matrix is given by a C-array.
- Parameters:
-
[in] sd Pointer to side instance [in] a Side matrix as a C-array instance
References Matrix::Add(), Node::getDOF(), Node::getNbDOF(), Side::getNbNodes(), and Side::getPtrNode().
Assembly of element matrix into global matrix.
Case where element matrix is given by a DMatrix instance.
References Matrix::Add(), Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
| void Assembly | ( | const Element * | el, | |
| T_ * | a | |||
| ) | [inherited] |
Assembly of element matrix into global matrix.
Case where element matrix is given by a C-array.
- Parameters:
-
[in] el Pointer to element instance [in] a Element matrix as a C-array
References Matrix::Add(), Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
Impose by a diagonal method an essential boundary condition.
This member function modifies diagonal terms in matrix and terms in vector that correspond to degrees of freedom with nonzero code in order to impose a boundary condition. The penalty parameter is defined by default equal to 1.e20. It can be modified by member function setPenal(..).
- Parameters:
-
[in] mesh Mesh instance from which information is extracted. [in,out] b Vect instance that contains right-hand side. [in] u Vect instance that conatins imposed valued at DOFs where they are to be imposed.
References OFELI::Abs(), Node::getCode(), Node::getDOF(), SpMatrix::getEntry(), Node::getNbDOF(), Mesh::getNode(), and Mesh::topNode().
| int FactorAndSolve | ( | Vect< T_ > & | b | ) | [inherited] |
Factorize matrix and solve the linear system.
This is available only if the storage class enables it.
References Matrix::Factor(), and Matrix::Solve().
| T_ * getArray | ( | ) | const |
Return C-Array.
Non zero terms of matrix is stored row by row.
| size_t getColInd | ( | size_t | i | ) | const [virtual] |
Return storage information.
- Return values:
-
c Column index of the i-th stored element in matrix
Reimplemented from Matrix.
| T_ getDiag | ( | size_t | k | ) | const [inherited] |
Return k-th diagonal entry of A.
First entry is given by GetDiag(1).
| void getMesh | ( | const class Mesh & | mesh | ) |
Get Mesh.
Get mesh instance whose reference will be stored in current instance of SpMatrix.
References Mesh::getNbEq(), and Mesh::getNbNodes().
| void getPrintView | ( | size_t & | rmin, | |
| size_t & | rmax, | |||
| size_t & | cmin, | |||
| size_t & | cmax | |||
| ) | const [inherited] |
Return window data for matrix printing.
- Parameters:
-
[out] rmin first row index to view [out] rmax last row index to view [out] cmin first column index to view [out] cmax last column index to view
Referenced by OFELI::operator<<().
| bool isFactorized | ( | ) | const [inherited] |
Say if matrix is factorized or not.
If the matrix was not factorized, the class does not allow solving by a direct solver.
Multiply matrix by vector v and save in w.
- Parameters:
-
[in] v Vector to multiply by matrix [out] w Vector that contains on output the result.
Implements Matrix.
References OFELI::Clear(), Vect::getSize(), and SpMatrix::MultAdd().
Multiply matrix by vector a*v and add to w.
- Parameters:
-
[in] a Constant to multiply by matrix [in] v Vector to multiply by matrix [out] w Vector to add to the result. y contains on output the result.
Implements Matrix.
Multiply matrix by vector v and add to w.
- Parameters:
-
[in] v Vector to multiply by matrix [out] w Vector to add to the result. w contains on output the result.
Implements Matrix.
Referenced by SpMatrix::Mult().
| const T_ operator() | ( | size_t | i | ) | const [virtual] |
Operator () with one argument (Constant version).
Returns i-th position in the array storing matrix entries. The first entry is at location 1. Entries are stored row by row.
Implements Matrix.
| T_ operator() | ( | size_t | i, | |
| size_t | j | |||
| ) | const [virtual] |
| T_ & operator() | ( | size_t | i, | |
| size_t | j | |||
| ) | [virtual] |
Operator () (Non constant version).
- Parameters:
-
[in] i Row index [in] j Column index
Implements Matrix.
| Matrix< T_ > & operator*= | ( | const T_ & | x | ) | [inherited] |
Operator *=.
Premultiply matrix entries by constant value x.
Reimplemented in DMatrix, SkMatrix, SkSMatrix, TrMatrix, and DMatrix< double >.
| Matrix< T_ > & operator+= | ( | const T_ & | x | ) | [inherited] |
Operator +=.
Add constant value x to all matrix entries.
Reimplemented in DMatrix, SkMatrix, and DMatrix< double >.
Operator +=.
Add matrix m to current matrix instance.
| Matrix< T_ > & operator-= | ( | const T_ & | x | ) | [inherited] |
Operator -=.
Subtract constant value x from all matrix entries.
Reimplemented in DMatrix, and DMatrix< double >.
Operator -=.
Subtract matrix m from current matrix instance.
| void operator= | ( | const T_ & | x | ) |
| T_& operator[] | ( | size_t | k | ) | [inherited] |
Operator [] (Non constant version).
Returns k-th stored element in matrix Index k starts at 0.
| const T_ operator[] | ( | size_t | i | ) | const |
Operator [] (Constant version).
Returns i-th position in the array storing matrix entries. The first entry is at location 0. Entries are stored row by row.
Reimplemented from Matrix.
| void Prescribe | ( | size_t | dof, | |
| const class Mesh & | mesh, | |||
| Vect< T_ > & | b, | |||
| const Vect< T_ > & | u, | |||
| int | flag = 0 | |||
| ) | [inherited] |
Impose by a penalty method an essential boundary condition when only one DOF is treated.
This member function modifies diagonal terms in matrix and terms in vector that correspond to degrees of freedom with nonzero code in order to impose a boundary condition. This gunction is to be used if only one DOF per node is treated in the linear system. The penalty parameter is by default equal to 1.e20. It can be modified by member function setPenal.
- Parameters:
-
[in] dof Label of the concerned degree of freedom (DOF). [in] mesh Mesh instance from which information is extracted. [in,out] b Vect instance that contains right-hand side. [in] u Vect instance that conatins imposed valued at DOFs where they are to be imposed. [in] flag Parameter to determine whether only the right-hand side is to be modified (dof>0) or both matrix and right-hand side (dof=0, default value).
References Node::getCode(), Matrix::getEntry(), Node::getLabel(), Mesh::getNode(), Matrix::Set(), and Mesh::topNode().
Impose by a penalty method a homegeneous (=0) essential boundary condition.
This member function modifies diagonal terms in matrix and terms in vector that correspond to degrees of freedom with nonzero code in order to impose a boundary condition. The penalty parameter is defined by default equal to 1.e20. It can be modified by member function setPenal(..).
- Parameters:
-
[in] mesh Mesh instance from which information is extracted. [in,out] b Vect instance that contains right-hand side. [in] flag Parameter to determine whether only the right-hand side is to be modified (dof>0) or both matrix and right-hand side (dof=0, default value).
References Node::getCode(), Node::getDOF(), Matrix::getEntry(), Node::getNbDOF(), Mesh::getNode(), Matrix::Set(), and Mesh::topNode().
| void Prescribe | ( | const class Mesh & | mesh, | |
| Vect< T_ > & | b, | |||
| const Vect< T_ > & | u, | |||
| int | flag = 0 | |||
| ) | [inherited] |
Impose by a penalty method an essential boundary condition.
This member function modifies diagonal terms in matrix and terms in vector that correspond to degrees of freedom with nonzero code in order to impose a boundary condition. The penalty parameter is defined by default equal to 1.e20. It can be modified by member function setPenal(..).
- Parameters:
-
[in] mesh Mesh instance from which information is extracted. [in,out] b Vect instance that contains right-hand side. [in] u Vect instance that conatins imposed valued at DOFs where they are to be imposed. [in] flag Parameter to determine whether only the right-hand side is to be modified (dof>0) or both matrix and right-hand side (dof=0, default value).
References Node::getCode(), Node::getDOF(), Matrix::getEntry(), Node::getNbDOF(), Mesh::getNode(), Matrix::Set(), and Mesh::topNode().
| void PrescribeSide | ( | const class Mesh & | mesh | ) | [inherited] |
Impose by a penalty method an essential boundary condition when DOFs are supported by sides.
This member function modifies diagonal terms in matrix and terms in vector that correspond to degrees of freedom with nonzero code in order to impose a boundary condition. The penalty parameter is defined by default equal to 1.e20. It can be modified by member function setPenal(..).
- Parameters:
-
[in] mesh Mesh instance from which information is extracted.
References Side::getCode(), Side::getDOF(), Matrix::getEntry(), Side::getNbDOF(), Mesh::getSide(), Matrix::Set(), and Mesh::topSide().
| void Resize | ( | size_t | nr, | |
| size_t | nc | |||
| ) |
Set size (number of rows) of matrix.
- Parameters:
-
[in] nr Number of rows. [in] nc Number of columns.
| void Resize | ( | size_t | size | ) |
Set size of matrix (case where it's a square matrix).
- Parameters:
-
[in] size Number of rows and columns.
| void Set | ( | size_t | i, | |
| size_t | j, | |||
| const T_ & | x | |||
| ) | [virtual] |
Assign a value to an entry of the matrix.
- Parameters:
-
[in] i Row index [in] j Column index [in] x Value to assign to a(i,j)
Implements Matrix.
| void setDiagonal | ( | const class Mesh & | mesh | ) | [inherited] |
Initialize matrix storage in the case where only diagonal terms are stored.
This member function is to be used for explicit time integration schemes
References OFELI::Clear(), and Mesh::getNbEq().
| void setMesh | ( | const class Mesh & | mesh, | |
| size_t | dof = 0, |
|||
| size_t | type = 0 | |||
| ) | [virtual] |
Determine mesh graph and initialize matrix.
This member function is called by constructor with the same arguments
- Parameters:
-
[in] mesh Mesh instance for which matrix graph is determined. [in] dof Option parameter, with default value 0.
dof=1 means that only one degree of freedom for each node (or element or side) is taken to determine matrix structure. The value dof=0 means that matrix structure is determined using all DOFs.[in] type An exotic argument that indicates (if nonzero) that an extended graph of the matrix is to extracted: An extended graph is the one for which a node is linked not only to its neighbor nodes but also to the neighbors of the neighbors.
Matrix entries are set to 0.
Referenced by SpMatrix::SpMatrix().
| void setPrintView | ( | size_t | rmin, | |
| size_t | rmax, | |||
| size_t | cmin, | |||
| size_t | cmax | |||
| ) | [inherited] |
set a window for matrix printing
- Parameters:
-
[in] rmin first row index to view [in] rmax last row index to view [in] cmin first column index to view [in] cmax last column index to view
Reimplemented in DMatrix, DSMatrix, and DMatrix< double >.
| void setSolver | ( | Iteration | solver = CG_SOLVER, |
|
| Preconditioner | prec = DIAG_PREC, |
|||
| int | max_it = 1000, |
|||
| double | toler = 1.e-8 | |||
| ) |
Choose solver and preconditioner for an iterative procedure.
- Parameters:
-
[in] solver Option to choose iterative solver in an enumerated variable - CG_SOLVER : Conjugate Gradient [default]
- CGS_SOLVER : Squared conjugate gradient
- BICG_SOLVER : Biconjugate gradient
- BICG_STAB_SOLVER : Biconjugate gradient stabilized
- GMRES_SOLVER : Generalized Minimal Residual
- QMR_SOLVER : Quasi-Minimal Residual
CG_SOLVER[in] prec Option to choose preconditioner in an enumerated variable - IDENT_PREC : Identity preconditioner (no preconditioning)
- DIAG_PREC : Diagonal preconditioner [default]
- ILU_PREC : ILU (Incomplete factorization) preconditioner
DIAG_PREC[in] max_it Maximum number of allowed iterations. Default value is 1000.[in] toler Tolerance for convergence. Default value is 1.e-8
Solve the linear system of equations.
The default parameters are:
- CG_SOLVER for solver
- DIAG_PREC for preconditioner
- Max. Nb. of iterations is 1000
- Tolerance is 1.e-8
- Parameters:
-
[in] b Vector that contains right-hand side [out] x Vector that contains the obtained solution
- Return values:
-
nb_it Number of actual performed iterations
Reimplemented from Matrix.
References OFELI::BiCG(), OFELI::BiCGStab(), OFELI::CG(), OFELI::CGS(), OFELI::GMRes(), and OFELI::QMR().
| int Solve | ( | Vect< T_ > & | b | ) | [virtual] |
Solve the linear system of equations.
The default parameters are:
- CG_SOLVER for solver
- DIAG_PREC for preconditioner
- Max. Nb. of iterations is 1000
- Tolerance is 1.e-8
- Parameters:
-
[in,out] b Vector that contains right-hand side on input and solution on output
- Return values:
-
nb_it Number of actual performed iterations
Implements Matrix.
References Vect::getSize().
Multiply transpose of matrix by vector v and save in w.
- Parameters:
-
[in] v Vector to multiply by matrix [out] w Vector that contains on output the result.
Implements Matrix.