Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
Matrix Class Reference

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

Inheritance diagram for Matrix:
Inheritance graph
[legend]

Public Types

typedef Matrix< Form, Type > mType
 
typedef Type cmptType
 
typedef Type * iterator
 

Public Member Functions

 Matrix () noexcept
 
 Matrix (const label m, const label n)
 
 Matrix (const label m, const label n, const Foam::zero)
 
 Matrix (const label m, const label n, const Type &val)
 
 Matrix (const labelPair &dims)
 
 Matrix (const labelPair &dims, const Foam::zero)
 
 Matrix (const labelPair &dims, const Type &val)
 
 Matrix (const Matrix< Form, Type > &mat)
 
 Matrix (Matrix< Form, Type > &&mat)
 
template<class Form2 >
 Matrix (const Matrix< Form2, Type > &mat)
 
template<class MatrixType >
 Matrix (const ConstMatrixBlock< MatrixType > &Mb)
 
template<class MatrixType >
 Matrix (const MatrixBlock< MatrixType > &Mb)
 
 Matrix (Istream &is)
 
autoPtr< mTypeclone () const
 
 ~Matrix ()
 
label m () const noexcept
 
label n () const noexcept
 
label size () const
 
labelPair sizes () const
 
bool empty () const noexcept
 
const Type * cdata () const noexcept
 
Type * data () noexcept
 
const char * cdata_bytes () const noexcept
 
char * data_bytes () noexcept
 
std::streamsize size_bytes () const noexcept
 
std::streamsize byteSize () const
 
const Type * rowData (const label irow) const
 
Type * rowData (const label irow)
 
const Type & at (const label idx) const
 
Type & at (const label idx)
 
ConstMatrixBlock< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1) const
 
ConstMatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1) const
 
ConstMatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1) const
 
template<class VectorSpace >
ConstMatrixBlock< mTypeblock (const label rowIndex, const label colIndex) const
 
MatrixBlock< mTypesubColumn (const label colIndex, const label rowIndex=0, label len=-1)
 
MatrixBlock< mTypesubRow (const label rowIndex, const label colIndex=0, label len=-1)
 
MatrixBlock< mTypesubMatrix (const label rowIndex, const label colIndex, label szRows=-1, label szCols=-1)
 
template<class VectorSpace >
MatrixBlock< mTypeblock (const label rowIndex, const label colIndex)
 
void checki (const label irow) const
 
void checkj (const label jcol) const
 
void checkSize () const
 
bool uniform () const
 
void clear ()
 
List< Type > release ()
 
void swap (Matrix< Form, Type > &mat)
 
void transfer (Matrix< Form, Type > &mat)
 
void resize (const label m, const label n)
 
void resize_nocopy (const label mrow, const label ncol)
 
void setSize (const label m, const label n)
 
void shallowResize (const label m, const label n)
 
void round (const scalar tol=SMALL)
 
Form T () const
 
tmp< Field< Type > > Amul (const UList< Type > &x) const
 
template<class Addr >
tmp< Field< Type > > Amul (const IndirectListBase< Type, Addr > &x) const
 
tmp< Field< Type > > Tmul (const UList< Type > &x) const
 
template<class Addr >
tmp< Field< Type > > Tmul (const IndirectListBase< Type, Addr > &x) const
 
List< Type > diag () const
 
void diag (const UList< Type > &list)
 
Type trace () const
 
scalar columnNorm (const label colIndex, const bool noSqrt=false) const
 
scalar norm (const bool noSqrt=false) const
 
const Type * operator[] (const label irow) const
 
Type * operator[] (const label irow)
 
const Type & operator() (const label irow, const label jcol) const
 
Type & operator() (const label irow, const label jcol)
 
void operator= (const Matrix< Form, Type > &mat)
 
void operator= (Matrix< Form, Type > &&mat)
 
template<class MatrixType >
void operator= (const ConstMatrixBlock< MatrixType > &Mb)
 
template<class MatrixType >
void operator= (const MatrixBlock< MatrixType > &Mb)
 
void operator= (const Foam::zero)
 
void operator= (const Type &val)
 
void operator+= (const Matrix< Form, Type > &other)
 
void operator-= (const Matrix< Form, Type > &other)
 
void operator+= (const Type &s)
 
void operator-= (const Type &s)
 
void operator*= (const Type &s)
 
void operator/= (const Type &s)
 
iterator begin () noexcept
 
iterator end () noexcept
 
const_iterator cbegin () const noexcept
 
const_iterator cend () const noexcept
 
