A simple square matrix solver with scalar coefficients. More...
#include <simpleMatrix.H>


Public Member Functions | |
| simpleMatrix (const label n) | |
| Construct given size. | |
| simpleMatrix (const label n, const scalar, const Type &) | |
| Construct given size and initial values for coefficients and source. | |
| simpleMatrix (const label n, Foam::zero) | |
| Construct given size, zero values for coefficients and source. | |
| simpleMatrix (const scalarSquareMatrix &, const Field< Type > &) | |
| Construct from components. | |
| simpleMatrix (const simpleMatrix< Type > &)=default | |
| Copy construct. | |
| simpleMatrix (Istream &) | |
| Construct from Istream. | |
| Field< Type > & | source () noexcept |
| Return access to the source. | |
| const Field< Type > & | source () const noexcept |
| Return const-access to the source. | |
| Field< Type > | solve () const |
| Solve the matrix using Gaussian elimination with pivoting and return the solution. | |
| Field< Type > | LUsolve () const |
| Solve the matrix using LU decomposition with pivoting and return the solution. | |
| void | operator= (const simpleMatrix< Type > &) |
| Copy assignment. | |
| Public Member Functions inherited from SquareMatrix< scalar > | |
| SquareMatrix ()=default | |
| Default construct. | |
| SquareMatrix (const SquareMatrix &)=default | |
| Copy construct. | |
| SquareMatrix & | operator= (const SquareMatrix &)=default |
| Copy assignment. | |
| SquareMatrix (const label n) | |
| Construct for given size (rows == cols), uninitialised content. | |
| SquareMatrix (const label n, Foam::zero) | |
| Construct for given size (rows == cols) initializing all elements to zero. | |
| SquareMatrix (const label n, const scalar &val) | |
| Construct for given size (rows == cols) initializing all elements to the given value. | |
| SquareMatrix (const label n, const Identity< AnyType >) | |
| Construct for given size (rows == cols) initializing to the identity matrix. | |
| SquareMatrix (const labelPair &dims, const Identity< AnyType >) | |
| Construct for given size (rows == cols) by using a labelPair initializing to the identity matrix. | |
| SquareMatrix (const labelPair &dims) | |
| Construct given number of rows/columns by using a labelPair (checked to be equal). | |
| SquareMatrix (const labelPair &dims, Foam::zero) | |
| Construct given number of rows/columns by using a labelPair (checked to be equal) and initializing all elements to zero. | |
| SquareMatrix (const labelPair &dims, const scalar &val) | |
| Construct given number of rows/columns by using a labelPair (checked to be equal) and initializing all elements to the given value. | |
| SquareMatrix (const label m, const label n, Foam::zero) | |
| Construct given number of rows/columns (checked to be equal) initializing all elements to zero. | |
| SquareMatrix (const ConstMatrixBlock< MatrixType > &mat) | |
| Construct from const sub-matrix block. | |
| SquareMatrix (const MatrixBlock< MatrixType > &mat) | |
| Construct from sub-matrix block. | |
| SquareMatrix (const RectangularMatrix< scalar > &mat) | |
| Construct as copy of a RectangularMatrix which is checked to be square. | |
| SquareMatrix (Istream &is) | |
| Construct from Istream. | |
| autoPtr< SquareMatrix< scalar > > | clone () const |
| Clone. | |
| void | resize (const label m) |
| Resize the matrix preserving the elements. | |
| void | resize_nocopy (const label n) |
| Resize the matrix without preserving existing content. | |
| void | resize (const label m, const label n) |
| Resize the matrix preserving the elements (compatibility). | |
| void | setSize (const label m) |
| Resize the matrix preserving the elements. | |
| void | shallowResize (const label m) |
| Resize the matrix without reallocating storage (unsafe). | |
| bool | symmetric () const |
| Return true if the square matrix is effectively symmetric/Hermitian. | |
| bool | tridiagonal () const |
| Return true if the square matrix is reduced tridiagonal. | |
| labelList | sortPermutation (CompOp &compare) const |
| Return a sort permutation using the given comparison operator on the diagonal entries. | |
| void | applyPermutation (const labelUList &p) |
| Column-reorder this Matrix according to the given permutation. | |
| void | operator= (SquareMatrix< scalar > &&mat) |
| Move assignment. | |
| void | operator= (Foam::zero) |
| Assign all elements to zero. | |
| void | operator= (const scalar &val) |
| Assign all elements to value. | |
| void | operator= (const Identity< AnyType >) |
| Set to identity matrix. | |
| Foam::labelList | sortPermutation (CompOp &compare) const |
| Public Member Functions inherited from Matrix< Form, Type > | |
| constexpr | Matrix () noexcept |
| Default construct (empty matrix). | |
| Matrix (const label m, const label n) | |
| Construct given number of rows/columns, uninitialised content. | |
| Matrix (const label m, const label n, Foam::zero) | |
| Construct with given number of rows/columns initializing all elements to zero. | |
| Matrix (const label m, const label n, const Type &val) | |
| Construct with given number of rows/columns initializing all elements to the given value. | |
| Matrix (const labelPair &dims) | |
| Construct given number of rows/columns. | |
| Matrix (const labelPair &dims, Foam::zero) | |
| Construct given number of rows/columns initializing all elements to zero. | |
| Matrix (const labelPair &dims, const Type &val) | |
| Construct with given number of rows/columns initializing all elements to the given value. | |
| Matrix (const Matrix< Form, Type > &mat) | |
| Copy construct. | |
| Matrix (Matrix< Form, Type > &&mat) | |
| Move construct. | |
| template<class Form2> | |
| Matrix (const Matrix< Form2, Type > &mat) | |
| Copy constructor from Matrix of a different form. | |
| template<class MatrixType> | |
| Matrix (const ConstMatrixBlock< MatrixType > &Mb) | |
| Construct from a block of another Matrix. | |
| template<class MatrixType> | |
| Matrix (const MatrixBlock< MatrixType > &Mb) | |
| Construct from a block of another Matrix. | |
| Matrix (Istream &is) | |
| Construct from Istream. | |
| autoPtr< mType > | clone () const |
| Clone. | |
| ~Matrix () | |
| Destructor. | |
| label | mRows () const noexcept |
| The number of rows. | |
| label | nRows () const noexcept |
| The number of rows. | |
| label | m () const noexcept |
| The number of rows. | |
| label | nCols () const noexcept |
| The number of columns. | |
| label | n () const noexcept |
| The number of columns. | |
| bool | empty () const noexcept |
| Return true if Matrix is empty (i.e., size() is zero). | |
| label | size () const noexcept |
| The number of elements in Matrix (m*n). | |
| labelPair | sizes () const noexcept |
| Return row/column sizes. | |
| const Type * | cdata () const noexcept |
| Return const pointer to the first data element, which can also be used to address into Matrix contents. | |
| Type * | data () noexcept |
| Return pointer to the first data element, which can also be used to address into Matrix contents. | |
| const char * | cdata_bytes () const noexcept |
| Return pointer to the underlying array serving as data storage, reinterpreted as byte data. | |
| char * | data_bytes () noexcept |
| Return pointer to the underlying array serving as data storage, reinterpreted as byte data. | |
| std::streamsize | size_bytes () const noexcept |
| Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous. | |
| std::streamsize | byteSize () const |
| Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous. | |
| const Type * | rowData (const label irow) const |
| Return const pointer to data in the specified row. | |
| Type * | rowData (const label irow) |
| Return pointer to data in the specified row. | |
| const Type & | at (const label idx) const |
| Linear addressing const element access. | |
| Type & | at (const label idx) |
| Linear addressing element access. | |
| ConstMatrixBlock< mType > | subColumn (const label colIndex, const label rowIndex=0, label len=-1) const |
| Return const column or column's subset of Matrix. | |
| ConstMatrixBlock< mType > | subRow (const label rowIndex, const label colIndex=0, label len=-1) const |
| Return const row or const row's subset of Matrix. | |
| ConstMatrixBlock< mType > | subMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const |
| Return const sub-block of Matrix. | |
| template<class VectorSpace> | |
| ConstMatrixBlock< mType > | block (const label rowIndex, const label colIndex) const |
| Access Field as a ConstMatrixBlock. | |
| MatrixBlock< mType > | subColumn (const label colIndex, const label rowIndex=0, label len=-1) |
| Return column or column's subset of Matrix. | |
| MatrixBlock< mType > | subRow (const label rowIndex, const label colIndex=0, label len=-1) |
| Return row or row's subset of Matrix. | |
| MatrixBlock< mType > | subMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) |
| Return sub-block of Matrix. | |
| template<class VectorSpace> | |
| MatrixBlock< mType > | block (const label rowIndex, const label colIndex) |
| Access Field as a MatrixBlock. | |
| void | checki (const label irow) const |
| Check index i is within valid range [0, m). | |
| void | checkj (const label jcol) const |
| Check index j is within valid range [0, n). | |
| void | checkSize () const |
| Check that dimensions are positive, non-zero. | |
| bool | uniform () const |
| True if all entries have identical values, and Matrix is non-empty. | |
| void | clear () |
| Clear Matrix, i.e. set sizes to zero. | |
| List< Type > | release () |
| Release storage management of Matrix contents by transferring management to a List. | |
| void | swap (Matrix< Form, Type > &mat) |
| Swap contents. | |
| void | transfer (Matrix< Form, Type > &mat) |
| Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix. | |
| void | resize (const label m, const label n) |
| Change Matrix dimensions, preserving the elements. | |
| void | resize_nocopy (const label mrow, const label ncol) |
| Change Matrix dimensions without preserving existing content. | |
| void | setSize (const label m, const label n) |
| Change Matrix dimensions, preserving the elements. | |
| void | shallowResize (const label m, const label n) |
| Resize Matrix without reallocating storage (unsafe). | |
| void | round (const scalar tol=SMALL) |
| Round elements with magnitude smaller than tol (SMALL) to zero. | |
| Form | T () const |
| Return conjugate transpose of Matrix. | |
| Form | transpose () const |
| Return non-conjugate transpose of Matrix. | |
| tmp< Field< Type > > | Amul (const UList< Type > &x) const |
| Right-multiply Matrix by a column vector (A * x). | |
| template<class Addr> | |
| tmp< Field< Type > > | Amul (const IndirectListBase< Type, Addr > &x) const |
| Right-multiply Matrix by a column vector (A * x). | |
| tmp< Field< Type > > | Tmul (const UList< Type > &x) const |
| Left-multiply Matrix by a row vector (x * A). | |
| template<class Addr> | |
| tmp< Field< Type > > | Tmul (const IndirectListBase< Type, Addr > &x) const |
| Left-multiply Matrix by a row vector (x * A). | |
| List< Type > | diag () const |
| Extract the diagonal elements. Method may change in the future. | |
| void | diag (const UList< Type > &list) |
| Assign diagonal of Matrix. | |
| Type | trace () const |
| Return the trace. | |
| scalar | columnNorm (const label colIndex, const bool noSqrt=false) const |
| Return L2-Norm of chosen column. | |
| scalar | norm (const bool noSqrt=false) const |
| Return Frobenius norm of Matrix. | |
| const Type * | operator[] (const label irow) const |
| Return const pointer to data in the specified row - rowData(). | |
| Type * | operator[] (const label irow) |
| Return pointer to data in the specified row - rowData(). | |
| const Type & | operator() (const label irow, const label jcol) const |
| (i, j) const element access operator | |
| Type & | operator() (const label irow, const label jcol) |
| (i, j) element access operator | |
| void | operator= (const Matrix< Form, Type > &mat) |
| Copy assignment. Takes linear time. | |
| void | operator= (Matrix< Form, Type > &&mat) |
| Move assignment. | |
| template<class MatrixType> | |
| void | operator= (const ConstMatrixBlock< MatrixType > &Mb) |
| Assignment to a block of another Matrix. | |
| template<class MatrixType> | |
| void | operator= (const MatrixBlock< MatrixType > &Mb) |
| Assignment to a block of another Matrix. | |
| void | operator= (Foam::zero) |
| Assignment of all elements to zero. | |
| void | operator= (const Type &val) |
| Assignment of all elements to the given value. | |
| void | operator+= (const Matrix< Form, Type > &other) |
| Matrix addition. | |
| void | operator-= (const Matrix< Form, Type > &other) |
| Matrix subtraction. | |
| void | operator+= (const Type &s) |
| Matrix scalar addition. | |
| void | operator-= (const Type &s) |
| Matrix scalar subtraction. | |
| void | operator*= (const Type &s) |
| Matrix scalar multiplication. | |
| void | operator/= (const Type &s) |
| Matrix scalar division. | |
| iterator | begin () noexcept |
| Return an iterator to begin traversing a Matrix. | |
| iterator | end () noexcept |
| Return an iterator to end traversing a Matrix. | |
| const_iterator | cbegin () const noexcept |
| Return const_iterator to begin traversing a constant Matrix. | |
| const_iterator | cend () const noexcept |
| Return const_iterator to end traversing a constant Matrix. | |
| const_iterator | begin () const noexcept |
| Return const_iterator to begin traversing a constant Matrix. | |
| const_iterator | end () const noexcept |
| Return const_iterator to end traversing a constant Matrix. | |
| bool | readMatrix (Istream &is) |
| Read Matrix from Istream, discarding existing contents. | |
| Ostream & | writeMatrix (Ostream &os, const label shortLen=0) const |
| Write Matrix, with line-breaks in ASCII when length exceeds shortLen. | |
| const Type * | v () const |
| Deprecated(2019-04) raw data pointer, const access. | |
| Type * | v () |
| Deprecated(2019-04) raw data pointer, non-const access. | |
| ConstMatrixBlock< mType > | block (const label m, const label n, const label mStart, const label nStart) const |
| Deprecated(2019-04) - use subMatrix(). | |
| MatrixBlock< mType > | block (const label m, const label n, const label mStart, const label nStart) |
| Deprecated(2019-04) - use subMatrix(). | |
| ConstMatrixBlock< mType > | col (const label m, const label mStart, const label nStart) const |
| Deprecated(2019-04) - use subColumn(). | |
| MatrixBlock< mType > | col (const label m, const label mStart, const label nStart) |
| Deprecated(2019-04) - use subColumn(). | |
| void | col (const label m, const label rowStart) const =delete |
| Deleted(2019-04) - use subColumn(). | |
| void | col (const label m, const label rowStart)=delete |
| Deleted(2019-04) - use subColumn(). | |
| template<class ListType> | |
| Foam::tmp< Foam::Field< Type > > | AmulImpl (const ListType &x) const |
| template<class ListType> | |
| Foam::tmp< Foam::Field< Type > > | TmulImpl (const ListType &x) const |
| template<class VectorSpace> | |
| Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > | block (const label rowIndex, const label colIndex) const |
| template<class VectorSpace> | |
| Foam::MatrixBlock< Foam::Matrix< Form, Type > > | block (const label rowIndex, const label colIndex) |
| template<class Addr> | |
| Foam::tmp< Foam::Field< Type > > | Amul (const IndirectListBase< Type, Addr > &x) const |
| template<class Addr> | |
| Foam::tmp< Foam::Field< Type > > | Tmul (const IndirectListBase< Type, Addr > &x) const |
Friends | |
| Ostream & | operator<< (Ostream &, const simpleMatrix< Type > &) |
Additional Inherited Members | |
| Public Types inherited from Matrix< Form, Type > | |
| typedef Matrix< Form, Type > | mType |
| Matrix type. | |
| typedef Type | cmptType |
| The value type the Matrix contains. | |
| typedef Type | value_type |
| The value type the Matrix contains. | |
| typedef label | size_type |
| The type to represent the size of a Matrix. | |
| typedef Type * | iterator |
| Random access iterator for traversing a Matrix. | |
| typedef const Type * | const_iterator |
| Random access iterator for traversing a Matrix. | |
| Static Public Member Functions inherited from Matrix< Form, Type > | |
| static const Matrix< Form, Type > & | null () noexcept |
| Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix. | |
A simple square matrix solver with scalar coefficients.
Definition at line 52 of file simpleMatrix.H.
|
explicit |
Construct given size.
Note: this does not initialise the coefficients or the source.
Definition at line 27 of file simpleMatrix.C.
Referenced by operator<<, operator=(), and simpleMatrix().

