|
IFEM 90A354
|
Class for representing a dense system matrix. More...
#include <DenseMatrix.h>


Public Member Functions | |
| DenseMatrix (size_t m=0, size_t n=0, bool s=false) | |
| Default constructor. | |
| DenseMatrix (const DenseMatrix &A) | |
| Copy constructor. | |
| DenseMatrix (const RealArray &data, size_t nrows=0) | |
| Special constructor taking data from a one-dimensional array. | |
| DenseMatrix (const Matrix &A, bool s=false) | |
| Special constructor, type conversion from Matrix. | |
| virtual | ~DenseMatrix () |
| The destructor frees the dynamically allocated arrays. | |
| virtual LinAlg::MatrixType | getType () const |
| Returns the matrix type. | |
| virtual SystemMatrix * | copy () const |
| Creates a copy of the system matrix and returns a pointer to it. | |
| bool | redim (size_t r, size_t c) |
| Resizes the matrix to dimension \(r \times c\). | |
| void | setSymmetric (bool s=true) |
| Marks the matrix as symmetric. | |
| virtual size_t | dim (int idim) const |
| Returns the dimension of the system matrix. | |
| Matrix & | getMat () |
| Access to the matrix itself. | |
| Real & | operator() (size_t r, size_t c) |
| Index-1 based element access. | |
| const Real & | operator() (size_t r, size_t c) const |
| Index-1 based element reference. | |
| virtual void | dump (std::ostream &os, LinAlg::StorageFormat format, const char *label) |
| Dumps the system matrix on a specified format. | |
| virtual void | initAssembly (const SAM &sam, char) |
| Initializes the element assembly process. | |
| virtual void | init () |
| Initializes the matrix to zero assuming it is properly dimensioned. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, int e) |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, SystemVector &B, int e) |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const SAM &sam, SystemVector &B, const std::vector< int > &meq) |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | assemble (const Matrix &eM, const IntVec &meq) |
| Adds an element matrix into the associated system matrix. | |
| virtual bool | augment (const SystemMatrix &B, size_t r0, size_t c0) |
| Augments a similar matrix symmetrically to the current matrix. | |
| virtual void | mult (Real alpha) |
| Multiplication with a scalar. | |
| virtual bool | add (const SystemMatrix &B, Real alpha) |
| Adds a matrix with similar dimension to the current matrix. | |
| virtual bool | add (Real sigma, int ieq) |
| Adds the constant σ to the diagonal of this matrix. | |
| virtual bool | multiply (const SystemVector &B, SystemVector &C) const |
| Performs the matrix-vector multiplication C = *this * B. | |
| virtual bool | solve (SystemVector &B, Real *rc=nullptr) |
| Solves the linear system of equations for a given right-hand-side. | |
| bool | solve (Matrix &B) |
| Solves the linear system of equations for a given right-hand-side. | |
| bool | solveEig (RealArray &eigVal, Matrix &eigVec, int nev) |
| Solves a standard symmetric-definite eigenproblem. | |
| bool | solveEigNon (RealArray &r_val, RealArray &c_val) |
| Solves a non-symmetric eigenproblem. | |
| bool | solveEig (DenseMatrix &B, RealArray &eigVal, Matrix &eigVec, int nev, Real shift=Real(0)) |
| Solves a generalized symmetric-definite eigenproblem. | |
| virtual Real | Linfnorm () const |
| Returns the L-infinity norm of the matrix. | |
| virtual bool | load (const char *fileName, bool binary) |
| Loads the system matrix from specified file. | |
| virtual bool | solve (SystemVector &b, Real *rc=nullptr)=0 |
| Solves the linear system of equations for a given right-hand-side. | |
| virtual bool | solve (const SystemVector &b, SystemVector &x) |
| Solves the linear system of equations for a given right-hand-side. | |
| virtual bool | solve (SystemVector &b, Matrix &x) |
| Solves a linear system of equations for multiple right-hand-sides. | |
Public Member Functions inherited from SystemMatrix | |
| virtual | ~SystemMatrix () |
| Empty destructor. | |
| virtual bool | lockPattern (bool) |
| Locks or unlocks the sparsity pattern. | |
| virtual bool | empty () const |
| Checks if the matrix is empty. | |
| bool | isZero () const |
| Checks if the matrix have no non-zero contributions. | |
| virtual void | preAssemble (const std::vector< IntVec > &, size_t=0) |
| Initializes the element sparsity pattern based on node connections. | |
| virtual void | compressPattern () |
| Compresses the sparsity pattern. | |
| void | initNonZeroEqs () |
| Initializes the nonZeroEqs flags. | |
| bool | flagNonZeroEq (int ieq=0) |
| Flags equation ieq as pivot element with non-zero contributions. | |
| bool | flagNonZeroEqs (const SAM &sam, const IntVec &meq) |
| Flags the equations meq as pivots with non-zero contributions. | |
| bool | flagNonZeroEqs (const SystemMatrix &B) |
| Flags the non-zero equations from B as non-zero pivots in this. | |
| virtual bool | endAssembly () |
| Finalizes the system matrix assembly. | |
| virtual bool | truncate (Real=Real(1.0e-16)) |
| Truncates all small matrix elements to zero. | |
| virtual void | dump (const char *fileName, std::streamsize precision=0, LinAlg::StorageFormat format=LinAlg::FLAT) |
| Dumps the system matrix to specified file. | |
| StdVector | operator* (const SystemVector &b) const |
| Calculates a matrix-vector product. | |
| StdVector | operator/ (const SystemVector &b) |
| Solves a linear equation system. | |
Protected Member Functions | |
| bool | augment (const Matrix &B, size_t r0, size_t c0) |
| Augments a dense matrix symmetrically to the current matrix. | |
| bool | augment (const SparseMatrix &B, size_t r0, size_t c0) |
| Augments a sparse matrix symmetrically to the current matrix. | |
| bool | solve (Real *B, size_t nrhs, Real *rcond=nullptr) |
| Solves the linear system of equations for a given right-hand-side. | |
| virtual std::ostream & | write (std::ostream &os) const |
| Writes the system matrix to the given output stream. | |
Protected Member Functions inherited from SystemMatrix | |
| SystemMatrix () | |
| Default constructor. | |
| SystemMatrix (const SystemMatrix &a) | |
| Copy constructor. | |
Private Attributes | |
| Matrix | myMat |
| The actual dense matrix. | |
| int * | ipiv |
| Pivot indices used in solve. | |
| bool | symm |
| Flags whether the matrix is symmetric or not. | |
Additional Inherited Members | |
Static Public Member Functions inherited from SystemMatrix | |
| static SystemMatrix * | create (const ProcessAdm *adm, LinAlg::MatrixType mType, int num_thread_SLU=1) |
| Static method creating a matrix of the given type. | |
| static SystemMatrix * | create (const ProcessAdm *adm, LinAlg::MatrixType mType, const LinSolParams &spar) |
| Static method creating a matrix of the given type. | |
Class for representing a dense system matrix.
|
virtual |
Adds a matrix with similar dimension to the current matrix.
| [in] | B | The matrix to be added |
| [in] | alpha | Scale factor for matrix B |
Reimplemented from SystemMatrix.
References utl::matrix< T >::add(), utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEqs(), SystemMatrix::isZero(), myMat, and utl::matrix< T >::rows().
|
virtual |
Adds the constant σ to the diagonal of this matrix.
Reimplemented from SystemMatrix.
References SystemMatrix::flagNonZeroEq(), myMat, utl::matrixBase< T >::ptr(), and utl::matrix< T >::rows().
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | meq | Matrix of element equation numbers (0 based) |
Implements SystemMatrix.
References SystemMatrix::flagNonZeroEq(), and myMat.
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data for FE assembly management |
| [in] | e | Identifier for the element that eM belongs to |
Implements SystemMatrix.
References assemDense(), utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEqs(), SAM::getElmEqns(), SAM::madof, SAM::meqn, SAM::mmceq, SAM::mmnpc, SAM::mpar, SAM::mpmceq, SAM::mpmnpc, myMat, SAM::neq, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::rows(), and SAM::ttcc.
|
virtual |
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data for FE assembly management |
| B | The system right-hand-side vector | |
| [in] | meq | Matrix of element equation numbers |
When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.
Implements SystemMatrix.
References assemDense(), utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEqs(), SAM::meqn, SAM::mmceq, SAM::mpmceq, myMat, SAM::neq, utl::matrix< T >::rows(), and SAM::ttcc.
|
virtual |
Adds an element matrix into the associated system matrix.
| [in] | eM | The element matrix |
| [in] | sam | Auxiliary data describing the FE model topology, nodal DOF status and constraint equations |
| B | The system right-hand-side vector | |
| [in] | e | Identifier for the element that eM belongs to |
When multi-point constraints are present, contributions from these are also added into the system right-hand-side vector, B.
Implements SystemMatrix.
References assemDense(), utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEqs(), SAM::getElmEqns(), SystemVector::getPtr(), SAM::madof, SAM::meqn, SAM::mmceq, SAM::mmnpc, SAM::mpar, SAM::mpmceq, SAM::mpmnpc, myMat, SAM::neq, utl::matrixBase< T >::ptr(), utl::matrix< T >::rows(), and SAM::ttcc.
|
protected |
Augments a dense matrix symmetrically to the current matrix.
| [in] | B | The matrix to be augmented |
| [in] | r0 | Row offset for the augmented matrix |
| [in] | c0 | Column offset for the augmented matrix |
References utl::matrix< T >::cols(), myMat, redim(), and utl::matrix< T >::rows().
|
protected |
Augments a sparse matrix symmetrically to the current matrix.
| [in] | B | The matrix to be augmented |
| [in] | r0 | Row offset for the augmented matrix |
| [in] | c0 | Column offset for the augmented matrix |
References SparseMatrix::cols(), SparseMatrix::getValues(), myMat, redim(), and SparseMatrix::rows().
|
virtual |
Augments a similar matrix symmetrically to the current matrix.
| [in] | B | The matrix to be augmented |
| [in] | r0 | Row offset for the augmented matrix |
| [in] | c0 | Column offset for the augmented matrix |
Reimplemented from SystemMatrix.
References augment(), and myMat.
Referenced by augment().
|
inlinevirtual |
Creates a copy of the system matrix and returns a pointer to it.
Implements SystemMatrix.
|
inlinevirtual |
Returns the dimension of the system matrix.
| [in] | idim | Which direction to return the dimension in |
Implements SystemMatrix.
References utl::matrixBase< T >::dim(), myMat, and utl::matrixBase< T >::size().
|
virtual |
Dumps the system matrix on a specified format.
Reimplemented from SystemMatrix.
References LinAlg::BINARY, utl::matrix< T >::cols(), LinAlg::FLAT, ipiv, LinAlg::MATLAB, LinAlg::MATRIX_MARKET, myMat, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::rows(), utl::matrixBase< T >::size(), symm, and utl::writeMatlab().
|
inlinevirtual |
|
virtual |
Initializes the matrix to zero assuming it is properly dimensioned.
Implements SystemMatrix.
References utl::matrix< T >::fill(), ipiv, myMat, and Real.
|
virtual |
Initializes the element assembly process.
| [in] | sam | Auxiliary data describing the FE model topology, etc. |
Implements SystemMatrix.
References myMat, SAM::neq, and utl::matrix< T >::resize().
|
inlinevirtual |
Returns the L-infinity norm of the matrix.
Implements SystemMatrix.
References myMat, and utl::matrix< T >::normInf().
|
virtual |
Loads the system matrix from specified file.
Reimplemented from SystemMatrix.
References utl::matrix< T >::cols(), SystemMatrix::flagNonZeroEq(), ipiv, myMat, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::rows(), and symm.
|
inlinevirtual |
Multiplication with a scalar.
Implements SystemMatrix.
References utl::matrix< T >::multiply(), and myMat.
|
virtual |
Performs the matrix-vector multiplication C = *this * B.
Reimplemented from SystemMatrix.
References utl::matrix< T >::multiply(), and myMat.
| bool DenseMatrix::redim | ( | size_t | r, |
| size_t | c | ||
| ) |
Resizes the matrix to dimension \(r \times c\).
Will preserve existing matrix content within the new dimension.
References utl::matrix< T >::cols(), utl::matrix< T >::fillColumn(), utl::matrix< T >::getColumn(), myMat, utl::matrix< T >::resize(), utl::matrix< T >::rows(), and symm.
|
inline |
Marks the matrix as symmetric.
If marked as symmetric, Cholesky factorization will be employed.
References utl::matrix< T >::cols(), myMat, utl::matrix< T >::rows(), and symm.
|
inlinevirtual |
Solves the linear system of equations for a given right-hand-side.
| [in] | b | Right-hand-side vector |
| [out] | x | Solution vector |
Reimplemented from SystemMatrix.
| bool DenseMatrix::solve | ( | Matrix & | B | ) |
Solves the linear system of equations for a given right-hand-side.
| B | Right-hand-side matrix on input, solution matrix on output |
References utl::matrix< T >::cols(), utl::matrixBase< T >::ptr(), and solve().
Solves the linear system of equations for a given right-hand-side.
| B | Right-hand-side vectors on input, solution vectors on output | |
| [in] | nrhs | Number of right-hand-side vectors |
| [out] | rcond | Reciprocal condition number of the LHS-matrix (optional) |
This is the function which actually solves the equation system, using the LAPack library subroutines. The two public solve methods just forward to this method.
References utl::matrix< T >::cols(), dgecon_(), dgesv_(), dgetrs_(), dlange_(), dposv_(), dpotrs_(), ipiv, myMat, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::rows(), and symm.
|
virtual |
Solves a linear system of equations for multiple right-hand-sides.
| b | Right-hand-side vectors on input, solution vectors on output | |
| [out] | x | Matrix of solution vectors (row-oriented) |
Reimplemented from SystemMatrix.
|
virtual |
Solves the linear system of equations for a given right-hand-side.
| B | Right-hand-side vector on input, solution vector on output | |
| [out] | rc | Reciprocal condition number of the LHS-matrix (optional) |
Implements SystemMatrix.
References SystemVector::dim(), SystemVector::getPtr(), myMat, utl::matrix< T >::rows(), and solve().
Referenced by SplineInterpolator::interpolate(), SplineInterpolator::leastsquare_approximation(), SplineInterpolator::quasiinterpolate(), ASMs2D::scRecovery(), ASMu2D::scRecovery(), ASMu3D::scRecovery(), solve(), and solve().
|
virtual |
Solves the linear system of equations for a given right-hand-side.
| b | Right-hand-side vector on input, solution vector on output | |
| [out] | rc | Reciprocal condition number of the LHS-matrix (optional) |
Implements SystemMatrix.
| bool DenseMatrix::solveEig | ( | DenseMatrix & | B, |
| RealArray & | eigVal, | ||
| Matrix & | eigVec, | ||
| int | nev, | ||
| Real | shift = Real(0) |
||
| ) |
Solves a generalized symmetric-definite eigenproblem.
| B | Symmetric and positive definite mass matrix. | |
| [out] | eigVal | Computed eigenvalues |
| [out] | eigVec | Computed eigenvectors stored column by column |
| [in] | nev | The number of eigenvalues and eigenvectors to compute |
| [in] | shift | Eigenvalue shift (unused) |
The eigenproblem is assumed to be on the form A x = λ B x where A ( = *this ) and B both are assumed to be symmetric and B also to be positive definite. The eigenproblem is solved by the LAPack library subroutine DSYGVX.
References utl::matrix< T >::cols(), dsygvx_(), myMat, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::resize(), and utl::matrix< T >::rows().
Solves a standard symmetric-definite eigenproblem.
| [out] | eigVal | Computed eigenvalues |
| [out] | eigVec | Computed eigenvectors stored column by column |
| [in] | nev | The number of eigenvalues and eigenvectors to compute |
The eigenproblem is assumed to be on the form A x = λ x where A ( = *this ) is assumed to be symmetric and positive definite. The eigenproblem is solved by the LAPack library subroutine DSYEVX.
References utl::matrix< T >::cols(), dsyevx_(), myMat, utl::matrixBase< T >::ptr(), Real, utl::matrix< T >::resize(), and utl::matrix< T >::rows().
Referenced by eig::solve().
Solves a non-symmetric eigenproblem.
| [out] | r_val | Real part of the computed eigenvalues |
| [out] | c_val | Complex part of the computed eigenvalues |
The eigenproblem is assumed to be on the form A x = λ x where A ( = *this ) is a square non-symmetric matrix. The eigenproblem is solved by the LAPack library subroutine DGEEV.
References dgeev_(), myMat, utl::matrixBase< T >::ptr(), Real, and utl::matrix< T >::rows().
Referenced by Legendre::GL().
|
inlineprotectedvirtual |
Writes the system matrix to the given output stream.
Reimplemented from SystemMatrix.
References myMat.