const_iterator begin () const noexcept
 
const_iterator end () const noexcept
 
bool readMatrix (Istream &is)
 
OstreamwriteMatrix (Ostream &os, const label shortLen=0) const
 
label mRows () const noexcept
 
label nRows () const noexcept
 
label nCols () const noexcept
 
const Type * v () const
 
Type * v ()
 
ConstMatrixBlock< mTypeblock (const label m, const label n, const label mStart, const label nStart) const
 
MatrixBlock< mTypeblock (const label m, const label n, const label mStart, const label nStart)
 
ConstMatrixBlock< mTypecol (const label m, const label mStart, const label nStart) const
 
MatrixBlock< mTypecol (const label m, const label mStart, const label nStart)
 
void col (const label m, const label rowStart) const =delete
 
void col (const label m, const label rowStart)=delete
 
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 ()
 

Public Attributes

const typedef Type * const_iterator
 

Detailed Description

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

Member Typedef Documentation

◆ mType

typedef Matrix<Form, Type> mType

Definition at line 104 of file Matrix.H.

◆ cmptType

typedef Type cmptType

Definition at line 107 of file Matrix.H.

◆ iterator

typedef Type* iterator

Definition at line 119 of file Matrix.H.

Constructor & Destructor Documentation

◆ Matrix() [1/13]

Matrix ( )
inlinenoexcept

◆ Matrix() [2/13]

Matrix ( const label  m,
const label  n 
)

Definition at line 102 of file Matrix.C.

◆ Matrix() [3/13]

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

Definition at line 115 of file Matrix.C.

◆ Matrix() [4/13]

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

Definition at line 130 of file Matrix.C.

◆ Matrix() [5/13]

Matrix ( const labelPair dims)
inlineexplicit

Definition at line 51 of file MatrixI.H.

◆ Matrix() [6/13]

Matrix ( const labelPair dims,
const Foam::zero   
)
inline

Definition at line 58 of file MatrixI.H.

◆ Matrix() [7/13]

Matrix ( const labelPair dims,
const Type &  val 
)
inline

Definition at line 65 of file MatrixI.H.

◆ Matrix() [8/13]

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

Definition at line 145 of file Matrix.C.

◆ Matrix() [9/13]

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

Definition at line 161 of file Matrix.C.

◆ Matrix() [10/13]

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

Definition at line 175 of file Matrix.C.

◆ Matrix() [11/13]

Matrix ( const ConstMatrixBlock< MatrixType > &  Mb)
inline

Definition at line 193 of file Matrix.C.

◆ Matrix() [12/13]

Matrix ( const MatrixBlock< MatrixType > &  Mb)
inline

Definition at line 215 of file Matrix.C.

◆ Matrix() [13/13]

Matrix ( Istream is)
explicit

Definition at line 33 of file MatrixIO.C.

◆ ~Matrix()

~Matrix ( )

Definition at line 237 of file Matrix.C.

Member Function Documentation

◆ null()

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

Definition at line 82 of file MatrixI.H.

◆ clone()

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

Definition at line 73 of file MatrixI.H.

◆ m()

Foam::label m ( ) const
inlinenoexcept

◆ n()

Foam::label n ( ) const
inlinenoexcept

◆ size()

Foam::label size ( ) const
inline

Definition at line 103 of file MatrixI.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ sizes()

Foam::labelPair sizes ( ) const
inline

Definition at line 110 of file MatrixI.H.

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

Here is the caller graph for this function:

◆ empty()

bool empty ( ) const
inlinenoexcept

Definition at line 117 of file MatrixI.H.

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

Here is the caller graph for this function:

◆ cdata()

const Type * cdata ( ) const
inlinenoexcept

Definition at line 195 of file MatrixI.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::Matrix(), and Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ data()

Type * data ( )
inlinenoexcept

Definition at line 202 of file MatrixI.H.

◆ cdata_bytes()

const char * cdata_bytes ( ) const
inlinenoexcept

Definition at line 209 of file MatrixI.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ data_bytes()

char * data_bytes ( )
inlinenoexcept

Definition at line 216 of file MatrixI.H.

◆ size_bytes()

std::streamsize size_bytes ( ) const
inlinenoexcept

Definition at line 223 of file MatrixI.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ byteSize()

std::streamsize byteSize ( ) const

Definition at line 487 of file Matrix.C.

◆ rowData() [1/2]

const Type * rowData ( const label  irow) const
inline

Definition at line 230 of file MatrixI.H.

◆ rowData() [2/2]

