Loading...
Searching...
No Matches
RectangularMatrix< Type > Class Template Reference

A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements, derived from Matrix. More...

#include <RectangularMatrix.H>

Inheritance diagram for RectangularMatrix< Type >:
Collaboration diagram for RectangularMatrix< Type >:

Public Member Functions

 RectangularMatrix ()=default
 Default construct.
 RectangularMatrix (const RectangularMatrix &)=default
 Copy construct.
RectangularMatrixoperator= (const RectangularMatrix &)=default
 Copy assignment.
 RectangularMatrix (const label n)
 Construct a square matrix (rows == columns), uninitialised content.
 RectangularMatrix (const label m, const label n)
 Construct given number of rows/columns.
 RectangularMatrix (const label m, const label n, Foam::zero)
 Construct given number of rows/columns initializing all elements to zero.
 RectangularMatrix (const label m, const label n, const Type &val)
 Construct given number of rows/columns initializing all elements to the given value.
template<class AnyType>
 RectangularMatrix (const labelPair &dims, const Identity< AnyType >)
 Construct for given number of rows/columns initializing all elements to zero, and diagonal to one.
 RectangularMatrix (const labelPair &dims)
 Construct given number of rows/columns by using a label pair.
 RectangularMatrix (const labelPair &dims, Foam::zero)
 Construct given number of rows/columns by using a label pair and initializing all elements to zero.
 RectangularMatrix (const labelPair &dims, const Type &val)
 Construct given number of rows/columns by using a label pair and initializing all elements to the given value.
template<class MatrixType>
 RectangularMatrix (const ConstMatrixBlock< MatrixType > &mat)
 Construct from a block of another matrix.
template<class MatrixType>
 RectangularMatrix (const MatrixBlock< MatrixType > &mat)
 Construct from a block of another matrix.
 RectangularMatrix (const SquareMatrix< Type > &mat)
 Construct as copy of a square matrix.
 RectangularMatrix (Istream &is)
 Construct from Istream.
autoPtr< RectangularMatrix< Type > > clone () const
 Clone.
void operator= (RectangularMatrix< Type > &&mat)
 Move assignment.
void operator= (Foam::zero)
 Assign all elements to zero.
void operator= (const Type &val)
 Assign all elements to value.
Public Member Functions inherited from Matrix< RectangularMatrix< 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< RectangularMatrix< Type >, Type > > block (const label rowIndex, const label colIndex) const
Foam::MatrixBlock< Foam::Matrix< RectangularMatrix< 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< 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.
const Type & at (const label idx) const
 Linear addressing const 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.
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< RectangularMatrix< Type >, Type > &mat)
 Swap contents.
void transfer (Matrix< RectangularMatrix< 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.
RectangularMatrix< Type > T () const
 Return conjugate transpose of Matrix.
RectangularMatrix< 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< RectangularMatrix< Type >, Type > &mat)
 Copy assignment. Takes linear time.
void operator+= (const Matrix< RectangularMatrix< Type >, Type > &other)
 Matrix addition.
