SymmetricSquareMatrix< Type > Class Template Reference

A templated 2D square symmetric matrix of objects of <T>, where the n x n matrix dimension is known and used for subscript bounds checking, etc. More...

Inheritance diagram for SymmetricSquareMatrix< Type >:
[legend]
Collaboration diagram for SymmetricSquareMatrix< Type >:
[legend]

Public Member Functions

 SymmetricSquareMatrix ()
 Construct null. More...
 
 SymmetricSquareMatrix (const label n)
 Construct for given size (rows == cols) More...
 
 SymmetricSquareMatrix (const label n, const zero)
 
 SymmetricSquareMatrix (const label n, const Type &val)
 
template<class AnyType >
 SymmetricSquareMatrix (const label n, const Identity< AnyType >)
 
 SymmetricSquareMatrix (Istream &is)
 Construct from Istream. More...
 
autoPtr< SymmetricSquareMatrix< Type > > clone () const
 Clone. More...
 
void operator= (const zero)
 Assign all elements to zero. More...
 
void operator= (const Type &val)
 Assign all elements to value. More...
 
template<class AnyType >
void operator= (const Identity< AnyType >)
 Set to identity matrix. More...
 
- Public Member Functions inherited from Matrix< SymmetricSquareMatrix< Type >, Type >
label n () const noexcept
 The number of columns. More...
 
Foam::tmp< Foam::Field< Type > > AmulImpl (const ListType &x) const
 
Foam::tmp< Foam::Field< Type > > TmulImpl (const ListType &x) const
 
 Matrix ()
 Construct null. More...
 
 Matrix (const label m, const label n)
 Construct given number of rows/columns. More...
 
 Matrix (const label m, const label n, const zero)
 
 Matrix (const label m, const label n, const Type &val)
 
 Matrix (const labelPair &dims)
 Construct given number of rows/columns. More...
 
 Matrix (const labelPair &dims, const zero)
 
 Matrix (const labelPair &dims, const Type &val)
 
 Matrix (const Matrix< SymmetricSquareMatrix< Type >, Type > &mat)
 Copy construct. More...
 
 Matrix (Matrix< SymmetricSquareMatrix< Type >, Type > &&mat)
 Move construct. More...
 
 Matrix (const Matrix< Form2, Type > &mat)
 Copy constructor from Matrix of a different form. More...
 
 Matrix (const ConstMatrixBlock< MatrixType > &Mb)
 Construct from a block of another Matrix. More...
 
 Matrix (const MatrixBlock< MatrixType > &Mb)
 Construct from a block of another Matrix. More...
 
 Matrix (Istream &is)
 Construct from Istream. More...
 
autoPtr< mTypeclone () const
 Clone. More...
 
 ~Matrix ()
 Destructor. More...
 
label m () const noexcept
 The number of rows. More...
 
label size () const
 The number of elements in Matrix (m*n) More...
 
labelPair sizes () const
 Return row/column sizes. More...
 
bool empty () const noexcept
 Return true if Matrix is empty (i.e., size() is zero) More...
 
const Type * cdata () const noexcept
 
Type * data () noexcept
 
const Type * rowData (const label irow) const
 Return const pointer to data in the specified row. More...
 
Type * rowData (const label irow)
 Return pointer to data in the specified row. More...
 
const Type & at (const label idx) const
 Linear addressing const element access. More...
 
Type & at (const label idx)
 Linear addressing element access. More...
 
ConstMatrixBlock< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1) const
 Return const column or column's subset of Matrix. More...
 
MatrixBlock< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1)
 Return column or column's subset of Matrix. More...
 
ConstMatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1) const
 Return const row or const row's subset of Matrix. More...
 
MatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1)
 Return row or row's subset of Matrix. More...
 
ConstMatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
 Return const sub-block of Matrix. More...
 
MatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1)
 Return sub-block of Matrix. More...
 
ConstMatrixBlock< mTypeblock (const label rowIndex, const label colIndex) const
 Access Field as a ConstMatrixBlock. More...
 
MatrixBlock< mTypeblock (const label rowIndex, const label colIndex)
 Access Field as a MatrixBlock. More...
 
Foam::ConstMatrixBlock< Foam::Matrix< SymmetricSquareMatrix< Type >, Type > > block (const label rowIndex, const label colIndex) const
 
Foam::MatrixBlock< Foam::Matrix< SymmetricSquareMatrix< Type >, Type > > block (const label rowIndex, const label colIndex)
 
void checki (const label irow) const
 Check index i is within valid range [0, m) More...
 
void checkj (const label jcol) const
 Check index j is within valid range [0, n) More...
 
void checkSize () const
 Check that dimensions are positive, non-zero. More...
 
bool uniform () const
 True if all entries have identical values, and Matrix is non-empty. More...
 
void clear ()
 Clear Matrix, i.e. set sizes to zero. More...
 
List< Type > release ()
 
