dune-common  2.11
Public Types | Public Member Functions | Static Public Attributes | Static Protected Member Functions | List of all members
Dune::DynamicMatrix< K > Class Template Reference

Construct a matrix with a dynamic size. More...

#include <dune/common/dynmatrix.hh>

Inheritance diagram for Dune::DynamicMatrix< K >:
Inheritance graph

Public Types

typedef Base::size_type size_type
 
typedef Base::value_type value_type
 
typedef Base::row_type row_type
 
typedef Traits::derived_type derived_type
 type of derived matrix class More...
 
typedef Traits::value_type field_type
 export the type representing the field More...
 
typedef Traits::value_type block_type
 export the type representing the components More...
 
typedef Traits::row_reference row_reference
 The type used to represent a reference to a row (usually row_type &) More...
 
typedef Traits::const_row_reference const_row_reference
 The type used to represent a reference to a constant row (usually const row_type &) More...
 
typedef DenseIterator< DenseMatrix, row_type, row_referenceIterator
 Iterator class for sequential access. More...
 
typedef Iterator iterator
 typedef for stl compliant access More...
 
typedef Iterator RowIterator
 rename the iterators for easier access More...
 
typedef std::remove_reference< row_reference >::type::Iterator ColIterator
 rename the iterators for easier access More...
 
typedef DenseIterator< const DenseMatrix, const row_type, const_row_referenceConstIterator
 Iterator class for sequential access. More...
 
typedef ConstIterator const_iterator
 typedef for stl compliant access More...
 
typedef ConstIterator ConstRowIterator
 rename the iterators for easier access More...
 
typedef std::remove_reference< const_row_reference >::type::ConstIterator ConstColIterator
 rename the iterators for easier access More...
 

Public Member Functions

 DynamicMatrix ()
 Default constructor. More...
 
 DynamicMatrix (size_type r, size_type c, value_type v=value_type())
 Constructor initializing the whole matrix with a scalar. More...
 
 DynamicMatrix (std::initializer_list< DynamicVector< K >> const &ll)
 Constructor initializing the matrix from a list of vector. More...
 
template<class T , typename = std::enable_if_t<!Dune::IsNumber<T>::value && HasDenseMatrixAssigner<DynamicMatrix, T>::value>>
 DynamicMatrix (T const &rhs)
 
void resize (size_type r, size_type c, value_type v=value_type())
 resize matrix to r × c More...
 
template<typename T , typename = std::enable_if_t<!Dune::IsNumber<T>::value>>
DynamicMatrixoperator= (T const &rhs)
 
template<typename T , typename = std::enable_if_t<Dune::IsNumber<T>::value>>
DynamicMatrixoperator= (T scalar)
 
DynamicMatrix transposed () const
 Return transposed of the matrix as DynamicMatrix. More...
 
size_type mat_rows () const
 
size_type mat_cols () const
 
row_typemat_access (size_type i)
 
const row_typemat_access (size_type i) const
 
constexpr row_reference operator[] (size_type i)
 random access More...
 
constexpr const_row_reference operator[] (size_type i) const
 
constexpr size_type size () const
 size method (number of rows) More...
 
constexpr Iterator begin ()
 begin iterator More...
 
constexpr ConstIterator begin () const
 begin iterator More...
 
constexpr Iterator end ()
 end iterator More...
 
constexpr ConstIterator end () const
 end iterator More...
 
constexpr Iterator beforeEnd ()
 
constexpr ConstIterator beforeEnd () const
 
constexpr Iterator beforeBegin ()
 
constexpr ConstIterator beforeBegin () const
 
constexpr derived_typeoperator+= (const DenseMatrix< Other > &x)
 vector space addition More...
 
constexpr derived_type operator- () const
 Matrix negation. More...
 
constexpr derived_typeoperator-= (const DenseMatrix< Other > &x)
 vector space subtraction More...
 
constexpr derived_typeoperator*= (const field_type &k)
 vector space multiplication with scalar More...
 
constexpr derived_typeoperator/= (const field_type &k)
 vector space division by scalar More...
 
constexpr derived_typeaxpy (const field_type &a, const DenseMatrix< Other > &x)
 vector space axpy operation (*this += a x) More...
 
constexpr bool operator== (const DenseMatrix< Other > &x) const
 Binary matrix comparison. More...
 
constexpr bool operator!= (const DenseMatrix< Other > &x) const
 Binary matrix incomparison. More...
 
