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...
 
 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...
 
 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 79 of file Matrix.H.

Member Typedef Documentation

◆ mType

typedef Matrix<Form, Type> mType

Matrix type.

Definition at line 96 of file Matrix.H.

◆ cmptType

typedef Type cmptType

Component type.

Definition at line 99 of file Matrix.H.

Constructor & Destructor Documentation

◆ Matrix() [1/9]

Matrix
inline

Null constructor.

Definition at line 31 of file MatrixI.H.

◆ Matrix() [2/9]

Matrix ( const label  m,
const label  n 
)

Construct given number of rows and columns.

Definition at line 43 of file Matrix.C.

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

Here is the call graph for this function:

◆ Matrix() [3/9]

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 61 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/9]

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 88 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/9]

Matrix ( const mType M)

Copy constructor.

Definition at line 115 of file Matrix.C.

◆ Matrix() [6/9]

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

Copy constructor from matrix of a different form.

Definition at line 136 of file Matrix.C.

◆ Matrix() [7/9]

Matrix ( const ConstMatrixBlock< MatrixType > &  Mb)
inline

Construct from a block of another matrix.

Definition at line 157 of file Matrix.C.

◆ Matrix() [8/9]

Matrix ( const MatrixBlock< MatrixType > &  Mb)
inline

Construct from a block of another matrix.

Definition at line 179 of file Matrix.C.

◆ Matrix() [9/9]

Matrix ( Istream is)

Construct from Istream.

Definition at line 35 of file MatrixIO.C.

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

◆ ~Matrix()

Destructor.

Definition at line 202 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.

◆ 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 FatalErrorInFunction.

◆ clear()

void clear

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

Definition at line 214 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 228 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 244 of file Matrix.C.

◆ 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.

References n.

◆ T()

Form T

Return the transpose of the matrix.

Definition at line 264 of file Matrix.C.

References 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 284 of file Matrix.C.

◆ operator=() [2/5]

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

Assignment to a block of another matrix.

Definition at line 314 of file Matrix.C.

◆ operator=() [3/5]

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

Assignment to a block of another matrix.

Definition at line 331 of file Matrix.C.

◆ operator=() [4/5]

void operator= ( const  zero)

Assignment of all elements to zero.

Definition at line 361 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 347 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

Definition at line 155 of file MatrixI.H.

◆ 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: