Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
Matrix< Form, Type > Class Template Reference

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

Inheritance diagram for Matrix< Form, Type >:
Inheritance graph
[legend]

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...
 
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 &)
 

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 47 of file DiagonalMatrix.H.

Member Typedef Documentation

typedef Matrix<Form, Type> mType

Matrix type.

Definition at line 96 of file Matrix.H.

typedef Type cmptType

Component type.

Definition at line 99 of file Matrix.H.

Constructor & Destructor Documentation

Matrix ( )
inline

Null constructor.

Definition at line 31 of file MatrixI.H.

References Matrix< Form, Type >::clone().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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 ( const label  m,
const label  n,
const zero   
)

Construct with given number of rows and columns.

initializing 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 ( const label  m,
const label  n,
const Type &  s 
)

Construct with given number of rows and columns.

initializing 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 ( const mType M)

Copy constructor.

Definition at line 115 of file Matrix.C.

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

Here is the call graph for this function:

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

Copy constructor from matrix of a different form.

Definition at line 136 of file Matrix.C.

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

Here is the call graph for this function:

Matrix ( const ConstMatrixBlock< MatrixType > &  Mb)
inline

Construct from a block of another matrix.

Definition at line 158 of file Matrix.C.

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

Here is the call graph for this function:

Matrix ( const MatrixBlock< MatrixType > &  Mb)
inline

Construct from a block of another matrix.

Definition at line 180 of file Matrix.C.

Matrix ( Istream is)
~Matrix ( )

Destructor.

Definition at line 202 of file Matrix.C.

Member Function Documentation

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

Return a null Matrix.

Definition at line 50 of file MatrixI.H.

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

Clone.

Definition at line 41 of file MatrixI.H.

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

Here is the caller graph for this function:

Foam::label m ( ) const
inline
Foam::label n ( ) const
inline

Return the number of columns.

Definition at line 64 of file MatrixI.H.

Referenced by Matrix< Form, Type >::block(), Matrix< Form, Type >::Matrix(), Foam::multiply(), Foam::operator*(), Foam::operator+(), Foam::operator-(), Foam::operator/(), SVD::SVD(), and Matrix< Form, Type >::T().

Here is the caller graph for this function:

Foam::label size ( ) const
inline

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

Definition at line 71 of file MatrixI.H.

Referenced by Matrix< Form, Type >::Matrix(), Foam::max(), Foam::min(), Foam::operator*(), Foam::operator+(), Foam::operator-(), Foam::operator/(), and Matrix< Form, Type >::operator=().

Here is the caller graph for this function:

const Type * v ( ) const
inline

Return element vector of the constant Matrix.

Definition at line 118 of file MatrixI.H.

Referenced by Matrix< Form, Type >::Matrix(), Foam::max(), Foam::min(), Foam::operator*(), Foam::operator+(), Foam::operator-(), and Foam::operator/().

Here is the caller graph for this function:

Type * v ( )
inline

Return element vector of the Matrix.

Definition at line 125 of file MatrixI.H.

References Matrix< Form, Type >::block().

Here is the call graph for this function:

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

Definition at line 134 of file MatrixI.H.

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

Referenced by Matrix< Form, Type >::col(), QRMatrix< MatrixType >::inv(), and Matrix< Form, Type >::v().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 175 of file MatrixI.H.

References Matrix< Form, Type >::m().

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 194 of file MatrixI.H.

References Matrix< Form, Type >::block(), and Matrix< Form, Type >::m().

Here is the call graph for this function:

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

Definition at line 214 of file MatrixI.H.

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

Here is the call graph for this function:

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

Definition at line 250 of file MatrixI.H.

References Matrix< Form, Type >::col(), and Matrix< Form, Type >::m().

Here is the call graph for this function:

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

Definition at line 266 of file MatrixI.H.

References Matrix< Form, Type >::m(), and Matrix< Form, Type >::operator.

Here is the call graph for this function:

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.

Referenced by Matrix< Form, Type >::operator()(), and Matrix< Form, Type >::operator[]().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

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

Here is the call graph for this function:

Here is the caller graph for this function:

void clear ( )

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

Definition at line 214 of file Matrix.C.

Referenced by Matrix< Form, Type >::Matrix(), Matrix< Form, Type >::operator=(), and Matrix< Form, Type >::transfer().

Here is the caller graph for this function:

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 Matrix< Form, Type >::clear().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void setSize ( const label  m,
const label  n 
)

Resize the matrix preserving the elements.

Definition at line 244 of file Matrix.C.

References Foam::min(), Matrix< Form, Type >::transfer(), and Foam::Zero.

Here is the call graph for this function:

Form T ( ) const

Return the transpose of the matrix.

Definition at line 264 of file Matrix.C.

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

Referenced by SVD::SVD().

Here is the call graph for this function:

Here is the caller graph for this function:

Type * operator[] ( const label  i)
inline

Return subscript-checked row of Matrix.

Definition at line 320 of file MatrixI.H.

References Matrix< Form, Type >::checki().

Here is the call graph for this function:

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

Return subscript-checked row of constant Matrix.

Definition at line 312 of file MatrixI.H.

References Matrix< Form, Type >::checki().

Here is the call graph for this function:

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

(i, j) const element access operator

Definition at line 287 of file MatrixI.H.

References Matrix< Form, Type >::checki(), Matrix< Form, Type >::checkj(), and Matrix< Form, Type >::operator.

Here is the call graph for this function:

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

(i, j) element access operator

Definition at line 300 of file MatrixI.H.

References Matrix< Form, Type >::checki(), and Matrix< Form, Type >::checkj().

Here is the call graph for this function:

void operator= ( const mType M)

Assignment operator. Takes linear time.

Definition at line 284 of file Matrix.C.

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

Here is the call graph for this function:

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

Assignment to a block of another matrix.

Definition at line 315 of file Matrix.C.

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

Assignment to a block of another matrix.

Definition at line 332 of file Matrix.C.

void operator= ( const zero  )

Assignment of all elements to zero.

Definition at line 361 of file Matrix.C.

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

Here is the call graph for this function:

void operator= ( const Type &  s)

Assignment of all elements to the given value.

Definition at line 347 of file Matrix.C.

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

Here is the call graph for this function:

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

Definition at line 156 of file MatrixI.H.

References Matrix< Form, Type >::col(), VectorSpace< Form, Cmpt, Ncmpts >::mRows, and VectorSpace< Form, Cmpt, Ncmpts >::nCols.

Here is the call graph for this function:

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

Friends And Related Function Documentation

Istream& operator>> ( Istream ,
mType  
)
friend

Read Matrix from Istream, discarding contents of existing Matrix.

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

Ostream& operator ( Ostream ,
const mType  
)
friend

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