void operator-= (const Matrix< RectangularMatrix< 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.
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.
ConstMatrixBlock< mTypecol (const label m, const label mStart, const label nStart) const
 Deprecated(2019-04) - use subColumn().

Additional Inherited Members

Public Types inherited from Matrix< RectangularMatrix< Type >, Type >
typedef Matrix< RectangularMatrix< 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< RectangularMatrix< Type >, Type >
static const Matrix< RectangularMatrix< Type >, Type > & null () noexcept
 Return a null Matrix (reference to a nullObject). Behaves like a empty Matrix.

Detailed Description

template<class Type>
class Foam::RectangularMatrix< Type >

A templated (M x N) rectangular matrix of objects of <Type>, containing M*N elements, derived from Matrix.

See also
Test-RectangularMatrix.C
Source files

Definition at line 53 of file RectangularMatrix.H.

Constructor & Destructor Documentation

◆ RectangularMatrix() [1/14]

◆ RectangularMatrix() [2/14]

template<class Type>
RectangularMatrix ( const RectangularMatrix< Type > & )
default

Copy construct.

◆ RectangularMatrix() [3/14]

template<class Type>
RectangularMatrix ( const label n)
inlineexplicit

Construct a square matrix (rows == columns), uninitialised content.

Definition at line 36 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix(), Matrix< RectangularMatrix< Type >, Type >::n(), and RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [4/14]

template<class Type>
RectangularMatrix ( const label m,
const label n )
inline

Construct given number of rows/columns.

Definition at line 25 of file RectangularMatrixI.H.

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

Here is the call graph for this function:

◆ RectangularMatrix() [5/14]

template<class Type>
RectangularMatrix ( const label m,
const label n,
Foam::zero  )
inline

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

Definition at line 46 of file RectangularMatrixI.H.

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

Here is the call graph for this function:

◆ RectangularMatrix() [6/14]

template<class Type>
RectangularMatrix ( const label m,
const label n,
const Type & val )
inline

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

Definition at line 58 of file RectangularMatrixI.H.

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

Here is the call graph for this function:

◆ RectangularMatrix() [7/14]

template<class Type>
template<class AnyType>
RectangularMatrix ( const labelPair & dims,
const Identity< AnyType >  )
inline

Construct for given number of rows/columns initializing all elements to zero, and diagonal to one.

Definition at line 71 of file RectangularMatrixI.H.

References Pair< T >::first(), Foam::min(), Matrix< RectangularMatrix< Type >, Type >::operator()(), RectangularMatrix(), and Pair< T >::second().

Here is the call graph for this function:

◆ RectangularMatrix() [8/14]

template<class Type>
RectangularMatrix ( const labelPair & dims)
inlineexplicit

Construct given number of rows/columns by using a label pair.

Definition at line 89 of file RectangularMatrixI.H.

References RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [9/14]

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

Construct given number of rows/columns by using a label pair and initializing all elements to zero.

Definition at line 99 of file RectangularMatrixI.H.

References RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [10/14]

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

Construct given number of rows/columns by using a label pair and initializing all elements to the given value.

Definition at line 110 of file RectangularMatrixI.H.

References RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [11/14]

template<class Type>
template<class MatrixType>
RectangularMatrix ( const ConstMatrixBlock< MatrixType > & mat)
inline

Construct from a block of another matrix.

Definition at line 122 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix(), and RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [12/14]

template<class Type>
template<class MatrixType>
RectangularMatrix ( const MatrixBlock< MatrixType > & mat)
inline

Construct from a block of another matrix.

Definition at line 133 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix(), and RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [13/14]

template<class Type>
RectangularMatrix ( const SquareMatrix< Type > & mat)
inline

Construct as copy of a square matrix.

Definition at line 143 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix(), and RectangularMatrix().

Here is the call graph for this function:

◆ RectangularMatrix() [14/14]

template<class Type>
RectangularMatrix ( Istream & is)
inlineexplicit

Construct from Istream.

Definition at line 153 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix(), and RectangularMatrix().

Here is the call graph for this function:

Member Function Documentation

◆ operator=() [1/4]

template<class Type>
RectangularMatrix & operator= ( const RectangularMatrix< Type > & )
default

Copy assignment.

◆ clone()

template<class Type>
Foam::autoPtr< Foam::RectangularMatrix< Type > > clone ( ) const
inline

Clone.

Definition at line 161 of file RectangularMatrixI.H.

References Foam::New().

Here is the call graph for this function:

◆ operator=() [2/4]

template<class Type>
void operator= ( RectangularMatrix< Type > && mat)
inline

Move assignment.

Definition at line 170 of file RectangularMatrixI.H.

References RectangularMatrix(), and Matrix< RectangularMatrix< Type >, Type >::transfer().

Here is the call graph for this function:

◆ operator=() [3/4]

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

Assign all elements to zero.

Definition at line 180 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix().

Here is the call graph for this function:

◆ operator=() [4/4]

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

Assign all elements to value.

Definition at line 187 of file RectangularMatrixI.H.

References Matrix< RectangularMatrix< Type >, Type >::Matrix().

Here is the call graph for this function:

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