| simpleMatrix | ( | const label | n, |
| const scalar | coeffVal, | ||
| const Type & | sourceVal ) |
Construct given size and initial values for coefficients and source.
Definition at line 35 of file simpleMatrix.C.
| simpleMatrix | ( | const label | n, |
| Foam::zero | ) |
Construct given size, zero values for coefficients and source.
Definition at line 48 of file simpleMatrix.C.
References Matrix< Form, Type >::n().

| simpleMatrix | ( | const scalarSquareMatrix & | matrix, |
| const Field< Type > & | source ) |
Construct from components.
Definition at line 56 of file simpleMatrix.C.
References source().

|
default |
|
explicit |
Construct from Istream.
Definition at line 68 of file simpleMatrix.C.
|
inlinenoexcept |
Return access to the source.
Definition at line 102 of file simpleMatrix.H.
References Foam::noexcept.
Referenced by simpleMatrix().

|
inlinenoexcept |
Return const-access to the source.
Definition at line 107 of file simpleMatrix.H.
References Foam::noexcept.
| Foam::Field< Type > solve | ( | ) | const |
Solve the matrix using Gaussian elimination with pivoting and return the solution.
Definition at line 78 of file simpleMatrix.C.
References Foam::solve().

| Foam::Field< Type > LUsolve | ( | ) | const |
Solve the matrix using LU decomposition with pivoting and return the solution.
Definition at line 90 of file simpleMatrix.C.
References Foam::LUsolve().

| void operator= | ( | const simpleMatrix< Type > & | m | ) |
Copy assignment.
Definition at line 104 of file simpleMatrix.C.
References FatalErrorInFunction, Matrix< Form, Type >::m(), and simpleMatrix().

|
friend |
References simpleMatrix().