void swap (Matrix< SymmetricSquareMatrix< Type >, Type > &mat)
 Swap contents. More...
 
void transfer (Matrix< SymmetricSquareMatrix< Type >, Type > &mat)
 
void resize (const label m, const label n)
 Change Matrix dimensions, preserving the elements. More...
 
void setSize (const label m, const label n)
 Change Matrix dimensions, preserving the elements. More...
 
void shallowResize (const label m, const label n)
 Resize Matrix without reallocating storage (unsafe) More...
 
void round (const scalar tol=SMALL)
 Round to zero elements with magnitude smaller than tol (SMALL) More...
 
SymmetricSquareMatrix< Type > T () const
 Return (conjugate) transpose of Matrix. More...
 
tmp< Field< Type > > Amul (const UList< Type > &x) const
 Right-multiply Matrix by a column vector (A * x) More...
 
tmp< Field< Type > > Amul (const IndirectListBase< Type, Addr > &x) const
 Right-multiply Matrix by a column vector (A * x) More...
 
Foam::tmp< Foam::Field< Type > > Amul (const IndirectListBase< Type, Addr > &x) const
 
tmp< Field< Type > > Tmul (const UList< Type > &x) const
 Left-multiply Matrix by a row vector (x * A) More...
 
tmp< Field< Type > > Tmul (const IndirectListBase< Type, Addr > &x) const
 Left-multiply Matrix by a row vector (x * A) More...
 
Foam::tmp< Foam::Field< Type > > Tmul (const IndirectListBase< Type, Addr > &x) const
 
List< Type > diag () const
 Extract the diagonal elements. Method may change in the future. More...
 
void diag (const UList< Type > &list)
 Assign diagonal of Matrix. More...
 
Type trace () const
 Return the trace. More...
 
scalar columnNorm (const label colIndex, const bool noSqrt=false) const
 Return L2-Norm of chosen column. More...
 
scalar norm (const bool noSqrt=false) const
 Return Frobenius norm of Matrix. More...
 
const Type * operator[] (const label irow) const
 Return const pointer to data in the specified row - rowData(). More...
 
Type * operator[] (const label irow)
 Return pointer to data in the specified row - rowData(). More...
 
const Type & operator() (const label irow, const label jcol) const
 (i, j) const element access operator More...
 
Type & operator() (const label irow, const label jcol)
 (i, j) element access operator More...
 
void operator= (const Matrix< SymmetricSquareMatrix< Type >, Type > &mat)
 Copy assignment. Takes linear time. More...
 
void operator= (Matrix< SymmetricSquareMatrix< Type >, Type > &&mat)
 Move assignment. More...
 
void operator= (const ConstMatrixBlock< MatrixType > &Mb)
 Assignment to a block of another Matrix. More...
 
void operator= (const MatrixBlock< MatrixType > &Mb)
 Assignment to a block of another Matrix. More...
 
void operator= (const zero)
 Assignment of all elements to zero. More...
 
void operator= (const Type &val)
 Assignment of all elements to the given value. More...
 
void operator+= (const Matrix< SymmetricSquareMatrix< Type >, Type > &other)
 Matrix addition. More...
 
void operator+= (const Type &s)
 Matrix scalar addition. More...
 
void operator-= (const Matrix< SymmetricSquareMatrix< Type >, Type > &other)
 Matrix subtraction. More...
 
void operator-= (const Type &s)
 Matrix scalar subtraction. More...
 
void operator*= (const Type &s)
 Matrix scalar multiplication. More...
 
void operator/= (const Type &s)
 Matrix scalar division. More...
 
iterator begin ()
 Return an iterator to begin traversing a Matrix. More...
 
const_iterator begin () const
 Return const_iterator to begin traversing a constant Matrix. More...
 
iterator end ()
 Return an iterator to end traversing a Matrix. More...
 
const_iterator end () const
 Return const_iterator to end traversing a constant Matrix. More...
 
const_iterator cbegin () const
 Return const_iterator to begin traversing a constant Matrix. More...
 
const_iterator cend () const
 Return const_iterator to end traversing a constant Matrix. More...
 
bool readMatrix (Istream &is)
 Read Matrix from Istream, discarding existing contents. More...
 
OstreamwriteMatrix (Ostream &os, const label shortLen=0) const
 
label mRows () const noexcept
 The number of rows - same as m() More...
 
label nRows () const noexcept
 The number of rows - same as m() More...
 
label nCols () const noexcept
 The number of columns - same as n() More...
 
const Type * FOAM_DEPRECATED_FOR (2019-04, "cdata() method") v() const
 Deprecated(2019-04) raw data pointer, const access. More...
 
Type * FOAM_DEPRECATED_FOR (2019-04, "data() method") v()
 Deprecated(2019-04) raw data pointer, non-const access. More...
 