Type * rowData ( const label  irow)
inline

Definition at line 240 of file MatrixI.H.

◆ at() [1/2]

const Type & at ( const label  idx) const
inline

Definition at line 250 of file MatrixI.H.

◆ at() [2/2]

Type & at ( const label  idx)
inline

Definition at line 265 of file MatrixI.H.

◆ subColumn() [1/2]

ConstMatrixBlock<mType> subColumn ( const label  colIndex,
const label  rowIndex = 0,
label  len = -1 
) const
inline

Referenced by Matrix< RectangularMatrix< Type >, Type >::col().

Here is the caller graph for this function:

◆ subRow() [1/2]

ConstMatrixBlock<mType> subRow ( const label  rowIndex,
const label  colIndex = 0,
label  len = -1 
) const
inline

◆ subMatrix() [1/2]

ConstMatrixBlock<mType> subMatrix ( const label  rowIndex,
const label  colIndex,
label  szRows = -1,
label  szCols = -1 
) const
inline

Referenced by Matrix< RectangularMatrix< Type >, Type >::block().

Here is the caller graph for this function:

◆ block() [1/6]

ConstMatrixBlock<mType> block ( const label  rowIndex,
const label  colIndex 
) const
inline

◆ subColumn() [2/2]

MatrixBlock<mType> subColumn ( const label  colIndex,
const label  rowIndex = 0,
label  len = -1 
)
inline

◆ subRow() [2/2]

MatrixBlock<mType> subRow ( const label  rowIndex,
const label  colIndex = 0,
label  len = -1 
)
inline

◆ subMatrix() [2/2]

MatrixBlock<mType> subMatrix ( const label  rowIndex,
const label  colIndex,
label  szRows = -1,
label  szCols = -1 
)
inline

◆ block() [2/6]

MatrixBlock<mType> block ( const label  rowIndex,
const label  colIndex 
)
inline

◆ checki()

void checki ( const label  irow) const
inline

Definition at line 124 of file MatrixI.H.

◆ checkj()

void checkj ( const label  jcol) const
inline

Definition at line 142 of file MatrixI.H.

◆ checkSize()

void checkSize ( ) const
inline

Definition at line 160 of file MatrixI.H.

◆ uniform()

bool uniform ( ) const
inline

Definition at line 173 of file MatrixI.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ clear()

void clear ( )

Definition at line 249 of file Matrix.C.

◆ release()

Foam::List< Type > release ( )

Definition at line 263 of file Matrix.C.

◆ swap()

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

Definition at line 283 of file Matrix.C.

◆ transfer()

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

Definition at line 297 of file Matrix.C.

◆ resize()

void resize ( const label  m,
const label  n 
)

Definition at line 317 of file Matrix.C.

◆ resize_nocopy()

void resize_nocopy ( const label  mrow,
const label  ncol 
)

Definition at line 342 of file Matrix.C.

◆ setSize()

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

Definition at line 468 of file MatrixI.H.

◆ shallowResize()

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

Definition at line 475 of file MatrixI.H.

◆ round()

void round ( const scalar  tol = SMALL)

Definition at line 372 of file Matrix.C.

◆ T()

Form T ( ) const

Definition at line 385 of file Matrix.C.

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

Here is the caller graph for this function:

◆ Amul() [1/3]

Foam::tmp< Foam::Field< Type > > Amul ( const UList< Type > &  x) const
inline

Definition at line 484 of file MatrixI.H.

Referenced by Foam::operator*().

Here is the caller graph for this function:

◆ Amul() [2/3]

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

◆ Tmul() [1/3]

Foam::tmp< Foam::Field< Type > > Tmul ( const UList< Type > &  x) const
inline

Definition at line 505 of file MatrixI.H.

Referenced by Foam::operator*().

Here is the caller graph for this function:

◆ Tmul() [2/3]

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

◆ diag() [1/2]

Foam::List< Type > diag ( ) const

Definition at line 402 of file Matrix.C.

◆ diag() [2/2]

void diag ( const UList< Type > &  list)

Definition at line 418 of file Matrix.C.

◆ trace()

Type trace ( ) const

Definition at line 439 of file Matrix.C.

◆ columnNorm()

Foam::scalar columnNorm ( const label  colIndex,
const bool  noSqrt = false 
) const

Definition at line 456 of file Matrix.C.

Referenced by QRMatrix< MatrixType >::householderReflector().

Here is the caller graph for this function:

◆ norm()

Foam::scalar norm ( const bool  noSqrt = false) const

