Loading...
Searching...
No Matches
Dune::ScaledIdentityMatrix< K, n > Class Template Reference

A multiple of the identity matrix of static size. More...

`#include <dune/istl/scaledidmatrix.hh>`

## Public Types

typedef K | field_type
| The type representing numbers.
typedef K | block_type
| The type representing matrix entries (which may be matrices themselves).
typedef std::size_t | size_type
| The type used for the indices and sizes.
typedef DiagonalRowVector< K, n > | row_type
| Type of a single matrix row.
typedef row_type | reference
typedef DiagonalRowVectorConst< K, n > | const_row_type
| Const type of a single row.
typedef const_row_type | const_reference
typedef ContainerWrapperIterator< const WrapperType, reference, reference > | Iterator
| Iterator class for sequential access.
typedef Iterator | iterator
| typedef for stl compliant access
typedef Iterator | RowIterator
| rename the iterators for easier access
typedef row_type::Iterator | ColIterator
| rename the iterators for easier access
typedef ContainerWrapperIterator< const WrapperType, const_reference, const_reference > | ConstIterator
| Iterator class for sequential access.
typedef ConstIterator | const_iterator
| typedef for stl compliant access
typedef ConstIterator | ConstRowIterator
| rename the iterators for easier access
typedef const_row_type::ConstIterator | ConstColIterator
| rename the iterators for easier access

## Public Member Functions

| ScaledIdentityMatrix ()
| Default constructor.
| ScaledIdentityMatrix (const K &k)
| Constructor initializing the whole matrix with a scalar.
ScaledIdentityMatrix & | operator= (const K &k)
| Assignment from scalar.
bool | identical (const ScaledIdentityMatrix< K, n > &other) const
| Check if matrix is identical to other matrix.
Iterator | begin ()
| begin iterator
Iterator | end ()
| end iterator
Iterator | beforeEnd ()
Iterator | beforeBegin ()
ConstIterator | begin () const
| begin iterator
ConstIterator | end () const
| end iterator
ConstIterator | beforeEnd () const
ConstIterator | beforeBegin () const
bool | operator== (const ScaledIdentityMatrix &other) const
| Test for equality.
bool | operator!= (const ScaledIdentityMatrix &other) const
| Test for inequality.
template<class V>
void | solve (V &x, const V &b) const
| Solve linear system A x = b.
void | invert ()
| Compute inverse.
K | determinant () const
| Calculates the determinant of this matrix.
size_type | N () const
| number of blocks in row direction
size_type | M () const
| number of blocks in column direction
bool | exists (size_type i, size_type j) const
| Return true if (i,j) is in the matrix pattern, i.e., if i==j.
reference | operator[] (size_type i)
| Return reference object as row replacement.
const_reference | operator[] (size_type i) const
| Return const_reference object as row replacement.
const K & | diagonal (size_type) const
| Get const reference to diagonal entry.
K & | diagonal (size_type)
| Get reference to diagonal entry.
const K & | scalar () const
| Get const reference to the scalar diagonal value.
K & | scalar ()
| Get reference to the scalar diagonal value.
Matrix-vector products
template<class X, class Y>
void | mv (const X &x, Y &y) const
| y = A x
template<class X, class Y>
void | mtv (const X &x, Y &y) const
| y = A^T x
template<class X, class Y>
void | umv (const X &x, Y &y) const
| y += A x
template<class X, class Y>
void | umtv (const X &x, Y &y) const
| y += A^T x
template<class X, class Y>
void | umhv (const X &x, Y &y) const
| y += A^H x
template<class X, class Y>
void | mmv (const X &x, Y &y) const
| y -= A x
template<class X, class Y>
void | mmtv (const X &x, Y &y) const
| y -= A^T x
template<class X, class Y>
void | mmhv (const X &x, Y &y) const
| y -= A^H x
template<class X, class Y>
void | usmv (const K &alpha, const X &x, Y &y) const
| y += alpha A x
template<class X, class Y>
void | usmtv (const K &alpha, const X &x, Y &y) const
| y += alpha A^T x
template<class X, class Y>
void | usmhv (const K &alpha, const X &x, Y &y) const
| y += alpha A^H x
Norms
FieldTraits< field_type >::real_type | frobenius_norm () const
| The Frobenius norm.
FieldTraits< field_type >::real_type | frobenius_norm2 () const
| The square of the Frobenius norm.
FieldTraits< field_type >::real_type | infinity_norm () const
| The row sum norm.
FieldTraits< field_type >::real_type | infinity_norm_real () const
| simplified infinity norm (uses Manhattan norm for complex values)

