TrMatrix< T_ > Class Template Reference

To handle tridiagonal matrices. More...

#include <TrMatrix.h>

Inheritance diagram for TrMatrix< T_ >:
Matrix< T_ >

Public Member Functions

 TrMatrix ()
 Default constructor.
 
 TrMatrix (size_t size)
 Constructor for a tridiagonal matrix with size rows.
 
 TrMatrix (const TrMatrix &m)
 Copy Constructor.
 
 ~TrMatrix ()
 Destructor.
 
void Identity ()
 Define matrix as identity matrix.
 
void Diagonal ()
 Define matrix as a diagonal one.
 
void Diagonal (const T_ &a)
 Define matrix as a diagona one and assign value a to all diagonal entries.
 
void Laplace1D (real_t h)
 Define matrix as the one of 3-point finite difference discretization of the second derivative.
 
void setSize (size_t size)
 Set size (number of rows) of matrix.
 
void MultAdd (const Vect< T_ > &x, Vect< T_ > &y) const
 Multiply matrix by vector x and add result to y.
 
void MultAdd (T_ a, const Vect< T_ > &x, Vect< T_ > &y) const
 Multiply matrix by vector a*x and add result to y.
 
void Mult (const Vect< T_ > &x, Vect< T_ > &y) const
 Multiply matrix by vector x and save result in y.
 
void TMult (const Vect< T_ > &x, Vect< T_ > &y) const
 Multiply transpose of matrix by vector x and save result in y.
 
void Axpy (T_ a, const TrMatrix< T_ > &m)
 Add to matrix the product of a matrix by a scalar.
 
void Axpy (T_ a, const Matrix< T_ > *m)
 Add to matrix the product of a matrix by a scalar.
 
void set (size_t i, size_t j, const T_ &val)
 Assign constant val to an entry (i,j) of the matrix.
 
void add (size_t i, size_t j, const T_ &val)
 Add constant val value to an entry (i,j) of the matrix.
 
void add (size_t i, const T_ &val)
 Add val to entry i.
 
T_ at (size_t i, size_t j)
 Return a value of a matrix entry.
 
T_ operator() (size_t i, size_t j) const
 Operator () (Constant version).
 
T_ & operator() (size_t i, size_t j)
 Operator () (Non constant version).
 
TrMatrix< T_ > & operator= (const TrMatrix< T_ > &m)
 Operator =.
 
TrMatrix< T_ > & operator= (const T_ &x)
 Operator = Assign matrix to identity times x.
 
TrMatrix< T_ > & operator*= (const T_ &x)
 Operator *=.
 
int solve (Vect< T_ > &b, bool fact=true)
 Solve a linear system with current matrix (forward and back substitution).
 
int solve (const Vect< T_ > &b, Vect< T_ > &x, bool fact=false)
 Solve a linear system with current matrix (forward and back substitution).
 
T_ * get () const
 Return C-Array.
 
T_ get (size_t i, size_t j) const
 Return entry (i,j) of matrix.
 
- Public Member Functions inherited from Matrix< T_ >
 Matrix ()
 Default constructor.
 
 Matrix (const Matrix< T_ > &m)
 Copy Constructor.
 
virtual ~Matrix ()
 Destructor.
 
virtual void reset ()
 Set matrix to 0 and reset factorization parameter.
 
size_t getNbRows () const
 Return number of rows.
 
size_t getNbColumns () const
 Return number of columns.
 
string getName () const
 Return name of matrix.
 
MatrixSize getMatrixSize () const
 Return storage type.
 
void setPenal (real_t p)
 Set Penalty Parameter (For boundary condition prescription).
 
void setDiagonal ()
 Set the matrix as diagonal.
 
T_ getDiag (size_t k) const
 Return k-th diagonal entry of matrix.
 
size_t size () const
 Return matrix dimension (Number of rows and columns).
 
void setDiagonal (Mesh &mesh)
 Initialize matrix storage in the case where only diagonal terms are stored.
 
virtual void clear ()
 brief Set all matrix entries to zero
 
void Assembly (const Element &el, T_ *a)
 Assembly of element matrix into global matrix.
 
void Assembly (const Side &sd, T_ *a)
 Assembly of side matrix into global matrix.
 
void Prescribe (Vect< T_ > &b, const Vect< T_ > &u, int flag=0)
 Impose by a penalty method an essential boundary condition, using the Mesh instance provided by the constructor.
 
void Prescribe (int dof, int code, Vect< T_ > &b, const Vect< T_ > &u, int flag=0)
 Impose by a penalty method an essential boundary condition to a given degree of freedom for a given code.
 
void Prescribe (Vect< T_ > &b, int flag=0)
 Impose by a penalty method a homegeneous (=0) essential boundary condition.
 
void Prescribe (size_t dof, 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 PrescribeSide ()
 Impose by a penalty method an essential boundary condition when DOFs are supported by sides.
 
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.
 
int FactorAndSolve (const Vect< T_ > &b, Vect< T_ > &x)
 Factorize matrix and solve the linear system.
 
size_t getLength () const
 Return number of stored terms in matrix.
 
int isDiagonal () const
 Say if matrix is diagonal or not.
 
int isFactorized () const
 Say if matrix is factorized or not.
 
virtual size_t getColInd (size_t i) const
 Return Column index for column i (See the description for class SpMatrix).
 
virtual size_t getRowPtr (size_t i) const
 Return Row pointer for row i (See the description for class SpMatrix).
 
T_ operator() (size_t i) const
 Operator () with one argument (Constant version).
 
T_ & operator() (size_t i)
 Operator () with one argument (Non Constant version).
 
T_ & operator[] (size_t k)
 Operator [] (Non constant version).
 
T_ operator[] (size_t k) const
 Operator [] (Constant version).
 
Matrixoperator= (Matrix< T_ > &m)
 Operator =.
 
Matrixoperator+= (const Matrix< T_ > &m)
 Operator +=.
 
Matrixoperator-= (const Matrix< T_ > &m)
 Operator -=.
 
Matrixoperator= (const T_ &x)
 Operator =.
 
Matrixoperator*= (const T_ &x)
 Operator *=.
 
Matrixoperator+= (const T_ &x)
 Operator +=.
 
Matrixoperator-= (const T_ &x)
 Operator -=.
 

Detailed Description

template<class T_>
class OFELI::TrMatrix< T_ >

To handle tridiagonal matrices.

This class enables storing and manipulating tridiagonal matrices. The template parameter is the type of matrix entries. Any matrix entry can be accessed by the () operator: For instance, if A is an instance of this class, A(i,j) stands for the entry at the i-th row and j-th column, i and j starting from 1. If is difference from i-1, i or i+1, the returned value is 0. Entries of A can be assigned a value by the same operator. Only nonzero entries can be assigned.

Template Parameters
T_Data type (double, float, complex<double>, ...)
Author
Rachid Touzani