Definition at line 473 of file Matrix.C.

◆ operator[]() [1/2]

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

Definition at line 607 of file MatrixI.H.

◆ operator[]() [2/2]

Type * operator[] ( const label  irow)
inline

Definition at line 617 of file MatrixI.H.

◆ operator()() [1/2]

const Type & operator() ( const label  irow,
const label  jcol 
) const
inline

Definition at line 578 of file MatrixI.H.

◆ operator()() [2/2]

Type & operator() ( const label  irow,
const label  jcol 
)
inline

Definition at line 593 of file MatrixI.H.

◆ operator=() [1/6]

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

Definition at line 502 of file Matrix.C.

◆ operator=() [2/6]

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

Definition at line 525 of file Matrix.C.

◆ operator=() [3/6]

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

Definition at line 538 of file Matrix.C.

◆ operator=() [4/6]

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

Definition at line 555 of file Matrix.C.

◆ operator=() [5/6]

void operator= ( const Foam::zero  )

Definition at line 577 of file Matrix.C.

◆ operator=() [6/6]

void operator= ( const Type &  val)

Definition at line 570 of file Matrix.C.

◆ operator+=() [1/2]

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

Definition at line 584 of file Matrix.C.

◆ operator-=() [1/2]

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

Definition at line 614 of file Matrix.C.

◆ operator+=() [2/2]

void operator+= ( const Type &  s)

Definition at line 644 of file Matrix.C.

◆ operator-=() [2/2]

void operator-= ( const Type &  s)

Definition at line 654 of file Matrix.C.

◆ operator*=()

void operator*= ( const Type &  s)

Definition at line 664 of file Matrix.C.

◆ operator/=()

void operator/= ( const Type &  s)

Definition at line 674 of file Matrix.C.

◆ begin() [1/2]

iterator begin ( )
inlinenoexcept

◆ end() [1/2]

iterator end ( )
inlinenoexcept

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

Here is the caller graph for this function:

◆ cbegin()

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

◆ cend()

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

◆ begin() [2/2]

const_iterator begin ( ) const
inlinenoexcept

◆ end() [2/2]

const_iterator end ( ) const
inlinenoexcept

◆ readMatrix()

bool readMatrix ( Istream is)

Definition at line 46 of file MatrixIO.C.

Referenced by Foam::operator>>().

Here is the caller graph for this function:

◆ writeMatrix()

Foam::Ostream & writeMatrix ( Ostream os,
const label  shortLen = 0 
) const

Definition at line 137 of file MatrixIO.C.

Referenced by Foam::operator<<().

Here is the caller graph for this function:

◆ mRows()

label mRows ( ) const
inlinenoexcept

Definition at line 506 of file Matrix.H.

◆ nRows()

label nRows ( ) const
inlinenoexcept

Definition at line 512 of file Matrix.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ nCols()

label nCols ( ) const
inlinenoexcept

Definition at line 518 of file Matrix.H.

Referenced by Matrix< RectangularMatrix< Type >, Type >::writeMatrix().

Here is the caller graph for this function:

◆ v() [1/2]

const Type* v ( ) const
inline

Definition at line 527 of file Matrix.H.

◆ v() [2/2]

Type* v ( )
inline

Definition at line 535 of file Matrix.H.

◆ block() [3/6]

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

Definition at line 544 of file Matrix.H.

◆ block() [4/6]

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

Definition at line 558 of file Matrix.H.

◆ col() [1/4]

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

Definition at line 573 of file Matrix.H.

◆ col() [2/4]

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

Definition at line 586 of file Matrix.H.

◆ col() [3/4]

void col ( const label  m,
const label  rowStart 
) const
delete

◆ col() [4/4]

void col ( const label  m,
const label  rowStart 
)
delete

◆ AmulImpl()

Foam::tmp<Foam::Field<Type> > AmulImpl ( const ListType &  x) const

Definition at line 31 of file Matrix.C.

◆ TmulImpl()

Foam::tmp<Foam::Field<Type> > TmulImpl ( const ListType &  x) const

Definition at line 66 of file Matrix.C.

◆ block() [5/6]

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

Definition at line 357 of file MatrixI.H.

◆ block() [6/6]

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

Definition at line 451 of file MatrixI.H.

◆ Amul() [3/3]

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

Definition at line 495 of file MatrixI.H.

◆ Tmul() [3/3]

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

Definition at line 516 of file MatrixI.H.

Member Data Documentation

◆ const_iterator

const typedef Type* const_iterator

Definition at line 122 of file Matrix.H.


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