constexpr void mv (const X &x, Y &y) const
 y = A x More...
 
constexpr void mtv (const X &x, Y &y) const
 y = A^T x More...
 
constexpr void umv (const X &x, Y &y) const
 y += A x More...
 
constexpr void umtv (const X &x, Y &y) const
 y += A^T x More...
 
constexpr void umhv (const X &x, Y &y) const
 y += A^H x More...
 
constexpr void mmv (const X &x, Y &y) const
 y -= A x More...
 
constexpr void mmtv (const X &x, Y &y) const
 y -= A^T x More...
 
constexpr void mmhv (const X &x, Y &y) const
 y -= A^H x More...
 
constexpr void usmv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A x More...
 
constexpr void usmtv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A^T x More...
 
constexpr void usmhv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A^H x More...
 
constexpr FieldTraits< value_type >::real_type frobenius_norm () const
 frobenius norm: sqrt(sum over squared values of entries) More...
 
constexpr FieldTraits< value_type >::real_type frobenius_norm2 () const
 square of frobenius norm, need for block recursion More...
 
constexpr FieldTraits< vt >::real_type infinity_norm () const
 infinity norm (row sum norm, how to generalize for blocks?) More...
 
constexpr FieldTraits< vt >::real_type infinity_norm () const
 infinity norm (row sum norm, how to generalize for blocks?) More...
 
constexpr FieldTraits< vt >::real_type infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values) More...
 
constexpr FieldTraits< vt >::real_type infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values) More...
 
void solve (V1 &x, const V2 &b, bool doPivoting=true) const
 Solve system A x = b. More...
 
void invert (bool doPivoting=true)
 Compute inverse. More...
 
field_type determinant (bool doPivoting=true) const
 calculates the determinant of this matrix More...
 
DynamicMatrix< K > & leftmultiply (const DenseMatrix< M2 > &M)
 Multiplies M from the left to this matrix. More...
 
DynamicMatrix< K > & rightmultiply (const DenseMatrix< M2 > &M)
 Multiplies M from the right to this matrix. More...
 
constexpr size_type N () const
 number of rows More...
 
constexpr size_type M () const
 number of columns More...
 
constexpr size_type rows () const
 number of rows More...
 
constexpr size_type cols () const
 number of columns More...
 
constexpr bool exists ([[maybe_unused]] size_type i, [[maybe_unused]] size_type j) const
 return true when (i,j) is in pattern More...
 

Static Public Attributes

static constexpr int blocklevel
 The number of block levels we contain. This is the leaf, that is, 1. More...
 

Static Protected Member Functions

static void luDecomposition (DenseMatrix< DynamicMatrix< K > > &A, Func func, Mask &nonsingularLanes, bool throwEarly, bool doPivoting)
 do an LU-Decomposition on matrix A More...
 

Detailed Description

template<class K>
class Dune::DynamicMatrix< K >

Construct a matrix with a dynamic size.

Template Parameters
Kis the field type (use float, double, complex, etc)

Member Typedef Documentation

◆ block_type

export the type representing the components

◆ ColIterator

typedef std::remove_reference<row_reference>::type::Iterator Dune::DenseMatrix< DynamicMatrix< K > >::ColIterator
inherited

rename the iterators for easier access

◆ const_iterator

typedef for stl compliant access

◆ const_row_reference

The type used to represent a reference to a constant row (usually const row_type &)

◆ ConstColIterator

typedef std::remove_reference<const_row_reference>::type::ConstIterator Dune::DenseMatrix< DynamicMatrix< K > >::ConstColIterator
inherited

rename the iterators for easier access

◆ ConstIterator

Iterator class for sequential access.

◆ ConstRowIterator

rename the iterators for easier access

◆ derived_type

type of derived matrix class

◆ field_type

export the type representing the field

◆ Iterator

Iterator class for sequential access.

◆ iterator

typedef Iterator Dune::DenseMatrix< DynamicMatrix< K > >::iterator
inherited

typedef for stl compliant access

◆ row_reference

The type used to represent a reference to a row (usually row_type &)

◆ row_type

template<class K>
typedef Base::row_type Dune::DynamicMatrix< K >::row_type

◆ RowIterator

rename the iterators for easier access

◆ size_type

template<class K>
typedef Base::size_type Dune::DynamicMatrix< K >::size_type

