Opm::TridiagonalMatrix< Scalar > Class Template Reference

Provides a tridiagonal matrix that also supports non-zero entries in the upper right and lower left. More...

#include <TridiagonalMatrix.hpp>

Public Types

typedef Scalar FieldType
 
typedef TridiagRow_ RowType
 
typedef size_t SizeType
 
typedef TridiagRow_ iterator
 
typedef TridiagRow_ const_iterator
 

Public Member Functions

 TridiagonalMatrix (size_t numRows=0)
 
 TridiagonalMatrix (size_t numRows, Scalar value)
 
 TridiagonalMatrix (const TridiagonalMatrix &source)
 Copy constructor. More...
 
size_t size () const
 Return the number of rows/columns of the matrix. More...
 
size_t rows () const
 Return the number of rows of the matrix. More...
 
size_t cols () const
 Return the number of columns of the matrix. More...
 
void resize (size_t n)
 Change the number of rows of the matrix. More...
 
Scalar & at (size_t rowIdx, size_t colIdx)
 Access an entry. More...
 
Scalar at (size_t rowIdx, size_t colIdx) const
 Access an entry. More...
 
TridiagonalMatrixoperator= (const TridiagonalMatrix &source)
 Assignment operator from another tridiagonal matrix. More...
 
TridiagonalMatrixoperator= (Scalar value)
 Assignment operator from a Scalar. More...
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator end () const
 
TridiagRow_ operator[] (size_t rowIdx)
 Row access operator. More...
 
const TridiagRow_ operator[] (size_t rowIdx) const
 Row access operator. More...
 
TridiagonalMatrixoperator*= (Scalar alpha)
 Multiplication with a Scalar. More...
 
TridiagonalMatrixoperator/= (Scalar alpha)
 Division by a Scalar. More...
 
TridiagonalMatrixoperator-= (const TridiagonalMatrix &other)
 Subtraction operator. More...
 
TridiagonalMatrixoperator+= (const TridiagonalMatrix &other)
 Addition operator. More...
 
TridiagonalMatrixaxpy (Scalar alpha, const TridiagonalMatrix &other)
 Multiply and add the matrix entries of another tridiagonal matrix. More...
 
template<class Vector >
void mv (const Vector &source, Vector &dest) const
 Matrix-vector product. More...
 
template<class Vector >
void umv (const Vector &source, Vector &dest) const
 Additive matrix-vector product. More...
 
template<class Vector >
void mmv (const Vector &source, Vector &dest) const
 Subtractive matrix-vector product. More...
 
template<class Vector >
void usmv (Scalar alpha, const Vector &source, Vector &dest) const
 Scaled additive matrix-vector product. More...
 
template<class Vector >
void mtv (const Vector &source, Vector &dest) const
 Transposed matrix-vector product. More...
 
template<class Vector >
void umtv (const Vector &source, Vector &dest) const
 Transposed additive matrix-vector product. More...
 
template<class Vector >
void mmtv (const Vector &source, Vector &dest) const
 Transposed subtractive matrix-vector product. More...
 
template<class Vector >
void usmtv (Scalar alpha, const Vector &source, Vector &dest) const
 Transposed scaled additive matrix-vector product. More...
 
Scalar frobeniusNorm () const
 Calculate the frobenius norm. More...
 
Scalar frobeniusNormSquared () const
 Calculate the squared frobenius norm. More...
 
Scalar infinityNorm () const
 Calculate the infinity norm. More...
 
template<class XVector , class BVector >
void solve (XVector &x, const BVector &b) const
 Calculate the solution for a linear system of equations. More...
 
void print (std::ostream &os=std::cout) const
 Print the matrix to a given output stream. More...
 

Detailed Description

template<class Scalar>
class Opm::TridiagonalMatrix< Scalar >

Provides a tridiagonal matrix that also supports non-zero entries in the upper right and lower left.

The entries in the lower left and upper right are supported to make implementing periodic systems easy.

The API of this class is designed to be close to the one used by the DUNE matrix classes.

Member Typedef Documentation

◆ const_iterator

template<class Scalar >
typedef TridiagRow_ Opm::TridiagonalMatrix< Scalar >::const_iterator

◆ FieldType

template<class Scalar >
typedef Scalar Opm::TridiagonalMatrix< Scalar >::FieldType

◆ iterator

template<class Scalar >
typedef TridiagRow_ Opm::TridiagonalMatrix< Scalar >::iterator

