Matrix< Form, Type > Class Template Reference

A templated (m x n) matrix of objects of <T>. More...

Inheritance diagram for Matrix< Form, Type >:

Public Types

typedef Matrix< Form, Type > mType
 Matrix type. More...
 
typedef Type cmptType
 Component type. More...
 

Public Member Functions

 Matrix ()
 Null constructor. More...
 
 Matrix (const label m, const label n)
 Construct given number of rows and columns. More...
 
 Matrix (const label m, const label n, const zero)
 Construct with given number of rows and columns. More...
 
 Matrix (const label m, const label n, const Type &)
 Construct with given number of rows and columns. More...
 
template<class InputIterator >
 Matrix (const label m, const label n, InputIterator first, InputIterator last)
 Construct with given number of rows and columns. More...
 
 Matrix (const label m, const label n, std::initializer_list< Type >)
 Construct with given number of rows and columns and initialiser list. More...
 
 Matrix (std::initializer_list< std::initializer_list< Type >>)
 Construct from initialiser list list. More...
 
 Matrix (const mType &)
 Copy constructor. More...
 
template<class Form2 >
 Matrix (const Matrix< Form2, Type > &)
 Copy constructor from matrix of a different form. More...
 
template<class MatrixType >
 Matrix (const ConstMatrixBlock< MatrixType > &)
 Construct from a block of another matrix. More...
 
template<class MatrixType >
 Matrix (const MatrixBlock< MatrixType > &)
 Construct from a block of another matrix. More...
 
template<class MSForm , direction Mrows, direction Ncols>
 Matrix (const MatrixSpace< MSForm, Type, Mrows, Ncols > &)
 
 Matrix (Istream &)
 Construct from Istream. More...
 
autoPtr< mTypeclone () const
 Clone. More...
 
 ~Matrix ()
 Destructor. More...
 
label m () const
 Return the number of rows. More...
 
label n () const
 Return the number of columns. More...
 
label size () const
 Return the number of elements in matrix (m*n) More...
 
const Type * v () const
 Return element vector of the constant Matrix. More...
 
Type * v ()
 Return element vector of the Matrix. More...
 
ConstMatrixBlock< mTypeblock (const label m, const label n, const label mStart, const label nStart) const
 
template<class VectorSpace >
ConstMatrixBlock< mTypeblock (const label mStart, const label nStart) const
 
ConstMatrixBlock< mTypecol (const label m, const label rowStart) const
 
ConstMatrixBlock< mTypecol (const label m, const label mStart, const label nStart) const
 
MatrixBlock< mTypeblock (const label m, const label n, const label mStart, const label nStart)
 
template<class VectorSpace >
MatrixBlock< mTypeblock (const label mStart, const label nStart)
 
MatrixBlock< mTypecol (const label m, const label rowStart)
 
MatrixBlock< mTypecol (const label m, const label mStart, const label nStart)
 
void checki (const label i) const
 Check index i is within valid range (0 ... m-1). More...
 
void checkj (const label j) const
 Check index j is within valid range (0 ... n-1). More...
 
void clear ()
 Clear the Matrix, i.e. set sizes to zero. More...
 
void transfer (mType &)
 Transfer the contents of the argument Matrix into this Matrix. More...
 
void setSize (const label m, const label n)
 Resize the matrix preserving the elements. More...
 
void shallowResize (const label m, const label n)
 Resize the matrix without reallocating storage (unsafe) More...
 
Form T () const
 Return the transpose of the matrix. More...
 
Type * operator[] (const label)
 Return subscript-checked row of Matrix. More...
 
const Type * operator[] (const label) const
 Return subscript-checked row of constant Matrix. More...
 
const Type & operator() (const label i, const label j) const
 (i, j) const element access operator More...
 
Type & operator() (const label i, const label j)
 (i, j) element access operator More...
 
void operator= (const mType &)
 Assignment operator. Takes linear time. More...
 
template<class MatrixType >
void operator= (const ConstMatrixBlock< MatrixType > &)
 Assignment to a block of another matrix. More...
 
template<class MatrixType >
void operator= (const MatrixBlock< MatrixType > &)
 Assignment to a block of another matrix. More...
 
void operator= (const zero)
 Assignment of all elements to zero. More...
 
void operator= (const Type &)
 Assignment of all elements to the given value. More...
 
template<class VectorSpace >
Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > block (const label mStart, const label nStart) const
 
template<class VectorSpace >
Foam::MatrixBlock< Foam::Matrix< Form, Type > > block (const label mStart, const label nStart)
 

Static Public Member Functions

static const mTypenull ()
 Return a null Matrix. More...
 

Friends

Istreamoperator>> (Istream &, mType &)
 Read Matrix from Istream, discarding contents of existing Matrix. More...
 
Ostreamoperator (Ostream &, const mType &)
 Write Matrix to Ostream. More...
 

Detailed Description

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