◆ value_type

template<class K>
typedef Base::value_type Dune::DynamicMatrix< K >::value_type

Constructor & Destructor Documentation

◆ DynamicMatrix() [1/4]

template<class K>
Dune::DynamicMatrix< K >::DynamicMatrix ( )
inline

Default constructor.

◆ DynamicMatrix() [2/4]

template<class K>
Dune::DynamicMatrix< K >::DynamicMatrix ( size_type  r,
size_type  c,
value_type  v = value_type() 
)
inline

Constructor initializing the whole matrix with a scalar.

◆ DynamicMatrix() [3/4]

template<class K>
Dune::DynamicMatrix< K >::DynamicMatrix ( std::initializer_list< DynamicVector< K >> const &  ll)
inline

Constructor initializing the matrix from a list of vector.

◆ DynamicMatrix() [4/4]

template<class K>
template<class T , typename = std::enable_if_t<!Dune::IsNumber<T>::value && HasDenseMatrixAssigner<DynamicMatrix, T>::value>>
Dune::DynamicMatrix< K >::DynamicMatrix ( T const &  rhs)
inline

Member Function Documentation

◆ axpy()

constexpr derived_type& Dune::DenseMatrix< DynamicMatrix< K > >::axpy ( const field_type a,
const DenseMatrix< Other > &  x 
)
inlineinherited

vector space axpy operation (*this += a x)

◆ beforeBegin() [1/2]

constexpr Iterator Dune::DenseMatrix< DynamicMatrix< K > >::beforeBegin ( )
inlineinherited
Returns
an iterator that is positioned before the first entry of the vector.

◆ beforeBegin() [2/2]

constexpr ConstIterator Dune::DenseMatrix< DynamicMatrix< K > >::beforeBegin ( ) const
inlineinherited
Returns
an iterator that is positioned before the first entry of the vector.

◆ beforeEnd() [1/2]

constexpr Iterator Dune::DenseMatrix< DynamicMatrix< K > >::beforeEnd ( )
inlineinherited
Returns
an iterator that is positioned before the end iterator of the vector, i.e. at the last entry.

◆ beforeEnd() [2/2]

constexpr ConstIterator Dune::DenseMatrix< DynamicMatrix< K > >::beforeEnd ( ) const
inlineinherited
Returns
an iterator that is positioned before the end iterator of the vector. i.e. at the last element

◆ begin() [1/2]

constexpr Iterator Dune::DenseMatrix< DynamicMatrix< K > >::begin ( )
inlineinherited

begin iterator

◆ begin() [2/2]

constexpr ConstIterator Dune::DenseMatrix< DynamicMatrix< K > >::begin ( ) const
inlineinherited

begin iterator

◆ cols()

constexpr size_type Dune::DenseMatrix< DynamicMatrix< K > >::cols ( ) const
inlineinherited

number of columns

◆ determinant()

field_type Dune::DenseMatrix< DynamicMatrix< K > >::determinant ( bool  doPivoting = true) const
inherited

calculates the determinant of this matrix

◆ end() [1/2]

constexpr Iterator Dune::DenseMatrix< DynamicMatrix< K > >::end ( )
inlineinherited

end iterator

◆ end() [2/2]

constexpr ConstIterator Dune::DenseMatrix< DynamicMatrix< K > >::end ( ) const
inlineinherited

end iterator

◆ exists()

constexpr bool Dune::DenseMatrix< DynamicMatrix< K > >::exists ( [[maybe_unused] ] size_type  i,
[[maybe_unused] ] size_type  j 
) const
inlineinherited

return true when (i,j) is in pattern

◆ frobenius_norm()

constexpr FieldTraits<value_type>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::frobenius_norm ( ) const
inlineinherited

frobenius norm: sqrt(sum over squared values of entries)

◆ frobenius_norm2()

constexpr FieldTraits<value_type>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::frobenius_norm2 ( ) const
inlineinherited

square of frobenius norm, need for block recursion

◆ infinity_norm() [1/2]

constexpr FieldTraits<vt>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::infinity_norm ( ) const
inlineinherited

infinity norm (row sum norm, how to generalize for blocks?)

◆ infinity_norm() [2/2]

constexpr FieldTraits<vt>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::infinity_norm ( ) const
inlineinherited

infinity norm (row sum norm, how to generalize for blocks?)

◆ infinity_norm_real() [1/2]

