LocalMatrix Class Template Reference
[Vector and Matrix]
#include <LocalMatrix.h>
Detailed Description
template<class T_, size_t NR_, size_t NC_>
class OFELI::LocalMatrix< T_, NR_, NC_ >
Handles small size matrices like element matrices.
The template class LocalMatrix treats small size matrices. Typically, this class is recommended to store element and side arrays.
Internally, no dynamic storage is used.
Template Arguments :
- T_ data type (double, float, ...)
- NR_ number of rows of matrix
- NC_ number of columns of matrix
Public Member Functions | |
| int | Factor () |
| Factorize matrix. | |
| int | FactorAndSolve (LocalVect< T_, NR_ > &b) |
| Factorize matrix and solve linear system. | |
| T_ * | getArray () |
| Return pointer to matrix as a C-array. | |
| T_ | getInnerProduct (const LocalVect< T_, NC_ > &x, const LocalVect< T_, NR_ > &y) |
| Calculate inner product witrh respect to matrix. | |
| void | Invert (LocalMatrix< T_, NR_, NC_ > &A) |
| Calculate inverse of matrix. | |
| void | Localize (Element *el, const SkSMatrix< T_ > &a) |
| Initialize matrix as element matrix from global SkSMatrix. | |
| void | Localize (Element *el, const SkMatrix< T_ > &a) |
| Initialize matrix as element matrix from global SkMatrix. | |
| void | Localize (Element *el, const SpMatrix< T_ > &a) |
| Initialize matrix as element matrix from global SpMatrix. | |
| LocalMatrix (Element *el, const SkSMatrix< T_ > &a) | |
| Constructor of a local matrix associated to element from a SkSMatrix. | |
| LocalMatrix (Element *el, const SkMatrix< T_ > &a) | |
| Constructor of a local matrix associated to element from a SkMatrix. | |
| LocalMatrix (Element *el, const SpMatrix< T_ > &a) | |
| Constructor of a local matrix associated to element from a SpMatrix. | |
| LocalMatrix (const LocalMatrix< T_, NR_, NC_ > &m) | |
| Copy constructor. | |
| LocalMatrix () | |
| Default constructor. | |
| void | Mult (const LocalVect< T_, NC_ > &x, LocalVect< T_, NR_ > &y) |
| Multiply matrix by vector. | |
| void | MultAdd (const LocalVect< T_, NC_ > &x, LocalVect< T_, NR_ > &y) |
| Multiply matrix by vector and add result to vector. | |
| void | MultAddScal (const T_ &a, const LocalVect< T_, NC_ > &x, LocalVect< T_, NR_ > &y) |
| Multiply matrix by scaled vector and add result to vector. | |
| T_ | operator() (size_t i, size_t j) const |
| Operator () (Constant version). | |
| T_ & | operator() (size_t i, size_t j) |
| Operator () (Non constant version). | |
| LocalVect< T_, NR_ > | operator* (LocalVect< T_, NC_ > &x) |
| Operator *. | |
| LocalMatrix< T_, NR_, NC_ > & | operator*= (const T_ &x) |
| Operator *=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator+= (const T_ &x) |
| Operator +=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator+= (const LocalMatrix< T_, NR_, NC_ > &m) |
| Operator +=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator-= (const T_ &x) |
| Operator -=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator-= (const LocalMatrix< T_, NR_, NC_ > &m) |
| Operator -=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator/= (const T_ &x) |
| Operator /=. | |
| LocalMatrix< T_, NR_, NC_ > & | operator= (const T_ &x) |
| Operator =. | |
| LocalMatrix< T_, NR_, NC_ > & | operator= (const LocalMatrix< T_, NR_, NC_ > &m) |
| Operator =. | |
| int | Solve (LocalVect< T_, NR_ > &b) |
| Forward and backsubstitute to solve a linear system. | |
| void | Symmetrize () |
| Symmetrize matrix. | |
| ~LocalMatrix () | |
| Destructor. | |
Constructor & Destructor Documentation
| LocalMatrix | ( | ) |
Default constructor.
Initialize matrix entries to zero.
| LocalMatrix | ( | Element * | el, | |
| const SpMatrix< T_ > & | a | |||
| ) |
Constructor of a local matrix associated to element from a SpMatrix.
References LocalMatrix::Localize().
| LocalMatrix | ( | Element * | el, | |
| const SkMatrix< T_ > & | a | |||
| ) |
Constructor of a local matrix associated to element from a SkMatrix.
References LocalMatrix::Localize().
| LocalMatrix | ( | Element * | el, | |
| const SkSMatrix< T_ > & | a | |||
| ) |
Constructor of a local matrix associated to element from a SkSMatrix.
References LocalMatrix::Localize().
Member Function Documentation
| int Factor | ( | ) |
Factorize matrix.
Performs a LU factorization.
- Return values:
-
ret - 0 : Factorization has ended normally,
- n : n-th pivot was zero.
References OFELI::Abs(), and OFELI_EPSMCH.
Referenced by LocalMatrix::FactorAndSolve(), and LocalMatrix::Invert().
| int FactorAndSolve | ( | LocalVect< T_, NR_ > & | b | ) |
Factorize matrix and solve linear system.
- Parameters:
-
b [in/out] Right-hand side in input and solution vector in output.
- Return values:
-
ret - 0 if solution was performed normally.
-
n if
n-thpivot is zero.
Factor()thenSolve(b).
References LocalMatrix::Factor(), and LocalMatrix::Solve().
Calculate inner product witrh respect to matrix.
Returns the product x^T*A*y
- Parameters:
-
[in] x Left vector [in] y Right vector
- Return values:
-
p Resulting product
| void Invert | ( | LocalMatrix< T_, NR_, NC_ > & | A | ) |
Calculate inverse of matrix.
- Parameters:
-
[out] A Inverse of matrix
References LocalMatrix::Factor(), and LocalMatrix::Solve().
Initialize matrix as element matrix from global SkSMatrix.
- Parameters:
-
[in] el Pointer to Element [in] a Global matrix as instance of class SkSMatrix. This function is called by its corresponding constructor.
References Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
Initialize matrix as element matrix from global SkMatrix.
- Parameters:
-
[in] el Pointer to Element [in] a Global matrix as instance of class SkMatrix. This function is called by its corresponding constructor.
References Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
Initialize matrix as element matrix from global SpMatrix.
- Parameters:
-
[in] el Pointer to Element [in] a Global matrix as instance of class SpMatrix. This function is called by its corresponding constructor.
References Node::getDOF(), Node::getNbDOF(), Element::getNbNodes(), and Element::getPtrNode().
Referenced by LocalMatrix::LocalMatrix().
Multiply matrix by vector.
- Parameters:
-
[in] x Vector to multiply matrix by. [out] y Resulting vector.
References LocalMatrix::MultAdd().
Multiply matrix by vector and add result to vector.
- Parameters:
-
[in] x Vector to multiply matrix by. [out] y Resulting vector ( y+=a*x)
Referenced by LocalMatrix::Mult().
Multiply matrix by scaled vector and add result to vector.
- Parameters:
-
a Constant to premultiply by vector x.[in] x (Scaled) vector to multiply matrix by. [out] y Resulting vector ( y+=a*x)
| T_ operator() | ( | size_t | i, | |
| size_t | j | |||
| ) | const |
Operator () (Constant version).
Returns entry at row i and column j.
| T_& operator() | ( | size_t | i, | |
| size_t | j | |||
| ) |
Operator () (Non constant version).
Returns entry at row i and column j.
Operator *.
Return a Vect instance as product of current matrix by vector x.
| LocalMatrix< T_, NR_, NC_ > & operator*= | ( | const T_ & | x | ) |
Operator *=.
Multiply matrix entries by constant x.
| LocalMatrix< T_, NR_, NC_ > & operator+= | ( | const T_ & | x | ) |
Operator +=.
Add constant x to current matrix entries.
| LocalMatrix< T_, NR_, NC_ > & operator+= | ( | const LocalMatrix< T_, NR_, NC_ > & | m | ) |
| LocalMatrix< T_, NR_, NC_ > & operator-= | ( | const T_ & | x | ) |
Operator -=.
Subtract x from current matrix entries.
| LocalMatrix< T_, NR_, NC_ > & operator-= | ( | const LocalMatrix< T_, NR_, NC_ > & | m | ) |
| LocalMatrix< T_, NR_, NC_ > & operator/= | ( | const T_ & | x | ) |
Operator /=.
Divide by x current matrix entries.
| LocalMatrix< T_, NR_, NC_ > & operator= | ( | const T_ & | x | ) |
Operator =.
Assign x to matrix entries.
| LocalMatrix< T_, NR_, NC_ > & operator= | ( | const LocalMatrix< T_, NR_, NC_ > & | m | ) |
Operator =.
Copy instance m into current instance.
References LocalMatrix::_a, and LocalMatrix::_length.
| int Solve | ( | LocalVect< T_, NR_ > & | b | ) |
Forward and backsubstitute to solve a linear system.
- Parameters:
-
[in] b Right-hand side in input and solution vector in output.
- Return values:
-
ret - 0 : Solution was performed normally.
- n : n-th pivot is zero.
References OFELI::Abs(), and OFELI_EPSMCH.
Referenced by LocalMatrix::FactorAndSolve(), and LocalMatrix::Invert().
| void Symmetrize | ( | ) |
Symmetrize matrix.
Fill upper triangle to form a symmetric matrix.