ConstMatrixBlock< mTypeFOAM_DEPRECATED_FOR (2019-04, "subMatrix() method") block(const label m
 Deprecated(2019-04) - use subMatrix() More...
 
MatrixBlock< mTypeFOAM_DEPRECATED_FOR (2019-04, "subMatrix() method") block(const label m
 Deprecated(2019-04) - use subMatrix() More...
 
ConstMatrixBlock< mTypeFOAM_DEPRECATED_FOR (2019-04, "subColumn() method") col(const label m
 Deprecated(2019-04) - use subColumn() More...
 
MatrixBlock< mTypeFOAM_DEPRECATED_FOR (2019-04, "subColumn() method") col(const label m
 Deprecated(2019-04) - use subColumn() More...
 
void col (const label m, const label rowStart) const=delete
 Deleted(2019-04) - use subColumn() More...
 
void col (const label m, const label rowStart)=delete
 Deleted(2019-04) - use subColumn() More...
 

Additional Inherited Members

- Public Types inherited from Matrix< SymmetricSquareMatrix< Type >, Type >
typedef Matrix< SymmetricSquareMatrix< Type >, Type > mType
 Matrix type. More...
 
typedef Type cmptType
 Component type. More...
 
typedef Type * iterator
 Random access iterator for traversing a Matrix. More...
 
- Static Public Member Functions inherited from Matrix< SymmetricSquareMatrix< Type >, Type >
static const Matrix< SymmetricSquareMatrix< Type >, Type > & null ()
 Return a null Matrix. More...
 
- Public Attributes inherited from Matrix< SymmetricSquareMatrix< Type >, Type >
const typedef Type * const_iterator
 Random access iterator for traversing a Matrix. More...
 
ConstMatrixBlock< mType > const label n
 
MatrixBlock< mType > const label n
 
ConstMatrixBlock< mType > const label const label mStart
 
MatrixBlock< mType > const label const label mStart
 
ConstMatrixBlock< mType > const label mStart
 
MatrixBlock< mType > const label mStart
 
ConstMatrixBlock< mType > const label const label const label const nStart
 
MatrixBlock< mType > const label const label const label nStart
 
ConstMatrixBlock< mType > const label const label const nStart
 
MatrixBlock< mType > const label const label nStart
 

Detailed Description

template<class Type>
class Foam::SymmetricSquareMatrix< Type >

A templated 2D square symmetric matrix of objects of <T>, where the n x n matrix dimension is known and used for subscript bounds checking, etc.

Source files

Definition at line 54 of file SymmetricSquareMatrix.H.

Constructor & Destructor Documentation

◆ SymmetricSquareMatrix() [1/6]

Construct null.

Definition at line 41 of file SymmetricSquareMatrixI.H.

◆ SymmetricSquareMatrix() [2/6]

SymmetricSquareMatrix ( const label  n)
inlineexplicit

Construct for given size (rows == cols)

Definition at line 48 of file SymmetricSquareMatrixI.H.

◆ SymmetricSquareMatrix() [3/6]

SymmetricSquareMatrix ( const label  n,
const  zero 
)
inline

Construct for given size (rows == cols) initializing all elements to zero

Definition at line 56 of file SymmetricSquareMatrixI.H.

◆ SymmetricSquareMatrix() [4/6]

SymmetricSquareMatrix ( const label  n,
const Type &  val 
)
inline

Construct for given size (rows == cols) initializing all elements to the given value

Definition at line 67 of file SymmetricSquareMatrixI.H.

◆ SymmetricSquareMatrix() [5/6]

SymmetricSquareMatrix ( const label  n,
const Identity< AnyType >   
)
inline

Construct for given size (rows == cols) setting the diagonal to one and off-diagonals to zero

Definition at line 79 of file SymmetricSquareMatrixI.H.

References n.

◆ SymmetricSquareMatrix() [6/6]

SymmetricSquareMatrix ( Istream is)
inlineexplicit

Construct from Istream.

Definition at line 94 of file SymmetricSquareMatrixI.H.

References CHECK_MATRIX_IS_SQUARE, Matrix< SymmetricSquareMatrix< Type >, Type >::m(), and Matrix< SymmetricSquareMatrix< Type >, Type >::n().

Here is the call graph for this function:

Member Function Documentation

◆ clone()

Foam::autoPtr< Foam::SymmetricSquareMatrix< Type > > clone ( ) const
inline

Clone.

Definition at line 104 of file SymmetricSquareMatrixI.H.

References Foam::New().

Here is the call graph for this function:

◆ operator=() [1/3]

void operator= ( const  zero)
inline

Assign all elements to zero.

Definition at line 113 of file SymmetricSquareMatrixI.H.

References Foam::Zero.

◆ operator=() [2/3]

void operator= ( const Type &  val)
inline

Assign all elements to value.

Definition at line 120 of file SymmetricSquareMatrixI.H.

References Foam::val.

◆ operator=() [3/3]

void operator= ( const Identity< AnyType >  )

Set to identity matrix.

Definition at line 118 of file SymmetricSquareMatrix.C.

References n, and Foam::Zero.


The documentation for this class was generated from the following files: