Loading...
Searching...
No Matches
Matrix< Form, Type > Class Template Reference

A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order: More...

#include <Matrix.H>

Inheritance diagram for Matrix< Form, Type >:

Public Types

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.

Public Member Functions

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< mTypeclone () 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< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1) const
 Return const column or column's subset of Matrix.
ConstMatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1) const
 Return const row or const row's subset of Matrix.
ConstMatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
 Return const sub-block of Matrix.
template<class VectorSpace>
ConstMatrixBlock< mTypeblock (const label rowIndex, const label colIndex) const
 Access Field as a ConstMatrixBlock.
MatrixBlock< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1)
 Return column or column's subset of Matrix.
MatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1)
 Return row or row's subset of Matrix.
MatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1)
 Return sub-block of Matrix.
template<class VectorSpace>
MatrixBlock< mTypeblock (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.
OstreamwriteMatrix (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< mTypeblock (const label m, const label n, const label mStart, const label nStart) const
 Deprecated(2019-04) - use subMatrix().
MatrixBlock< mTypeblock (const label m, const label n, const label mStart, const label nStart)
 Deprecated(2019-04) - use subMatrix().
ConstMatrixBlock< mTypecol (const label m, const label mStart, const label nStart) const
 Deprecated(2019-04) - use subColumn().
MatrixBlock< mTypecol (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

Static Public Member Functions

static const Matrix< Form, Type > & null () noexcept
 Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.

Detailed Description

template<class Form, class Type>
class Foam::Matrix< Form, Type >

A templated (m x n) matrix of objects of <T>. The layout is (mRows x nCols) - row-major order:

    (0,0)
      +---> j [nCols]
      |
      |
      v
      i [mRows]
Source files

Definition at line 76 of file Matrix.H.

Member Typedef Documentation

◆ mType

template<class Form, class Type>
typedef Matrix<Form, Type> mType

Matrix type.

Definition at line 118 of file Matrix.H.

◆ cmptType

template<class Form, class Type>
typedef Type cmptType

The value type the Matrix contains.

Definition at line 123 of file Matrix.H.

◆ value_type

template<class Form, class Type>
typedef Type value_type

The value type the Matrix contains.

Definition at line 128 of file Matrix.H.

◆ size_type

template<class Form, class Type>
typedef label size_type

The type to represent the size of a Matrix.

Definition at line 133 of file Matrix.H.

◆ iterator

template<class Form, class Type>
typedef Type* iterator

Random access iterator for traversing a Matrix.

Definition at line 138 of file Matrix.H.

◆ const_iterator

template<class Form, class Type>
typedef const Type* const_iterator

Random access iterator for traversing a Matrix.

Definition at line 143 of file Matrix.H.

Constructor & Destructor Documentation

◆ Matrix() [1/13]

template<class Form, class Type>
Matrix ( )
inlineconstexprnoexcept

Default construct (empty matrix).

Definition at line 43 of file MatrixI.H.

References Foam::noexcept.

Referenced by block(), Matrix(), Matrix(), Matrix(), Matrix(), Matrix(), Matrix(), Matrix(), null(), operator+=(), operator-=(), operator=(), operator=(), resize(), swap(), Tmul(), transfer(), and writeMatrix().

Here is the caller graph for this function:

◆ Matrix() [2/13]

template<class Form, class Type>
Matrix ( const label m,
const label n )

Construct given number of rows/columns, uninitialised content.

Definition at line 101 of file Matrix.C.

References checkSize(), m(), and n().

Here is the call graph for this function:

◆ Matrix() [3/13]

template<class Form, class Type>
Matrix ( const label m,
const label n,
Foam::zero  )

Construct with given number of rows/columns initializing all elements to zero.

Definition at line 114 of file Matrix.C.

References begin(), checkSize(), m(), n(), size(), and Foam::Zero.

Here is the call graph for this function:

◆ Matrix() [4/13]

template<class Form, class Type>
Matrix ( const label m,
const label n,
const Type & val )

Construct with given number of rows/columns initializing all elements to the given value.

Definition at line 129 of file Matrix.C.

References begin(), checkSize(), m(), n(), and size().

Here is the call graph for this function:

◆ Matrix() [5/13]

template<class Form, class Type>
Matrix ( const labelPair & dims)
inlineexplicit

Construct given number of rows/columns.

Definition at line 52 of file MatrixI.H.

References Matrix().

Here is the call graph for this function:

◆ Matrix() [6/13]

template<class Form, class Type>
Matrix ( const labelPair & dims,
Foam::zero  )
inline

Construct given number of rows/columns initializing all elements to zero.

Definition at line 59 of file MatrixI.H.

References Matrix().

Here is the call graph for this function:

◆ Matrix() [7/13]

template<class Form, class Type>
Matrix ( const labelPair & dims,
const Type & val )
inline

Construct with given number of rows/columns initializing all elements to the given value.

Definition at line 66 of file MatrixI.H.

References Matrix().

Here is the call graph for this function:

◆ Matrix() [8/13]

template<class Form, class Type>
Matrix ( const Matrix< Form, Type > & mat)

Copy construct.

Definition at line 144 of file Matrix.C.

References cdata(), and Matrix().

Here is the call graph for this function:

◆ Matrix() [9/13]

template<class Form, class Type>
Matrix ( Matrix< Form, Type > && mat)

Move construct.

Definition at line 160 of file Matrix.C.

References Matrix().

Here is the call graph for this function:

◆ Matrix() [10/13]

template<class Form, class Type>
template<class Form2>
Matrix ( const Matrix< Form2, Type > & mat)
explicit

Copy constructor from Matrix of a different form.

Definition at line 174 of file Matrix.C.

References cdata(), m(), Matrix(), and n().

Here is the call graph for this function:

◆ Matrix() [11/13]

template<class Form, class Type>
template<class MatrixType>
Matrix ( const ConstMatrixBlock< MatrixType > & Mb)
inline

Construct from a block of another Matrix.

Definition at line 191 of file Matrix.C.

References m(), and n().

Here is the call graph for this function:

◆ Matrix() [12/13]

template<class Form, class Type>
template<class MatrixType>
Matrix ( const MatrixBlock< MatrixType > & Mb)
inline

Construct from a block of another Matrix.

Definition at line 214 of file Matrix.C.

References m(), and n().

Here is the call graph for this function:

◆ Matrix() [13/13]

template<class Form, class Type>
Matrix ( Istream & is)
explicit

Construct from Istream.

Definition at line 30 of file MatrixIO.C.

References Matrix(), and readMatrix().

Here is the call graph for this function:

◆ ~Matrix()

template<class Form, class Type>
~Matrix ( )

Destructor.

Definition at line 238 of file Matrix.C.

Member Function Documentation

◆ null()

template<class Form, class Type>
const Matrix< Form, Type > & null ( )
inlinestaticnoexcept

Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.

Definition at line 152 of file Matrix.H.

References Matrix(), Foam::noexcept, and Foam::NullObjectRef().

Here is the call graph for this function:

◆ clone()

template<class Form, class Type>
Foam::autoPtr< Foam::Matrix< Form, Type > > clone ( ) const
inline

Clone.

Definition at line 74 of file MatrixI.H.

References Foam::New().

Here is the call graph for this function:

◆ mRows()

template<class Form, class Type>
label mRows ( ) const
inlinenoexcept

The number of rows.

Definition at line 251 of file Matrix.H.

References mRows(), and Foam::noexcept.

Referenced by mRows().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nRows()

template<class Form, class Type>
label nRows ( ) const
inlinenoexcept

The number of rows.

Definition at line 256 of file Matrix.H.

References Foam::noexcept.

Referenced by LUscalarMatrix::LUscalarMatrix(), and writeMatrix().

Here is the caller graph for this function:

◆ m()

◆ nCols()

template<class Form, class Type>
label nCols ( ) const
inlinenoexcept

The number of columns.

Definition at line 266 of file Matrix.H.

References Foam::noexcept.

Referenced by LUscalarMatrix::LUscalarMatrix(), and writeMatrix().

Here is the caller graph for this function:

◆ n()

◆ empty()

template<class Form, class Type>
bool empty ( ) const
inlinenoexcept

Return true if Matrix is empty (i.e., size() is zero).

Definition at line 97 of file MatrixI.H.

References Foam::noexcept.

Referenced by Foam::max(), and Foam::min().

Here is the caller graph for this function:

◆ size()

template<class Form, class Type>
Foam::label size ( ) const
inlinenoexcept

The number of elements in Matrix (m*n).

Definition at line 83 of file MatrixI.H.

References Foam::noexcept.

Referenced by at(), at(), Matrix(), Matrix(), operator=(), operator=(), readMatrix(), release(), uniform(), and writeMatrix().

Here is the caller graph for this function:

◆ sizes()

template<class Form, class Type>
Foam::labelPair sizes ( ) const
inlinenoexcept

Return row/column sizes.

Definition at line 90 of file MatrixI.H.

References Foam::noexcept.

Referenced by Foam::applyPermutation(), Foam::operator*(), Foam::operator+(), Foam::operator-(), Foam::operator-(), Foam::operator-(), and Foam::operator/().

Here is the caller graph for this function:

◆ cdata()

template<class Form, class Type>
const Type * cdata ( ) const
inlinenoexcept

Return const pointer to the first data element, which can also be used to address into Matrix contents.

Definition at line 176 of file MatrixI.H.

References Foam::noexcept.

Referenced by Matrix(), and Matrix().

Here is the caller graph for this function:

◆ data()

template<class Form, class Type>
Type * data ( )
inlinenoexcept

Return pointer to the first data element, which can also be used to address into Matrix contents.

Definition at line 183 of file MatrixI.H.

References Foam::noexcept.

◆ cdata_bytes()

template<class Form, class Type>
const char * cdata_bytes ( ) const
inlinenoexcept

Return pointer to the underlying array serving as data storage, reinterpreted as byte data.

Note
Only meaningful for contiguous data

Definition at line 190 of file MatrixI.H.

References Foam::noexcept.

Referenced by writeMatrix().

Here is the caller graph for this function:

◆ data_bytes()

template<class Form, class Type>
char * data_bytes ( )
inlinenoexcept

Return pointer to the underlying array serving as data storage, reinterpreted as byte data.

Note
Only meaningful for contiguous data

Definition at line 197 of file MatrixI.H.

References Foam::noexcept.

Referenced by readMatrix().

Here is the caller graph for this function:

◆ size_bytes()

template<class Form, class Type>
std::streamsize size_bytes ( ) const
inlinenoexcept

Number of contiguous bytes for the Matrix data, no runtime check that the type is actually contiguous.

Note
Only meaningful for contiguous data

Definition at line 204 of file MatrixI.H.

References Foam::noexcept.

Referenced by readMatrix(), and writeMatrix().

Here is the caller graph for this function:

◆ byteSize()

template<class Form, class Type>
std::streamsize byteSize ( ) const

Number of contiguous bytes for the Matrix data, runtime FatalError if type is not contiguous.

Definition at line 501 of file Matrix.C.

References Foam::is_contiguous_v.

◆ rowData() [1/2]

template<class Form, class Type>
const Type * rowData ( const label irow) const
inline

Return const pointer to data in the specified row.

Subscript checking only with FULLDEBUG

Definition at line 211 of file MatrixI.H.

References checki().

Here is the call graph for this function:

◆ rowData() [2/2]

template<class Form, class Type>
Type * rowData ( const label irow)
inline

Return pointer to data in the specified row.

Subscript checking only with FULLDEBUG

Definition at line 221 of file MatrixI.H.

References checki().

Here is the call graph for this function:

◆ at() [1/2]

template<class Form, class Type>
const Type & at ( const label idx) const
inline

Linear addressing const element access.

Subscript checking only with FULLDEBUG

Definition at line 231 of file MatrixI.H.

References size().

Here is the call graph for this function:

◆ at() [2/2]

template<class Form, class Type>
Type & at ( const label idx)
inline

Linear addressing element access.

Subscript checking only with FULLDEBUG

Definition at line 246 of file MatrixI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and size().

Here is the call graph for this function:

◆ subColumn() [1/2]

template<class Form, class Type>
Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > subColumn ( const label colIndex,
const label rowIndex = 0,
label len = -1 ) const
inline

Return const column or column's subset of Matrix.

Return entire column by its index: M.subColumn(a); Return subset of a column starting from rowIndex: M.subColumn(a, b); Return subset of a column starting from rowIndex with szRows elems: M.subColumn(a, b, c);

Definition at line 262 of file MatrixI.H.

Referenced by Foam::applyPermutation(), SquareMatrix< Type >::applyPermutation(), block(), col(), and col().

Here is the caller graph for this function:

◆ subRow() [1/2]

template<class Form, class Type>
Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > subRow ( const label rowIndex,
const label colIndex = 0,
label len = -1 ) const
inline

Return const row or const row's subset of Matrix.

Return entire row by its index: M.subRow(a); Return subset of a row starting from columnIndex: M.subRow(a,b); Return subset of a row starting from columnIndex with szCols elems: M.subRow(a, b, c);

Definition at line 287 of file MatrixI.H.

Referenced by block().

Here is the caller graph for this function:

◆ subMatrix() [1/2]

template<class Form, class Type>
Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > subMatrix ( const label rowIndex,
const label colIndex,
label szRows = -1,
label szCols = -1 ) const
inline

Return const sub-block of Matrix.

Sub-block starting at columnIndex & rowIndex indices

Definition at line 312 of file MatrixI.H.

Referenced by block(), block(), and block().

Here is the caller graph for this function:

◆ block() [1/6]

template<class Form, class Type>
template<class VectorSpace>
ConstMatrixBlock< mType > block ( const label rowIndex,
const label colIndex ) const
inline

Access Field as a ConstMatrixBlock.

References block(), subColumn(), subMatrix(), and subRow().

Referenced by block(), block(), block(), and block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ subColumn() [2/2]

template<class Form, class Type>
Foam::MatrixBlock< Foam::Matrix< Form, Type > > subColumn ( const label colIndex,
const label rowIndex = 0,
label len = -1 )
inline

Return column or column's subset of Matrix.

Definition at line 356 of file MatrixI.H.

◆ subRow() [2/2]

template<class Form, class Type>
Foam::MatrixBlock< Foam::Matrix< Form, Type > > subRow ( const label rowIndex,
const label colIndex = 0,
label len = -1 )
inline

Return row or row's subset of Matrix.

Definition at line 381 of file MatrixI.H.

◆ subMatrix() [2/2]

template<class Form, class Type>
Foam::MatrixBlock< Foam::Matrix< Form, Type > > subMatrix ( const label rowIndex,
const label colIndex,
label szRows = -1,
label szCols = -1 )
inline

Return sub-block of Matrix.

Definition at line 406 of file MatrixI.H.

◆ block() [2/6]

template<class Form, class Type>
template<class VectorSpace>
MatrixBlock< mType > block ( const label rowIndex,
const label colIndex )
inline

◆ checki()

template<class Form, class Type>
void checki ( const label irow) const
inline

Check index i is within valid range [0, m).

Definition at line 104 of file MatrixI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Referenced by block(), operator()(), operator()(), operator[](), operator[](), rowData(), and rowData().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkj()

template<class Form, class Type>
void checkj ( const label jcol) const
inline

Check index j is within valid range [0, n).

Definition at line 122 of file MatrixI.H.

References Foam::abort(), Foam::FatalError, and FatalErrorInFunction.

Referenced by block(), operator()(), and operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkSize()

template<class Form, class Type>
void checkSize ( ) const
inline

Check that dimensions are positive, non-zero.

Definition at line 140 of file MatrixI.H.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, and Foam::nl.

Referenced by block(), Matrix(), Matrix(), and Matrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uniform()

template<class Form, class Type>
bool uniform ( ) const
inline

True if all entries have identical values, and Matrix is non-empty.

Definition at line 153 of file MatrixI.H.

References size().

Referenced by block(), and writeMatrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clear()

template<class Form, class Type>
void clear ( )

Clear Matrix, i.e. set sizes to zero.

Definition at line 248 of file Matrix.C.

References Foam::ListPolicy::deallocate().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ release()

template<class Form, class Type>
Foam::List< Type > release ( )

Release storage management of Matrix contents by transferring management to a List.

Definition at line 260 of file Matrix.C.

References clear(), size(), and UList< T >::swap().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ swap()

template<class Form, class Type>
void swap ( Matrix< Form, Type > & mat)

Swap contents.

Definition at line 280 of file Matrix.C.

References Matrix().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transfer()

template<class Form, class Type>
void transfer ( Matrix< Form, Type > & mat)

Transfer the contents of the argument Matrix into this Matrix and annul the argument Matrix.

Definition at line 294 of file Matrix.C.

References clear(), and Matrix().

Referenced by block(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize()

template<class Form, class Type>
void resize ( const label m,
const label n )

Change Matrix dimensions, preserving the elements.

Definition at line 314 of file Matrix.C.

References m(), Matrix(), Foam::min(), and n().

Referenced by block(), and Foam::MatrixTools::pinv().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_nocopy()

template<class Form, class Type>
void resize_nocopy ( const label mrow,
const label ncol )

Change Matrix dimensions without preserving existing content.

Definition at line 339 of file Matrix.C.

References clear().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setSize()

template<class Form, class Type>
void setSize ( const label m,
const label n )
inline

Change Matrix dimensions, preserving the elements.

Definition at line 449 of file MatrixI.H.

References m(), n(), and resize().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ shallowResize()

template<class Form, class Type>
void shallowResize ( const label m,
const label n )
inline

Resize Matrix without reallocating storage (unsafe).

Definition at line 456 of file MatrixI.H.

References m(), and n().

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ round()

template<class Form, class Type>
void round ( const scalar tol = SMALL)

Round elements with magnitude smaller than tol (SMALL) to zero.

Definition at line 369 of file Matrix.C.

References Foam::mag(), and Foam::Zero.

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ T()

template<class Form, class Type>
Form T ( ) const

Return conjugate transpose of Matrix.

Definition at line 382 of file Matrix.C.

References Foam::Detail::conj(), m(), and n.

Referenced by block(), and chemPointISAT< CompType, ThermoType >::chemPointISAT().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ transpose()

template<class Form, class Type>
Form transpose ( ) const

Return non-conjugate transpose of Matrix.

Definition at line 399 of file Matrix.C.

References m(), and n.

Referenced by block().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Amul() [1/3]

template<class Form, class Type>
Foam::tmp< Foam::Field< Type > > Amul ( const UList< Type > & x) const
inline

Right-multiply Matrix by a column vector (A * x).

Definition at line 464 of file MatrixI.H.

Referenced by Amul(), block(), Matrix< RectangularMatrix< Type >, Type >::operator()(), and Foam::operator*().

Here is the caller graph for this function:

◆ Amul() [2/3]

template<class Form, class Type>
template<class Addr>
tmp< Field< Type > > Amul ( const IndirectListBase< Type, Addr > & x) const
inline

Right-multiply Matrix by a column vector (A * x).

References Amul(), Tmul(), and x.

Here is the call graph for this function:

◆ Tmul() [1/3]

template<class Form, class Type>
Foam::tmp< Foam::Field< Type > > Tmul ( const UList< Type > & x) const
inline

Left-multiply Matrix by a row vector (x * A).

Definition at line 485 of file MatrixI.H.

References x.

Referenced by Amul(), Foam::operator*(), Foam::operator*(), and Tmul().

Here is the caller graph for this function:

◆ Tmul() [2/3]

template<class Form, class Type>
template<class Addr>
tmp< Field< Type > > Tmul ( const IndirectListBase< Type, Addr > & x) const
inline

Left-multiply Matrix by a row vector (x * A).

References begin(), cbegin(), cend(), columnNorm(), diag(), end(), Foam::FOAM_DEPRECATED_FOR(), Matrix(), Foam::noexcept, norm(), os(), readMatrix(), s(), Tmul(), trace(), writeMatrix(), and x.

Here is the call graph for this function:

◆ diag() [1/2]

template<class Form, class Type>
Foam::List< Type > diag ( ) const

Extract the diagonal elements. Method may change in the future.

Definition at line 416 of file Matrix.C.

References Foam::min().

Referenced by fvMatrixExpression< E, DiagExpr, UpperExpr, LowerExpr, FaceFluxExpr, SourceExpr >::evaluate(), and Tmul().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ diag() [2/2]

template<class Form, class Type>
void diag ( const UList< Type > & list)

Assign diagonal of Matrix.

Definition at line 432 of file Matrix.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Foam::min(), and UList< T >::size().

Here is the call graph for this function:

◆ trace()

template<class Form, class Type>
Type trace ( ) const

Return the trace.

Definition at line 453 of file Matrix.C.

References Foam::min(), and Foam::Zero.

Referenced by Tmul().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ columnNorm()

template<class Form, class Type>
Foam::scalar columnNorm ( const label colIndex,
const bool noSqrt = false ) const

Return L2-Norm of chosen column.

Optional without sqrt for parallel usage.

Definition at line 469 of file Matrix.C.

References Foam::magSqr(), and Foam::sqrt().

Referenced by Tmul().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ norm()

template<class Form, class Type>
Foam::scalar norm ( const bool noSqrt = false) const

Return Frobenius norm of Matrix.

Optional without sqrt for parallel usage.

Definition at line 487 of file Matrix.C.

Referenced by Tmul().

Here is the caller graph for this function:

◆ operator[]() [1/2]

template<class Form, class Type>
const Type * operator[] ( const label irow) const
inline

Return const pointer to data in the specified row - rowData().

Subscript checking only with FULLDEBUG

Definition at line 588 of file MatrixI.H.

References checki().

Referenced by LUscalarMatrix::LUscalarMatrix().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator[]() [2/2]

template<class Form, class Type>
Type * operator[] ( const label irow)
inline

Return pointer to data in the specified row - rowData().

Subscript checking only with FULLDEBUG

Definition at line 598 of file MatrixI.H.

References checki().

Here is the call graph for this function:

◆ operator()() [1/2]

template<class Form, class Type>
const Type & operator() ( const label irow,
const label jcol ) const
inline

(i, j) const element access operator

Subscript checking only with FULLDEBUG

Definition at line 558 of file MatrixI.H.

References checki(), and checkj().

Here is the call graph for this function:

◆ operator()() [2/2]

template<class Form, class Type>
Type & operator() ( const label irow,
const label jcol )
inline

(i, j) element access operator

Subscript checking only with FULLDEBUG

Definition at line 573 of file MatrixI.H.

References checki(), and checkj().

Here is the call graph for this function:

◆ operator=() [1/6]

template<class Form, class Type>
void operator= ( const Matrix< Form, Type > & mat)

Copy assignment. Takes linear time.

Definition at line 516 of file Matrix.C.

References Matrix().

Here is the call graph for this function:

◆ operator=() [2/6]

template<class Form, class Type>
void operator= ( Matrix< Form, Type > && mat)

Move assignment.

Definition at line 539 of file Matrix.C.

References Matrix(), and transfer().

Here is the call graph for this function:

◆ operator=() [3/6]

template<class Form, class Type>
template<class MatrixType>
void operator= ( const ConstMatrixBlock< MatrixType > & Mb)

Assignment to a block of another Matrix.

Definition at line 551 of file Matrix.C.

◆ operator=() [4/6]

template<class Form, class Type>
template<class MatrixType>
void operator= ( const MatrixBlock< MatrixType > & Mb)

Assignment to a block of another Matrix.

Definition at line 568 of file Matrix.C.

◆ operator=() [5/6]

template<class Form, class Type>
void operator= ( Foam::zero )

Assignment of all elements to zero.

Definition at line 591 of file Matrix.C.

References begin(), size(), and Foam::Zero.

Here is the call graph for this function:

◆ operator=() [6/6]

template<class Form, class Type>
void operator= ( const Type & val)

Assignment of all elements to the given value.

Definition at line 584 of file Matrix.C.

References begin(), and size().

Here is the call graph for this function:

◆ operator+=() [1/2]

template<class Form, class Type>
void operator+= ( const Matrix< Form, Type > & other)

Matrix addition.

Definition at line 598 of file Matrix.C.

References Foam::abort(), cbegin(), Foam::FatalError, FatalErrorInFunction, m(), Matrix(), n(), n, and Foam::nl.

Here is the call graph for this function:

◆ operator-=() [1/2]

template<class Form, class Type>
void operator-= ( const Matrix< Form, Type > & other)

Matrix subtraction.

Definition at line 628 of file Matrix.C.

References Matrix().

Here is the call graph for this function:

◆ operator+=() [2/2]

template<class Form, class Type>
void operator+= ( const Type & s)

Matrix scalar addition.

Definition at line 658 of file Matrix.C.

References s().

Here is the call graph for this function:

◆ operator-=() [2/2]

template<class Form, class Type>
void operator-= ( const Type & s)

Matrix scalar subtraction.

Definition at line 668 of file Matrix.C.

References s().

Here is the call graph for this function:

◆ operator*=()

template<class Form, class Type>
void operator*= ( const Type & s)

Matrix scalar multiplication.

Definition at line 678 of file Matrix.C.

References s().

Here is the call graph for this function:

◆ operator/=()

template<class Form, class Type>
void operator/= ( const Type & s)

Matrix scalar division.

Definition at line 688 of file Matrix.C.

References s().

Here is the call graph for this function:

◆ begin() [1/2]

template<class Form, class Type>
Foam::Matrix< Form, Type >::iterator begin ( )
inlinenoexcept

Return an iterator to begin traversing a Matrix.

Definition at line 509 of file MatrixI.H.

References Foam::noexcept.

Referenced by Matrix(), Matrix(), operator=(), operator=(), readMatrix(), and Tmul().

Here is the caller graph for this function:

◆ end() [1/2]

template<class Form, class Type>
Foam::Matrix< Form, Type >::iterator end ( )
inlinenoexcept

Return an iterator to end traversing a Matrix.

Definition at line 517 of file MatrixI.H.

References Foam::noexcept.

Referenced by Foam::operator-(), Foam::operator-(), Foam::operator/(), and Tmul().

Here is the caller graph for this function:

◆ cbegin()

template<class Form, class Type>
Foam::Matrix< Form, Type >::const_iterator cbegin ( ) const
inlinenoexcept

Return const_iterator to begin traversing a constant Matrix.

Definition at line 525 of file MatrixI.H.

References Foam::noexcept.

Referenced by STDMD::initialise(), Foam::max(), Foam::min(), Foam::operator*(), Foam::operator+(), operator+=(), Foam::operator-(), Foam::operator-(), Foam::operator-(), Foam::operator/(), Tmul(), and writeMatrix().

Here is the caller graph for this function:

◆ cend()

template<class Form, class Type>
Foam::Matrix< Form, Type >::const_iterator cend ( ) const
inlinenoexcept

Return const_iterator to end traversing a constant Matrix.

Definition at line 533 of file MatrixI.H.

References Foam::noexcept.

Referenced by Foam::max(), Foam::min(), Foam::operator*(), Foam::operator+(), Foam::operator-(), and Tmul().

Here is the caller graph for this function:

◆ begin() [2/2]

template<class Form, class Type>
Foam::Matrix< Form, Type >::const_iterator begin ( ) const
inlinenoexcept

Return const_iterator to begin traversing a constant Matrix.

Definition at line 541 of file MatrixI.H.

References Foam::noexcept.

◆ end() [2/2]

template<class Form, class Type>
Foam::Matrix< Form, Type >::const_iterator end ( ) const
inlinenoexcept

Return const_iterator to end traversing a constant Matrix.

Definition at line 549 of file MatrixI.H.

References Foam::noexcept.

◆ readMatrix()

template<class Form, class Type>
bool readMatrix ( Istream & is)

◆ writeMatrix()

template<class Form, class Type>
Foam::Ostream & writeMatrix ( Ostream & os,
const label shortLen = 0 ) const

Write Matrix, with line-breaks in ASCII when length exceeds shortLen.

Using '0' suppresses line-breaks entirely.

Definition at line 130 of file MatrixIO.C.

References token::BEGIN_BLOCK, token::BEGIN_LIST, IOstreamOption::BINARY, cbegin(), cdata_bytes(), token::END_BLOCK, token::END_LIST, FUNCTION_NAME, Foam::is_contiguous_v, Matrix(), nCols(), Foam::nl, nRows(), os(), size(), size_bytes(), token::SPACE, and uniform().

Referenced by Foam::operator<<(), and Tmul().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ v() [1/2]

template<class Form, class Type>
const Type * v ( ) const
inline

Deprecated(2019-04) raw data pointer, const access.

Deprecated
(2019-04) - use cdata() method

Definition at line 751 of file Matrix.H.

References v().

Referenced by v(), and v().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ v() [2/2]

template<class Form, class Type>
Type * v ( )
inline

Deprecated(2019-04) raw data pointer, non-const access.

Deprecated
(2019-04) - use data() method

Definition at line 762 of file Matrix.H.

References v().

Here is the call graph for this function:

◆ block() [3/6]

template<class Form, class Type>
ConstMatrixBlock< mType > block ( const label m,
const label n,
const label mStart,
const label nStart ) const
inline

Deprecated(2019-04) - use subMatrix().

Deprecated
(2019-04) - use subMatrix()

Definition at line 773 of file Matrix.H.

References block(), m(), n(), and subMatrix().

Here is the call graph for this function:

◆ block() [4/6]

template<class Form, class Type>
MatrixBlock< mType > block ( const label m,
const label n,
const label mStart,
const label nStart )
inline

Deprecated(2019-04) - use subMatrix().

Deprecated
(2019-04) - use subMatrix()

Definition at line 790 of file Matrix.H.

References block(), m(), n(), and subMatrix().

Here is the call graph for this function:

◆ col() [1/4]

template<class Form, class Type>
ConstMatrixBlock< mType > col ( const label m,
const label mStart,
const label nStart ) const
inline

Deprecated(2019-04) - use subColumn().

Deprecated
(2019-04) - use subColumn()

Definition at line 808 of file Matrix.H.

References col(), m(), and subColumn().

Referenced by col(), and col().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ col() [2/4]

template<class Form, class Type>
MatrixBlock< mType > col ( const label m,
const label mStart,
const label nStart )
inline

Deprecated(2019-04) - use subColumn().

Deprecated
(2019-04) - use subColumn()

Definition at line 824 of file Matrix.H.

References col(), m(), and subColumn().

Here is the call graph for this function:

◆ col() [3/4]

template<class Form, class Type>
void col ( const label m,
const label rowStart ) const
delete

Deleted(2019-04) - use subColumn().

Deprecated
(2019-04) - use subColumn()

References m().

Here is the call graph for this function:

◆ col() [4/4]

template<class Form, class Type>
void col ( const label m,
const label rowStart )
delete

Deleted(2019-04) - use subColumn().

Deprecated
(2019-04) - use subColumn()

References m().

Here is the call graph for this function:

◆ AmulImpl()

template<class Form, class Type>
template<class ListType>
Foam::tmp< Foam::Field< Type > > AmulImpl ( const ListType & x) const

Definition at line 29 of file Matrix.C.

◆ TmulImpl()

template<class Form, class Type>
template<class ListType>
Foam::tmp< Foam::Field< Type > > TmulImpl ( const ListType & x) const

Definition at line 64 of file Matrix.C.

◆ block() [5/6]

template<class Form, class Type>
template<class VectorSpace>
Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > block ( const label rowIndex,
const label colIndex ) const
inline

Definition at line 337 of file MatrixI.H.

◆ block() [6/6]

template<class Form, class Type>
template<class VectorSpace>
Foam::MatrixBlock< Foam::Matrix< Form, Type > > block ( const label rowIndex,
const label colIndex )
inline

Definition at line 431 of file MatrixI.H.

◆ Amul() [3/3]

template<class Form, class Type>
template<class Addr>
Foam::tmp< Foam::Field< Type > > Amul ( const IndirectListBase< Type, Addr > & x) const
inline

Definition at line 475 of file MatrixI.H.

◆ Tmul() [3/3]

template<class Form, class Type>
template<class Addr>
Foam::tmp< Foam::Field< Type > > Tmul ( const IndirectListBase< Type, Addr > & x) const
inline

Definition at line 496 of file MatrixI.H.


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