constexpr FieldTraits<vt>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::infinity_norm_real ( ) const
inlineinherited

simplified infinity norm (uses Manhattan norm for complex values)

◆ infinity_norm_real() [2/2]

constexpr FieldTraits<vt>::real_type Dune::DenseMatrix< DynamicMatrix< K > >::infinity_norm_real ( ) const
inlineinherited

simplified infinity norm (uses Manhattan norm for complex values)

◆ invert()

void Dune::DenseMatrix< DynamicMatrix< K > >::invert ( bool  doPivoting = true)
inherited

Compute inverse.

Exceptions
FMatrixErrorif the matrix is singular

◆ leftmultiply()

DynamicMatrix< K > & Dune::DenseMatrix< DynamicMatrix< K > >::leftmultiply ( const DenseMatrix< M2 > &  M)
inlineinherited

Multiplies M from the left to this matrix.

◆ luDecomposition()

static void Dune::DenseMatrix< DynamicMatrix< K > >::luDecomposition ( DenseMatrix< DynamicMatrix< K > > &  A,
Func  func,
Mask &  nonsingularLanes,
bool  throwEarly,
bool  doPivoting 
)
staticprotectedinherited

do an LU-Decomposition on matrix A

Parameters
AThe matrix to decompose, and to store the result in.
funcFunctor used for swapping lanes and to conduct the elimination. Depending on the functor, luDecomposition() can be used for solving, for inverting, or to compute the determinant.
nonsingularLanesSimdMask of lanes that are nonsingular.
throwEarlyWhether to throw an FMatrixError immediately as soon as one lane is discovered to be singular. If false, do not throw, instead continue until finished or all lanes are singular, and exit via return in both cases.
doPivotingEnable pivoting.

There are two modes of operation:

  • Terminate as soon as one lane is discovered to be singular. Early termination is done by throwing an FMatrixError. On entry, Simd::allTrue(nonsingularLanes) and throwEarly==true should hold. After early termination, the contents of A should be considered bogus, and nonsingularLanes has the lane(s) that triggered the early termination unset. There may be more singular lanes than the one reported in nonsingularLanes, which just haven't been discovered yet; so the value of nonsingularLanes is mostly useful for diagnostics.
  • Terminate only when all lanes are discovered to be singular. Use this when you want to apply special postprocessing in singular lines (e.g. setting the determinant of singular lanes to 0 in determinant()). On entry, nonsingularLanes may have any value and throwEarly==false should hold. The function will not throw an exception if some lanes are discovered to be singular, instead it will continue running until all lanes are singular or until finished, and terminate only via normal return. On exit, nonsingularLanes contains the map of lanes that are valid in A.

◆ M()

constexpr size_type Dune::DenseMatrix< DynamicMatrix< K > >::M ( ) const
inlineinherited

number of columns

◆ mat_access() [1/2]

template<class K>
row_type& Dune::DynamicMatrix< K >::mat_access ( size_type  i)
inline

◆ mat_access() [2/2]

template<class K>
const row_type& Dune::DynamicMatrix< K >::mat_access ( size_type  i) const
inline

◆ mat_cols()

template<class K>
size_type Dune::DynamicMatrix< K >::mat_cols ( ) const
inline

◆ mat_rows()

template<class K>
size_type Dune::DynamicMatrix< K >::mat_rows ( ) const
inline

◆ mmhv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::mmhv ( const X &  x,
Y &  y 
) const
inlineinherited

y -= A^H x

◆ mmtv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::mmtv ( const X &  x,
Y &  y 
) const
inlineinherited

y -= A^T x

◆ mmv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::mmv ( const X &  x,
Y &  y 
) const
inlineinherited

y -= A x

◆ mtv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::mtv ( const X &  x,
Y &  y 
) const
inlineinherited

y = A^T x

◆ mv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::mv ( const X &  x,
Y &  y 
) const
inlineinherited

y = A x

◆ N()

constexpr size_type Dune::DenseMatrix< DynamicMatrix< K > >::N ( ) const
inlineinherited

number of rows

◆ operator!=()

constexpr bool Dune::DenseMatrix< DynamicMatrix< K > >::operator!= ( const DenseMatrix< Other > &  x) const
inlineinherited

Binary matrix incomparison.

◆ operator*=()

constexpr derived_type& Dune::DenseMatrix< DynamicMatrix< K > >::operator*= ( const field_type k)
inlineinherited