◆ RowType

template<class Scalar >
typedef TridiagRow_ Opm::TridiagonalMatrix< Scalar >::RowType

◆ SizeType

template<class Scalar >
typedef size_t Opm::TridiagonalMatrix< Scalar >::SizeType

Constructor & Destructor Documentation

◆ TridiagonalMatrix() [1/3]

template<class Scalar >
Opm::TridiagonalMatrix< Scalar >::TridiagonalMatrix ( size_t  numRows = 0)
inlineexplicit

◆ TridiagonalMatrix() [2/3]

template<class Scalar >
Opm::TridiagonalMatrix< Scalar >::TridiagonalMatrix ( size_t  numRows,
Scalar  value 
)
inline

◆ TridiagonalMatrix() [3/3]

template<class Scalar >
Opm::TridiagonalMatrix< Scalar >::TridiagonalMatrix ( const TridiagonalMatrix< Scalar > &  source)
inline

Copy constructor.

Member Function Documentation

◆ at() [1/2]

template<class Scalar >
Scalar & Opm::TridiagonalMatrix< Scalar >::at ( size_t  rowIdx,
size_t  colIdx 
)
inline

◆ at() [2/2]

template<class Scalar >
Scalar Opm::TridiagonalMatrix< Scalar >::at ( size_t  rowIdx,
size_t  colIdx 
) const
inline

Access an entry.

References Opm::TridiagonalMatrix< Scalar >::size().

◆ axpy()

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::axpy ( Scalar  alpha,
const TridiagonalMatrix< Scalar > &  other 
)
inline

Multiply and add the matrix entries of another tridiagonal matrix.

This means that

A.axpy(alpha, B)

is equivalent to

A += alpha*C

References Opm::TridiagonalMatrix< Scalar >::size().

Referenced by Opm::TridiagonalMatrix< Scalar >::operator+=(), and Opm::TridiagonalMatrix< Scalar >::operator-=().

◆ begin() [1/2]

template<class Scalar >
iterator Opm::TridiagonalMatrix< Scalar >::begin ( )
inline

\begin Iterator for the first row

◆ begin() [2/2]

template<class Scalar >
const_iterator Opm::TridiagonalMatrix< Scalar >::begin ( ) const
inline

\begin Const iterator for the first row

◆ cols()

template<class Scalar >
size_t Opm::TridiagonalMatrix< Scalar >::cols ( ) const
inline

Return the number of columns of the matrix.

References Opm::TridiagonalMatrix< Scalar >::size().

◆ end()

template<class Scalar >
const_iterator Opm::TridiagonalMatrix< Scalar >::end ( ) const
inline

\begin Const iterator for the next-to-last row

References Opm::TridiagonalMatrix< Scalar >::size().

◆ frobeniusNorm()

template<class Scalar >
Scalar Opm::TridiagonalMatrix< Scalar >::frobeniusNorm ( ) const
inline

Calculate the frobenius norm.

i.e., the square root of the sum of all squared entries. This corresponds to the euclidean norm for vectors.

References Opm::TridiagonalMatrix< Scalar >::frobeniusNormSquared(), and Opm::sqrt().

◆ frobeniusNormSquared()

template<class Scalar >
Scalar Opm::TridiagonalMatrix< Scalar >::frobeniusNormSquared ( ) const
inline

Calculate the squared frobenius norm.

i.e., the sum of all squared entries.

References Opm::TridiagonalMatrix< Scalar >::size().

Referenced by Opm::TridiagonalMatrix< Scalar >::frobeniusNorm().

◆ infinityNorm()

template<class Scalar >
Scalar Opm::TridiagonalMatrix< Scalar >::infinityNorm ( ) const
inline

Calculate the infinity norm.

i.e., the maximum of the sum of the absolute values of all rows.

References Opm::abs(), Opm::max(), and Opm::TridiagonalMatrix< Scalar >::size().

◆ mmtv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::mmtv ( const Vector &  source,
Vector &  dest 
) const
inline

Transposed subtractive matrix-vector product.

This means that

A.mmtv(x, y)

is equivalent to

y -= A^T*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ mmv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::mmv ( const Vector &  source,
Vector &  dest 
) const
inline

Subtractive matrix-vector product.

This means that

A.mmv(x, y)

is equivalent to

y -= A*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ mtv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::mtv ( const Vector &  source,
Vector &  dest 
) const
inline

Transposed matrix-vector product.

This means that