## Static Public Attributes

static constexpr std::integral_constant< size_type, n > | rows = {}
| The number of matrix rows.
static constexpr std::integral_constant< size_type, n > | cols = {}
| The number of matrix columns.

## Friends

std::ostream & | operator<< (std::ostream &s, const ScaledIdentityMatrix< K, n > &a)
| Sends the matrix to an output stream.

## Vector space arithmetic

ScaledIdentityMatrix & | operator+= (const ScaledIdentityMatrix &y)
| Vector space addition.
ScaledIdentityMatrix & | operator-= (const ScaledIdentityMatrix &y)
| Vector space subtraction.
ScaledIdentityMatrix & | operator+= (const K &k)
| Addition of a scalar to the diagonal.
ScaledIdentityMatrix & | operator-= (const K &k)
| Subtraction of a scalar from the diagonal.
ScaledIdentityMatrix & | operator*= (const K &k)
| Vector space multiplication with scalar.
ScaledIdentityMatrix & | operator/= (const K &k)
| Vector space division by scalar.
template<class Scalar, std::enable_if_t< IsNumber< Scalar >::value, int > = 0>
auto | operator* (const ScaledIdentityMatrix &matrix, Scalar scalar)
| Vector space multiplication with scalar.
template<class Scalar, std::enable_if_t< IsNumber< Scalar >::value, int > = 0>
auto | operator* (Scalar scalar, const ScaledIdentityMatrix &matrix)
| Vector space multiplication with scalar.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto & | operator+= (FieldMatrix< OtherScalar, n, n > &fieldMatrix, const ScaledIdentityMatrix &matrix)
| Addition of ScaledIdentityMatrix to FieldMatrix.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto | operator+ (const FieldMatrix< OtherScalar, n, n > &fieldMatrix, const ScaledIdentityMatrix &matrix)
| Addition of ScaledIdentityMatrix to FieldMatrix.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto | operator+ (const ScaledIdentityMatrix &matrix, const FieldMatrix< OtherScalar, n, n > &fieldMatrix)
| Addition of FieldMatrix to ScaledIdentityMatrix.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto | operator+= (DiagonalMatrix< OtherScalar, n > &diagonalMatrix, const ScaledIdentityMatrix &matrix)
| Addition of ScaledIdentityMatrix to DiagonalMatrix.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto | operator+ (const DiagonalMatrix< OtherScalar, n > &diagonalMatrix, const ScaledIdentityMatrix &matrix)
| Addition of ScaledIdentityMatrix to DiagonalMatrix.
template<class OtherScalar> requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }
auto | operator+ (const ScaledIdentityMatrix &matrix, const DiagonalMatrix< OtherScalar, n > &diagonalMatrix)
| Addition of DiagonalMatrix to ScaledIdentityMatrix.

## Detailed Description

template<class K, int n>
class Dune::ScaledIdentityMatrix< K, n >

A multiple of the identity matrix of static size.

This class provides all operations specified by the dune-istl matrix API. The implementations exploit the fact that the matrix is a multiple of the identity.

Template Parameters

  K | The number used for matrix entries
  n | The number of matrix rows and columns

Warning
  If m is an object of type ScaledIdentityMatrix, then code like
  K entry = m[0][1];
  will compile. However, the expression m[0][1] is not guaranteed to return 0. Rather, its behavior is undefined.

## Member Typedef Documentation

## block_type

template<class K, int n>

typedef K Dune::ScaledIdentityMatrix< K, n >::block_type

The type representing matrix entries (which may be matrices themselves).

## ColIterator

template<class K, int n>

typedef row_type::Iterator Dune::ScaledIdentityMatrix< K, n >::ColIterator

rename the iterators for easier access

## const_iterator

template<class K, int n>

typedef ConstIterator Dune::ScaledIdentityMatrix< K, n >::const_iterator

typedef for stl compliant access

## const_reference

template<class K, int n>

typedef const_row_type Dune::ScaledIdentityMatrix< K, n >::const_reference

## const_row_type

template<class K, int n>

typedef DiagonalRowVectorConst<K,n> Dune::ScaledIdentityMatrix< K, n >::const_row_type

Const type of a single row.

## ConstColIterator

template<class K, int n>

typedef const_row_type::ConstIterator Dune::ScaledIdentityMatrix< K, n >::ConstColIterator

rename the iterators for easier access

## ConstIterator

template<class K, int n>