A templated (m x n) matrix of objects of <T>.

Source files

Definition at line 82 of file Matrix.H.

Member Typedef Documentation

◆ mType

typedef Matrix<Form, Type> mType

Matrix type.

Definition at line 99 of file Matrix.H.

◆ cmptType

typedef Type cmptType

Component type.

Definition at line 102 of file Matrix.H.

Constructor & Destructor Documentation

◆ Matrix() [1/13]

Matrix
inline

Null constructor.

Definition at line 31 of file MatrixI.H.

◆ Matrix() [2/13]

Matrix ( const label  m,
const label  n 
)

Construct given number of rows and columns.

Definition at line 44 of file Matrix.C.

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

Here is the call graph for this function:

◆ Matrix() [3/13]

Matrix ( const label  m,
const label  n,
const  zero 
)

Construct with given number of rows and columns.

initialising all elements to zero

Definition at line 62 of file Matrix.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, Matrix< Form, Type >::size(), and Foam::Zero.

Here is the call graph for this function:

◆ Matrix() [4/13]

Matrix ( const label  m,
const label  n,
const Type &  s 
)

Construct with given number of rows and columns.

initialising all elements to the given value

Definition at line 89 of file Matrix.C.

References Foam::abort(), Foam::FatalError, FatalErrorInFunction, s(), and Matrix< Form, Type >::size().

Here is the call graph for this function:

◆ Matrix() [5/13]

Matrix ( const label  m,
const label  n,
InputIterator  first,
InputIterator  last 
)

Construct with given number of rows and columns.

and start and end iterators

Definition at line 117 of file Matrix.C.

◆ Matrix() [6/13]

Matrix ( const label  m,
const label  n,
std::initializer_list< Type >  lst 
)

Construct with given number of rows and columns and initialiser list.

Definition at line 161 of file Matrix.C.

◆ Matrix() [7/13]

Matrix ( std::initializer_list< std::initializer_list< Type >>  lstLst)

Construct from initialiser list list.

Definition at line 173 of file Matrix.C.

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

Here is the call graph for this function:

◆ Matrix() [8/13]

Matrix ( const mType M)

Copy constructor.

Definition at line 216 of file Matrix.C.

References M, and Matrix< Form, Type >::size().

Here is the call graph for this function:

◆ Matrix() [9/13]

Matrix ( const Matrix< Form2, Type > &  M)
explicit

Copy constructor from matrix of a different form.

Definition at line 237 of file Matrix.C.

References M, and Matrix< Form, Type >::size().

Here is the call graph for this function:

◆ Matrix() [10/13]

Matrix ( const ConstMatrixBlock< MatrixType > &  Mb)

Construct from a block of another matrix.

Definition at line 258 of file Matrix.C.

◆ Matrix() [11/13]

Matrix ( const MatrixBlock< MatrixType > &  Mb)

Construct from a block of another matrix.

Definition at line 280 of file Matrix.C.

◆ Matrix() [12/13]

Matrix ( const MatrixSpace< MSForm, Type, Mrows, Ncols > &  Ms)

Definition at line 302 of file Matrix.C.

◆ Matrix() [13/13]

Matrix ( Istream is)

Construct from Istream.

Definition at line 35 of file MatrixIO.C.

References Matrix< Form, Type >::operator>>.

◆ ~Matrix()

Destructor.

Definition at line 325 of file Matrix.C.

Member Function Documentation

◆ null()

const Foam::Matrix< Form, Type > & null
inlinestatic

Return a null Matrix.

Definition at line 50 of file MatrixI.H.

◆ clone()

Foam::autoPtr< Foam::Matrix< Form, Type > > clone
inline

Clone.

Definition at line 40 of file MatrixI.H.

◆ m()

◆ n()

Foam::label n
inline

Return the number of columns.

Definition at line 64 of file MatrixI.H.

Referenced by LUscalarMatrix::LUscalarMatrix(), Foam::outer(), SVD::SVD(), and Foam::symmOuter().

Here is the caller graph for this function:

◆ size()

Foam::label size
inline

Return the number of elements in matrix (m*n)

Definition at line 71 of file MatrixI.H.

Referenced by Matrix< Form, Type >::Matrix().

Here is the caller graph for this function:

◆ v() [1/2]

const Type * v
inline

Return element vector of the constant Matrix.

Definition at line 118 of file MatrixI.H.

◆ v() [2/2]

Type * v
inline

Return element vector of the Matrix.

Definition at line 125 of file MatrixI.H.

◆ block() [1/6]

Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > block ( const label  m,
const label  n,
const label  mStart,
const label  nStart 
) const
inline

Definition at line 133 of file MatrixI.H.

References n.

◆ block() [2/6]

ConstMatrixBlock<mType> block ( const label  mStart,
const label  nStart 
) const
inline

◆ col() [1/4]

Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > col ( const label  m,
const label  rowStart 
) const
inline

