A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix. More...
#include <SquareMatrix.H>


Public Member Functions | |
| 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 Type &val) | |
| Construct for given size (rows == cols) initializing all elements to the given value. | |
| template<class AnyType> | |
| SquareMatrix (const label n, const Identity< AnyType >) | |
| Construct for given size (rows == cols) initializing to the identity matrix. | |
| template<class AnyType> | |
| 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 Type &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. | |
| template<class MatrixType> | |
| SquareMatrix (const ConstMatrixBlock< MatrixType > &mat) | |
| Construct from const sub-matrix block. | |
| template<class MatrixType> | |
| SquareMatrix (const MatrixBlock< MatrixType > &mat) | |
| Construct from sub-matrix block. | |
| SquareMatrix (const RectangularMatrix< Type > &mat) | |
| Construct as copy of a RectangularMatrix which is checked to be square. | |
| SquareMatrix (Istream &is) | |
| Construct from Istream. | |
| autoPtr< SquareMatrix< Type > > | 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. | |
| template<class CompOp> | |
| 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< Type > &&mat) |
| Move assignment. | |
| void | operator= (Foam::zero) |
| Assign all elements to zero. | |
| void | operator= (const Type &val) |
| Assign all elements to value. | |
| template<class AnyType> | |
| void | operator= (const Identity< AnyType >) |
| Set to identity matrix. | |
| template<class CompOp> | |
| Foam::labelList | sortPermutation (CompOp &compare) const |
| Public Member Functions inherited from Matrix< SquareMatrix< Type >, Type > | |
| Foam::tmp< Foam::Field< Type > > | AmulImpl (const ListType &x) const |
| Foam::tmp< Foam::Field< Type > > | TmulImpl (const ListType &x) const |
| Foam::ConstMatrixBlock< Foam::Matrix< SquareMatrix< Type >, Type > > | block (const label rowIndex, const label colIndex) const |
| Foam::MatrixBlock< Foam::Matrix< SquareMatrix< Type >, Type > > | block (const label rowIndex, const label colIndex) |
| Foam::tmp< Foam::Field< Type > > | Amul (const IndirectListBase< Type, Addr > &x) const |
| Foam::tmp< Foam::Field< Type > > | Tmul (const IndirectListBase< Type, Addr > &x) const |
| constexpr | Matrix () noexcept |
| Default construct (empty matrix). | |
| 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. | |
| const Type & | at (const label idx) const |
| Linear addressing const 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. | |
| 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< SquareMatrix< Type >, Type > &mat) |
| Swap contents. | |
| void | transfer (Matrix< SquareMatrix< Type >, 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. | |
| SquareMatrix< Type > | T () const |
| Return conjugate transpose of Matrix. | |
| SquareMatrix< Type > | transpose () const |
| Return non-conjugate transpose of Matrix. | |
| List< Type > | diag () const |
| Extract the diagonal elements. Method may change in the future. | |
| 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(). | |
| const Type & | operator() (const label irow, const label jcol) const |
| (i, j) const element access operator | |
| void | operator= (const Matrix< SquareMatrix< Type >, Type > &mat) |
| Copy assignment. Takes linear time. | |
| void | operator+= (const Matrix< SquareMatrix< Type >, Type > &other) |
| Matrix addition. | |
| void | operator-= (const Matrix< SquareMatrix< Type >, Type > &other) |
| Matrix 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. | |
| 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. | |
| ConstMatrixBlock< mType > | col (const label m, const label mStart, const label nStart) const |
| Deprecated(2019-04) - use subColumn(). | |
Additional Inherited Members | |
| Public Types inherited from Matrix< SquareMatrix< Type >, Type > | |
| typedef Matrix< SquareMatrix< Type >, 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< SquareMatrix< Type >, Type > | |
| static const Matrix< SquareMatrix< Type >, Type > & | null () noexcept |
| Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix. | |
A templated (N x N) square matrix of objects of <Type>, containing N*N elements, derived from Matrix.
Definition at line 57 of file SquareMatrix.H.
|
default |
Default construct.
Referenced by applyPermutation(), LLTMatrix< Type >::decompose(), LLTMatrix< Type >::LLTMatrix(), LLTMatrix< Type >::LLTMatrix(), operator=(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), SquareMatrix(), and SquareMatrix().

|
default |
Copy construct.
|
inlineexplicit |
Construct for given size (rows == cols), uninitialised content.
Definition at line 34 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and SquareMatrix().

|
inline |
Construct for given size (rows == cols) initializing all elements to zero.
Definition at line 41 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and SquareMatrix().

|
inline |
Construct for given size (rows == cols) initializing all elements to the given value.
Definition at line 52 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and SquareMatrix().

|
inline |
Construct for given size (rows == cols) initializing to the identity matrix.
Definition at line 64 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::n(), Matrix< SquareMatrix< Type >, Type >::operator()(), and SquareMatrix().

|
inline |
Construct for given size (rows == cols) by using a labelPair initializing to the identity matrix.
Definition at line 81 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Pair< T >::first(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::operator()(), Pair< T >::second(), and SquareMatrix().

|
inlineexplicit |
Construct given number of rows/columns by using a labelPair (checked to be equal).
For constructor consistency in rectangular matrices
Definition at line 99 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Pair< T >::first(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Pair< T >::second(), and SquareMatrix().

|
inline |
Construct given number of rows/columns by using a labelPair (checked to be equal) and initializing all elements to zero.
For constructor consistency with rectangular matrices
Definition at line 111 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Pair< T >::first(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Pair< T >::second(), and SquareMatrix().

|
inline |
Construct given number of rows/columns by using a labelPair (checked to be equal) and initializing all elements to the given value.
For constructor consistency with rectangular matrices
Definition at line 124 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Pair< T >::first(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Pair< T >::second(), and SquareMatrix().

|
inline |
Construct given number of rows/columns (checked to be equal) initializing all elements to zero.
Definition at line 137 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and SquareMatrix().

|
inline |
Construct from const sub-matrix block.
Definition at line 152 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), and SquareMatrix().

|
inline |
Construct from sub-matrix block.
Definition at line 165 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), and SquareMatrix().

|
inlineexplicit |
Construct as copy of a RectangularMatrix which is checked to be square.
Definition at line 177 of file SquareMatrixI.H.
|
inlineexplicit |
Construct from Istream.
Definition at line 189 of file SquareMatrixI.H.
References CHECK_MATRIX_IS_SQUARE, Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and SquareMatrix().

|
default |
Copy assignment.
|
inline |
Clone.
Definition at line 199 of file SquareMatrixI.H.
References Foam::New().

|
inline |
Resize the matrix preserving the elements.
Definition at line 208 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m().

|
inline |
Resize the matrix without preserving existing content.
Definition at line 215 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), and resize_nocopy().
Referenced by resize_nocopy().


|
inline |
Resize the matrix preserving the elements (compatibility).
Definition at line 222 of file SquareMatrixI.H.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), Matrix< SquareMatrix< Type >, Type >::n(), and resize().

|
inline |
Resize the matrix preserving the elements.
Definition at line 235 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), and resize().