typedef ContainerWrapperIterator<const WrapperType, const_reference, const_reference> Dune::ScaledIdentityMatrix< K, n >::ConstIterator

Iterator class for sequential access.

## ConstRowIterator

template<class K, int n>

typedef ConstIterator Dune::ScaledIdentityMatrix< K, n >::ConstRowIterator

rename the iterators for easier access

## field_type

template<class K, int n>

typedef K Dune::ScaledIdentityMatrix< K, n >::field_type

The type representing numbers.

## Iterator

template<class K, int n>

typedef ContainerWrapperIterator<const WrapperType, reference, reference> Dune::ScaledIdentityMatrix< K, n >::Iterator

Iterator class for sequential access.

## iterator

template<class K, int n>

typedef Iterator Dune::ScaledIdentityMatrix< K, n >::iterator

typedef for stl compliant access

## reference

template<class K, int n>

typedef row_type Dune::ScaledIdentityMatrix< K, n >::reference

## row_type

template<class K, int n>

typedef DiagonalRowVector<K,n> Dune::ScaledIdentityMatrix< K, n >::row_type

Type of a single matrix row.

Since the implementation does not store actual rows, this is a proxy type, which tries to behave like an array of matrix entries as much as possible.

Note
  The type is really DiagonalRowVector. Implementing a dedicated ScaledIdentityMatrixRowVector would just be a copy of that.

## RowIterator

template<class K, int n>

typedef Iterator Dune::ScaledIdentityMatrix< K, n >::RowIterator

rename the iterators for easier access

## size_type

template<class K, int n>

typedef std::size_t Dune::ScaledIdentityMatrix< K, n >::size_type

The type used for the indices and sizes.

## Constructor & Destructor Documentation

## ScaledIdentityMatrix() [1/2]

template<class K, int n>

Dune::ScaledIdentityMatrix< K, n >::ScaledIdentityMatrix | ( |  | ) |

inline

Default constructor.

## ScaledIdentityMatrix() [2/2]

template<class K, int n>

Dune::ScaledIdentityMatrix< K, n >::ScaledIdentityMatrix | ( | const K & | k | ) |

inline

Constructor initializing the whole matrix with a scalar.

## Member Function Documentation

## beforeBegin() [1/2]

template<class K, int n>

Iterator Dune::ScaledIdentityMatrix< K, n >::beforeBegin | ( |  | ) |

inline

Returns
  an iterator that is positioned before the first row of the matrix.

## beforeBegin() [2/2]

template<class K, int n>

ConstIterator Dune::ScaledIdentityMatrix< K, n >::beforeBegin | ( |  | ) | const

inline

Returns
  an iterator that is positioned before the first row of the matrix.

## beforeEnd() [1/2]

template<class K, int n>

Iterator Dune::ScaledIdentityMatrix< K, n >::beforeEnd | ( |  | ) |

inline

Returns
  an iterator that is positioned before the end iterator of the rows, i.e. at the last row.

## beforeEnd() [2/2]

template<class K, int n>

ConstIterator Dune::ScaledIdentityMatrix< K, n >::beforeEnd | ( |  | ) | const

inline

Returns
  an iterator that is positioned before the end iterator of the rows. i.e. at the last row.

## begin() [1/2]

template<class K, int n>

Iterator Dune::ScaledIdentityMatrix< K, n >::begin | ( |  | ) |

inline

begin iterator

## begin() [2/2]

template<class K, int n>

ConstIterator Dune::ScaledIdentityMatrix< K, n >::begin | ( |  | ) | const

inline

begin iterator

## determinant()

template<class K, int n>

K Dune::ScaledIdentityMatrix< K, n >::determinant | ( |  | ) | const

inline

Calculates the determinant of this matrix.

## diagonal() [1/2]

template<class K, int n>

K & Dune::ScaledIdentityMatrix< K, n >::diagonal | ( | size_type |  | ) |

inline

Get reference to diagonal entry.

## diagonal() [2/2]

template<class K, int n>

const K & Dune::ScaledIdentityMatrix< K, n >::diagonal | ( | size_type |  | ) | const

inline

Get const reference to diagonal entry.

## end() [1/2]

template<class K, int n>

Iterator Dune::ScaledIdentityMatrix< K, n >::end | ( |  | ) |

inline

end iterator

## end() [2/2]

template<class K, int n>

ConstIterator Dune::ScaledIdentityMatrix< K, n >::end | ( |  | ) | const

inline

end iterator

## exists()

template<class K, int n>