Definition at line 174 of file MatrixI.H.

◆ col() [2/4]

Foam::ConstMatrixBlock< Foam::Matrix< Form, Type > > col ( const label  m,
const label  mStart,
const label  nStart 
) const
inline

Definition at line 193 of file MatrixI.H.

◆ block() [3/6]

Foam::MatrixBlock< Foam::Matrix< Form, Type > > block ( const label  m,
const label  n,
const label  mStart,
const label  nStart 
)
inline

Definition at line 213 of file MatrixI.H.

◆ block() [4/6]

MatrixBlock<mType> block ( const label  mStart,
const label  nStart 
)
inline

◆ col() [3/4]

Foam::MatrixBlock< Foam::Matrix< Form, Type > > col ( const label  m,
const label  rowStart 
)
inline

Definition at line 250 of file MatrixI.H.

◆ col() [4/4]

Foam::MatrixBlock< Foam::Matrix< Form, Type > > col ( const label  m,
const label  mStart,
const label  nStart 
)
inline

Definition at line 265 of file MatrixI.H.

◆ checki()

void checki ( const label  i) const
inline

Check index i is within valid range (0 ... m-1).

Definition at line 78 of file MatrixI.H.

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

Here is the call graph for this function:

◆ checkj()

void checkj ( const label  j) const
inline

Check index j is within valid range (0 ... n-1).

Definition at line 98 of file MatrixI.H.

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

Here is the call graph for this function:

◆ clear()

void clear

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

Definition at line 337 of file Matrix.C.

◆ transfer()

void transfer ( mType M)

Transfer the contents of the argument Matrix into this Matrix.

and annul the argument Matrix.

Definition at line 351 of file Matrix.C.

References clear(), and M.

Referenced by LUscalarMatrix::LUscalarMatrix().

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

◆ setSize()

void setSize ( const label  m,
const label  n 
)

Resize the matrix preserving the elements.

Definition at line 367 of file Matrix.C.

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

Here is the call graph for this function:

◆ shallowResize()

void shallowResize ( const label  m,
const label  n 
)
inline

Resize the matrix without reallocating storage (unsafe)

Definition at line 284 of file MatrixI.H.

◆ T()

Form T

Return the transpose of the matrix.

Definition at line 387 of file Matrix.C.

References Foam::saturationModels::A, and n.

Referenced by chemPointISAT::chemPointISAT().

Here is the caller graph for this function:

◆ operator[]() [1/2]

Type * operator[] ( const label  i)
inline

Return subscript-checked row of Matrix.

Definition at line 328 of file MatrixI.H.

Referenced by LUscalarMatrix::LUscalarMatrix().

Here is the caller graph for this function:

◆ operator[]() [2/2]

const Type * operator[] ( const label  i) const
inline

Return subscript-checked row of constant Matrix.

Definition at line 320 of file MatrixI.H.

◆ operator()() [1/2]

const Type & operator() ( const label  i,
const label  j 
) const
inline

(i, j) const element access operator

Definition at line 294 of file MatrixI.H.

◆ operator()() [2/2]

Type & operator() ( const label  i,
const label  j 
)
inline

(i, j) element access operator

Definition at line 307 of file MatrixI.H.

◆ operator=() [1/5]

void operator= ( const mType M)

Assignment operator. Takes linear time.

Definition at line 407 of file Matrix.C.

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

Here is the call graph for this function:

◆ operator=() [2/5]

void operator= ( const ConstMatrixBlock< MatrixType > &  Mb)

Assignment to a block of another matrix.

Definition at line 437 of file Matrix.C.

◆ operator=() [3/5]

void operator= ( const MatrixBlock< MatrixType > &  Mb)

Assignment to a block of another matrix.

Definition at line 454 of file Matrix.C.

◆ operator=() [4/5]

void operator= ( const  zero)

Assignment of all elements to zero.

Definition at line 484 of file Matrix.C.

References Foam::Zero.

◆ operator=() [5/5]

void operator= ( const Type &  s)

Assignment of all elements to the given value.

Definition at line 470 of file Matrix.C.

References s().

Here is the call graph for this function:

◆ block() [5/6]

Foam::ConstMatrixBlock<Foam::Matrix<Form, Type> > block ( const label  mStart,
const label  nStart 
) const
inline

◆ block() [6/6]

Foam::MatrixBlock<Foam::Matrix<Form, Type> > block ( const label  mStart,
const label  nStart 
)
inline

Definition at line 235 of file MatrixI.H.

Friends And Related Function Documentation

◆ operator>>

Istream& operator>> ( Istream ,
mType  
)
friend

Read Matrix from Istream, discarding contents of existing Matrix.

Referenced by Matrix< Form, Type >::Matrix().

◆ operator

Ostream& operator ( Ostream ,
const mType  
)
friend

Write Matrix to Ostream.


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