|
inline |
Resize the matrix without reallocating storage (unsafe).
Definition at line 242 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m(), Matrix< SquareMatrix< Type >, Type >::Matrix(), and shallowResize().
Referenced by ODESolver::resizeMatrix(), and shallowResize().


|
inline |
Return true if the square matrix is effectively symmetric/Hermitian.
Definition at line 249 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m(), Foam::mag(), Matrix< SquareMatrix< Type >, Type >::n(), and n.

|
inline |
Return true if the square matrix is reduced tridiagonal.
Definition at line 266 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::m(), Foam::mag(), and n.

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.
Definition at line 47 of file SquareMatrix.C.
References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Matrix< SquareMatrix< Type >, Type >::m(), Foam::nl, p, Matrix< SquareMatrix< Type >, Type >::sizes(), SquareMatrix(), Matrix< Form, Type >::subColumn(), Matrix< SquareMatrix< Type >, Type >::subColumn(), and Matrix< SquareMatrix< Type >, Type >::transfer().

|
inline |
Move assignment.
Definition at line 294 of file SquareMatrixI.H.
References SquareMatrix(), and Matrix< SquareMatrix< Type >, Type >::transfer().

|
inline |
Assign all elements to zero.
Definition at line 301 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix().

|
inline |
Assign all elements to value.
Definition at line 308 of file SquareMatrixI.H.
References Matrix< SquareMatrix< Type >, Type >::Matrix().

Set to identity matrix.
Definition at line 77 of file SquareMatrix.C.
References Matrix< SquareMatrix< Type >, Type >::Matrix(), n, and Matrix< SquareMatrix< Type >, Type >::operator()().

| Foam::labelList sortPermutation | ( | CompOp & | compare | ) | const |
Definition at line 29 of file SquareMatrix.C.