vector space multiplication with scalar

◆ operator+=()

constexpr derived_type& Dune::DenseMatrix< DynamicMatrix< K > >::operator+= ( const DenseMatrix< Other > &  x)
inlineinherited

vector space addition

◆ operator-()

constexpr derived_type Dune::DenseMatrix< DynamicMatrix< K > >::operator- ( ) const
inlineinherited

Matrix negation.

◆ operator-=()

constexpr derived_type& Dune::DenseMatrix< DynamicMatrix< K > >::operator-= ( const DenseMatrix< Other > &  x)
inlineinherited

vector space subtraction

◆ operator/=()

constexpr derived_type& Dune::DenseMatrix< DynamicMatrix< K > >::operator/= ( const field_type k)
inlineinherited

vector space division by scalar

◆ operator=() [1/2]

template<class K>
template<typename T , typename = std::enable_if_t<!Dune::IsNumber<T>::value>>
DynamicMatrix& Dune::DynamicMatrix< K >::operator= ( T const &  rhs)
inline

◆ operator=() [2/2]

template<class K>
template<typename T , typename = std::enable_if_t<Dune::IsNumber<T>::value>>
DynamicMatrix& Dune::DynamicMatrix< K >::operator= ( scalar)
inline

◆ operator==()

constexpr bool Dune::DenseMatrix< DynamicMatrix< K > >::operator== ( const DenseMatrix< Other > &  x) const
inlineinherited

Binary matrix comparison.

◆ operator[]() [1/2]

constexpr row_reference Dune::DenseMatrix< DynamicMatrix< K > >::operator[] ( size_type  i)
inlineinherited

random access

◆ operator[]() [2/2]

constexpr const_row_reference Dune::DenseMatrix< DynamicMatrix< K > >::operator[] ( size_type  i) const
inlineinherited

◆ resize()

template<class K>
void Dune::DynamicMatrix< K >::resize ( size_type  r,
size_type  c,
value_type  v = value_type() 
)
inline

resize matrix to r × c

Resize the matrix to r × c, using v as the value of all entries.

Warning
All previous entries are lost, even when the matrix was not actually resized.
Parameters
rnumber of rows
cnumber of columns
vvalue of matrix entries

◆ rightmultiply()

DynamicMatrix< K > & Dune::DenseMatrix< DynamicMatrix< K > >::rightmultiply ( const DenseMatrix< M2 > &  M)
inlineinherited

Multiplies M from the right to this matrix.

◆ rows()

constexpr size_type Dune::DenseMatrix< DynamicMatrix< K > >::rows ( ) const
inlineinherited

number of rows

◆ size()

constexpr size_type Dune::DenseMatrix< DynamicMatrix< K > >::size ( ) const
inlineinherited

size method (number of rows)

◆ solve()

void Dune::DenseMatrix< DynamicMatrix< K > >::solve ( V1 &  x,
const V2 &  b,
bool  doPivoting = true 
) const
inherited

Solve system A x = b.

Exceptions
FMatrixErrorif the matrix is singular

◆ transposed()

template<class K>
DynamicMatrix Dune::DynamicMatrix< K >::transposed ( ) const
inline

Return transposed of the matrix as DynamicMatrix.

◆ umhv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::umhv ( const X &  x,
Y &  y 
) const
inlineinherited

y += A^H x

◆ umtv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::umtv ( const X &  x,
Y &  y 
) const
inlineinherited

y += A^T x

◆ umv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::umv ( const X &  x,
Y &  y 
) const
inlineinherited

y += A x

◆ usmhv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::usmhv ( const typename FieldTraits< Y >::field_type alpha,
const X &  x,
Y &  y 
) const
inlineinherited

y += alpha A^H x

◆ usmtv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::usmtv ( const typename FieldTraits< Y >::field_type alpha,
const X &  x,
Y &  y 
) const
inlineinherited

y += alpha A^T x

◆ usmv()

constexpr void Dune::DenseMatrix< DynamicMatrix< K > >::usmv ( const typename FieldTraits< Y >::field_type alpha,
const X &  x,
Y &  y 
) const
inlineinherited

y += alpha A x

Member Data Documentation

◆ blocklevel

constexpr int Dune::DenseMatrix< DynamicMatrix< K > >::blocklevel
staticinherited

The number of block levels we contain. This is the leaf, that is, 1.


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