bool Dune::ScaledIdentityMatrix< K, n >::exists | ( | size_type | i,
|  | size_type | j ) const

inline

Return true if (i,j) is in the matrix pattern, i.e., if i==j.

## frobenius_norm()

template<class K, int n>

FieldTraits< field_type >::real_type Dune::ScaledIdentityMatrix< K, n >::frobenius_norm | ( |  | ) | const

inline

The Frobenius norm.

## frobenius_norm2()

template<class K, int n>

FieldTraits< field_type >::real_type Dune::ScaledIdentityMatrix< K, n >::frobenius_norm2 | ( |  | ) | const

inline

The square of the Frobenius norm.

## identical()

template<class K, int n>

bool Dune::ScaledIdentityMatrix< K, n >::identical | ( | const ScaledIdentityMatrix< K, n > & | other | ) | const

inline

Check if matrix is identical to other matrix.

"Identical" means: Not just the same values, but the very same object.

## infinity_norm()

template<class K, int n>

FieldTraits< field_type >::real_type Dune::ScaledIdentityMatrix< K, n >::infinity_norm | ( |  | ) | const

inline

The row sum norm.

For a multiple of the identity matrix, this is simply the absolute value of any diagonal matrix entry.

## infinity_norm_real()

template<class K, int n>

FieldTraits< field_type >::real_type Dune::ScaledIdentityMatrix< K, n >::infinity_norm_real | ( |  | ) | const

inline

simplified infinity norm (uses Manhattan norm for complex values)

## invert()

template<class K, int n>

void Dune::ScaledIdentityMatrix< K, n >::invert | ( |  | ) |

inline

Compute inverse.

## M()

template<class K, int n>

size_type Dune::ScaledIdentityMatrix< K, n >::M | ( |  | ) | const

inline

number of blocks in column direction

## mmhv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::mmhv | ( | const X & | x,
|  | Y & | y ) const

inline

y -= A^H x

## mmtv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::mmtv | ( | const X & | x,
|  | Y & | y ) const

inline

y -= A^T x

## mmv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::mmv | ( | const X & | x,
|  | Y & | y ) const

inline

y -= A x

## mtv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::mtv | ( | const X & | x,
|  | Y & | y ) const

inline

y = A^T x

## mv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::mv | ( | const X & | x,
|  | Y & | y ) const

inline

y = A x

## N()

template<class K, int n>

size_type Dune::ScaledIdentityMatrix< K, n >::N | ( |  | ) | const

inline

number of blocks in row direction

## operator!=()

template<class K, int n>

bool Dune::ScaledIdentityMatrix< K, n >::operator!= | ( | const ScaledIdentityMatrix< K, n > & | other | ) | const

inline

Test for inequality.

## operator*=()

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator*= | ( | const K & | k | ) |

inline

Vector space multiplication with scalar.

## operator+=() [1/2]

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator+= | ( | const K & | k | ) |

inline

Addition of a scalar to the diagonal.

Warning
  This is not the same as adding a scalar to a FieldMatrix!

## operator+=() [2/2]

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator+= | ( | const ScaledIdentityMatrix< K, n > & | y | ) |

inline

Vector space addition.

## operator-=() [1/2]

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator-= | ( | const K & | k | ) |

inline

Subtraction of a scalar from the diagonal.

Warning
  This is not the same as subtracting a scalar from a FieldMatrix!

## operator-=() [2/2]

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator-= | ( | const ScaledIdentityMatrix< K, n > & | y | ) |

inline

Vector space subtraction.

## operator/=()

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator/= | ( | const K & | k | ) |

inline

Vector space division by scalar.

## operator=()

template<class K, int n>

ScaledIdentityMatrix & Dune::ScaledIdentityMatrix< K, n >::operator= | ( | const K & | k | ) |

inline

Assignment from scalar.

## operator==()

template<class K, int n>

bool Dune::ScaledIdentityMatrix< K, n >::operator== | ( | const ScaledIdentityMatrix< K, n > & | other | ) | const

inline

Test for equality.

## operator[]() [1/2]

template<class K, int n>

reference Dune::ScaledIdentityMatrix< K, n >::operator[] | ( | size_type | i | ) |

inline

Return reference object as row replacement.

## operator[]() [2/2]

template<class K, int n>

const_reference Dune::ScaledIdentityMatrix< K, n >::operator[] | ( | size_type | i | ) | const

inline

Return const_reference object as row replacement.

## scalar() [1/2]

template<class K, int n>