A.mtv(x, y)

is equivalent to

y = A^T*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ mv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::mv ( const Vector &  source,
Vector &  dest 
) const
inline

Matrix-vector product.

This means that

A.mv(x, y)

is equivalent to

y = A*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ operator*=()

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator*= ( Scalar  alpha)
inline

Multiplication with a Scalar.

References Opm::TridiagonalMatrix< Scalar >::size().

◆ operator+=()

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator+= ( const TridiagonalMatrix< Scalar > &  other)
inline

Addition operator.

References Opm::TridiagonalMatrix< Scalar >::axpy().

◆ operator-=()

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator-= ( const TridiagonalMatrix< Scalar > &  other)
inline

Subtraction operator.

References Opm::TridiagonalMatrix< Scalar >::axpy().

◆ operator/=()

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator/= ( Scalar  alpha)
inline

Division by a Scalar.

References Opm::TridiagonalMatrix< Scalar >::size().

◆ operator=() [1/2]

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator= ( const TridiagonalMatrix< Scalar > &  source)
inline

Assignment operator from another tridiagonal matrix.

Referenced by Opm::TridiagonalMatrix< Scalar >::TridiagonalMatrix().

◆ operator=() [2/2]

template<class Scalar >
TridiagonalMatrix & Opm::TridiagonalMatrix< Scalar >::operator= ( Scalar  value)
inline

Assignment operator from a Scalar.

References Opm::TridiagonalMatrix< Scalar >::size().

◆ operator[]() [1/2]

template<class Scalar >
TridiagRow_ Opm::TridiagonalMatrix< Scalar >::operator[] ( size_t  rowIdx)
inline

Row access operator.

◆ operator[]() [2/2]

template<class Scalar >
const TridiagRow_ Opm::TridiagonalMatrix< Scalar >::operator[] ( size_t  rowIdx) const
inline

Row access operator.

◆ print()

template<class Scalar >
void Opm::TridiagonalMatrix< Scalar >::print ( std::ostream &  os = std::cout) const
inline

Print the matrix to a given output stream.

References Opm::TridiagonalMatrix< Scalar >::at(), and Opm::TridiagonalMatrix< Scalar >::size().

Referenced by operator<<().

◆ resize()

template<class Scalar >
void Opm::TridiagonalMatrix< Scalar >::resize ( size_t  n)
inline

◆ rows()

template<class Scalar >
size_t Opm::TridiagonalMatrix< Scalar >::rows ( ) const
inline

Return the number of rows of the matrix.

References Opm::TridiagonalMatrix< Scalar >::size().

Referenced by Opm::Spline< Scalar >::makePeriodicSystem_().

◆ size()

◆ solve()

template<class Scalar >
template<class XVector , class BVector >
void Opm::TridiagonalMatrix< Scalar >::solve ( XVector &  x,
const BVector &  b 
) const
inline

Calculate the solution for a linear system of equations.

i.e., calculate x, so that it solves Ax = b, where A is a tridiagonal matrix.

References Opm::abs(), and Opm::TridiagonalMatrix< Scalar >::size().

Referenced by Opm::Spline< Scalar >::makeFullSpline_(), Opm::Spline< Scalar >::makeNaturalSpline_(), Opm::Spline< Scalar >::makePeriodicSpline_(), and Opm::Spline< Scalar >::set().

◆ umtv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::umtv ( const Vector &  source,
Vector &  dest 
) const
inline

Transposed additive matrix-vector product.

This means that

A.umtv(x, y)

is equivalent to

y += A^T*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ umv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::umv ( const Vector &  source,
Vector &  dest 
) const
inline

Additive matrix-vector product.

This means that

A.umv(x, y)

is equivalent to

y += A*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ usmtv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::usmtv ( Scalar  alpha,
const Vector &  source,
Vector &  dest 
) const
inline

Transposed scaled additive matrix-vector product.

This means that

A.umtv(alpha, x, y)

is equivalent to

y += alpha*A^T*x

References Opm::TridiagonalMatrix< Scalar >::size().

◆ usmv()

template<class Scalar >
template<class Vector >
void Opm::TridiagonalMatrix< Scalar >::usmv ( Scalar  alpha,
const Vector &  source,
Vector &  dest 
) const
inline

Scaled additive matrix-vector product.

This means that

A.usmv(x, y)

is equivalent to

y += alpha*(A*x)

References Opm::TridiagonalMatrix< Scalar >::size().


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