K & Dune::ScaledIdentityMatrix< K, n >::scalar | ( |  | ) |

inline

Get reference to the scalar diagonal value.

## scalar() [2/2]

template<class K, int n>

const K & Dune::ScaledIdentityMatrix< K, n >::scalar | ( |  | ) | const

inline

Get const reference to the scalar diagonal value.

## solve()

template<class K, int n>
template<class V>

void Dune::ScaledIdentityMatrix< K, n >::solve | ( | V & | x,
|  | const V & | b ) const

inline

Solve linear system A x = b.

Template Parameters

  V | Vector data type

## umhv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::umhv | ( | const X & | x,
|  | Y & | y ) const

inline

y += A^H x

## umtv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::umtv | ( | const X & | x,
|  | Y & | y ) const

inline

y += A^T x

## umv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::umv | ( | const X & | x,
|  | Y & | y ) const

inline

y += A x

## usmhv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::usmhv | ( | const K & | alpha,
|  | const X & | x,
|  | Y & | y ) const

inline

y += alpha A^H x

## usmtv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::usmtv | ( | const K & | alpha,
|  | const X & | x,
|  | Y & | y ) const

inline

y += alpha A^T x

## usmv()

template<class K, int n>
template<class X, class Y>

void Dune::ScaledIdentityMatrix< K, n >::usmv | ( | const K & | alpha,
|  | const X & | x,
|  | Y & | y ) const

inline

y += alpha A x

## Friends And Related Symbol Documentation

## operator* [1/2]

template<class K, int n>
template<class Scalar, std::enable_if_t< IsNumber< Scalar >::value, int > = 0>

auto operator* | ( | const ScaledIdentityMatrix< K, n > & | matrix,
|  | Scalar | scalar )

friend

Vector space multiplication with scalar.

## operator* [2/2]

template<class K, int n>
template<class Scalar, std::enable_if_t< IsNumber< Scalar >::value, int > = 0>

auto operator* | ( | Scalar | scalar,
|  | const ScaledIdentityMatrix< K, n > & | matrix )

friend

Vector space multiplication with scalar.

## operator+ [1/4]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto operator+ | ( | const DiagonalMatrix< OtherScalar, n > & | diagonalMatrix,
|  | const ScaledIdentityMatrix< K, n > & | matrix )

friend

Addition of ScaledIdentityMatrix to DiagonalMatrix.

## operator+ [2/4]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto operator+ | ( | const FieldMatrix< OtherScalar, n, n > & | fieldMatrix,
|  | const ScaledIdentityMatrix< K, n > & | matrix )

friend

Addition of ScaledIdentityMatrix to FieldMatrix.

## operator+ [3/4]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto operator+ | ( | const ScaledIdentityMatrix< K, n > & | matrix,
|  | const DiagonalMatrix< OtherScalar, n > & | diagonalMatrix )

friend

Addition of DiagonalMatrix to ScaledIdentityMatrix.

## operator+ [4/4]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto operator+ | ( | const ScaledIdentityMatrix< K, n > & | matrix,
|  | const FieldMatrix< OtherScalar, n, n > & | fieldMatrix )

friend

Addition of FieldMatrix to ScaledIdentityMatrix.

## operator+= [1/2]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto operator+= | ( | DiagonalMatrix< OtherScalar, n > & | diagonalMatrix,
|  | const ScaledIdentityMatrix< K, n > & | matrix )

friend

Addition of ScaledIdentityMatrix to DiagonalMatrix.

## operator+= [2/2]

template<class K, int n>
template<class OtherScalar>
requires requires(K k, OtherScalar otherScalar) { k + otherScalar; }

auto & operator+= | ( | FieldMatrix< OtherScalar, n, n > & | fieldMatrix,
|  | const ScaledIdentityMatrix< K, n > & | matrix )

friend

Addition of ScaledIdentityMatrix to FieldMatrix.

## operator<<

template<class K, int n>

std::ostream & operator<< | ( | std::ostream & | s,
|  | const ScaledIdentityMatrix< K, n > & | a )

friend

Sends the matrix to an output stream.

## Member Data Documentation

## cols

template<class K, int n>

std::integral_constant<size_type,n> Dune::ScaledIdentityMatrix< K, n >::cols = {}

static constexpr

The number of matrix columns.

## rows

template<class K, int n>

std::integral_constant<size_type,n> Dune::ScaledIdentityMatrix< K, n >::rows = {}

static constexpr

The number of matrix rows.

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

- scaledidmatrix.hh