dune-common  2.5-git
Public Types | Public Member Functions | Friends | List of all members
Dune::DiagonalMatrix< K, n > Class Template Reference

A diagonal matrix of static size. More...

#include <dune/common/diagonalmatrix.hh>

Public Types

enum  { blocklevel = 1 }
 We are at the leaf of the block recursion. More...
 
enum  { rows = n, cols = n }
 export size More...
 
typedef K value_type
 export the type representing the field More...
 
typedef value_type field_type
 
typedef K block_type
 export the type representing the components More...
 
typedef std::size_t size_type
 The type used for the index access and size operations. More...
 
typedef DiagonalRowVector< K, n > row_type
 Each row is implemented by a field vector. More...
 
typedef row_type reference
 
typedef row_type row_reference
 
typedef DiagonalRowVectorConst< K, n > const_row_type
 
typedef const_row_type const_reference
 
typedef const_row_type const_row_reference
 
typedef ContainerWrapperIterator< const WrapperType, reference, 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 row_type::Iterator ColIterator
 rename the iterators for easier access More...
 
typedef ContainerWrapperIterator< const WrapperType, const_reference, const_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 const_row_type::ConstIterator ConstColIterator
 rename the iterators for easier access More...
 

Public Member Functions

size_type size () const
 
 DiagonalMatrix ()
 Default constructor. More...
 
 DiagonalMatrix (const K &k)
 Constructor initializing the whole matrix with a scalar. More...
 
 DiagonalMatrix (const FieldVector< K, n > &diag)
 Constructor initializing the diagonal with a vector. More...
 
 DiagonalMatrix (std::initializer_list< K > const &l)
 Construct diagonal matrix from an initializer list. More...
 
DiagonalMatrixoperator= (const K &k)
 Assignment from a scalar. More...
 
bool identical (const DiagonalMatrix< K, n > &other) const
 Check if matrix is the same object as the other matrix. More...
 
Iterator begin ()
 begin iterator More...
 
Iterator end ()
 end iterator More...
 
Iterator beforeEnd ()
 
Iterator beforeBegin ()
 
ConstIterator begin () const
 begin iterator More...
 
ConstIterator end () const
 end iterator More...
 
ConstIterator beforeEnd () const
 
ConstIterator beforeBegin () const
 
DiagonalMatrixoperator+= (const DiagonalMatrix &y)
 vector space addition More...
 
DiagonalMatrixoperator-= (const DiagonalMatrix &y)
 vector space subtraction More...
 
DiagonalMatrixoperator+= (const K &k)
 vector space multiplication with scalar More...
 
DiagonalMatrixoperator-= (const K &k)
 vector space division by scalar More...
 
DiagonalMatrixoperator*= (const K &k)
 vector space multiplication with scalar More...
 
DiagonalMatrixoperator/= (const K &k)
 vector space division by scalar More...
 
bool operator== (const DiagonalMatrix &other) const
 comparison operator More...
 
bool operator!= (const DiagonalMatrix &other) const
 incomparison operator More...
 
template<class X , class Y >
void mv (const X &x, Y &y) const
 y = A x More...
 
template<class X , class Y >
void mtv (const X &x, Y &y) const
 y = A^T x More...
 
template<class X , class Y >
void umv (const X &x, Y &y) const
 y += A x More...
 
template<class X , class Y >
void umtv (const X &x, Y &y) const
 y += A^T x More...
 
template<class X , class Y >
void umhv (const X &x, Y &y) const
 y += A^H x More...
 
template<class X , class Y >
void mmv (const X &x, Y &y) const
 y -= A x More...
 
template<class X , class Y >
void mmtv (const X &x, Y &y) const
 y -= A^T x More...
 
template<class X , class Y >
void mmhv (const X &x, Y &y) const
 y -= A^H x More...
 
template<class X , class Y >
void usmv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A x More...
 
template<class X , class Y >
void usmtv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A^T x More...
 
template<class X , class Y >
void usmhv (const typename FieldTraits< Y >::field_type &alpha, const X &x, Y &y) const
 y += alpha A^H x More...
 
double frobenius_norm () const
 frobenius norm: sqrt(sum over squared values of entries) More...
 
double frobenius_norm2 () const
 square of frobenius norm, need for block recursion More...
 
double infinity_norm () const
 infinity norm (row sum norm, how to generalize for blocks?) More...
 
double infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values) More...
 
template<class V >
void solve (V &x, const V &b) const
 Solve system A x = b. More...
 
void invert ()
 Compute inverse. More...
 
determinant () const
 calculates the determinant of this matrix More...
 
size_type N () const
 number of blocks in row direction More...
 
size_type M () const
 number of blocks in column direction More...
 
bool exists (size_type i, size_type j) const
 return true when (i,j) is in pattern More...
 
reference operator[] (size_type i)
 Return reference object as row replacement. More...
 
const_reference operator[] (size_type i) const
 Return const_reference object as row replacement. More...
 
const K & diagonal (size_type i) const
 Get const reference to diagonal entry. More...
 
K & diagonal (size_type i)
 Get reference to diagonal entry. More...
 
const FieldVector< K, n > & diagonal () const
 Get const reference to diagonal vector. More...
 
FieldVector< K, n > & diagonal ()
 Get reference to diagonal vector. More...
 

Friends

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

Detailed Description

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

A diagonal matrix of static size.

This is meant to be a replacement of FieldMatrix for the case that it is a diagonal matrix.

Template Parameters
KType used for scalars
nMatrix size

Member Typedef Documentation

§ block_type

template<class K, int n>
typedef K Dune::DiagonalMatrix< K, n >::block_type

export the type representing the components

§ ColIterator

template<class K, int n>
typedef row_type::Iterator Dune::DiagonalMatrix< K, n >::ColIterator

rename the iterators for easier access

§ const_iterator

template<class K, int n>
typedef ConstIterator Dune::DiagonalMatrix< K, n >::const_iterator

typedef for stl compliant access

§ const_reference

template<class K, int n>
typedef const_row_type Dune::DiagonalMatrix< K, n >::const_reference

§ const_row_reference

template<class K, int n>
typedef const_row_type Dune::DiagonalMatrix< K, n >::const_row_reference

§ const_row_type

template<class K, int n>
typedef DiagonalRowVectorConst<K,n> Dune::DiagonalMatrix< K, n >::const_row_type

§ ConstColIterator

template<class K, int n>
typedef const_row_type::ConstIterator Dune::DiagonalMatrix< K, n >::ConstColIterator

rename the iterators for easier access

§ ConstIterator

Iterator class for sequential access.

§ ConstRowIterator

template<class K, int n>
typedef ConstIterator Dune::DiagonalMatrix< K, n >::ConstRowIterator

rename the iterators for easier access

§ field_type

template<class K, int n>
typedef value_type Dune::DiagonalMatrix< K, n >::field_type

§ Iterator

template<class K, int n>
typedef ContainerWrapperIterator<const WrapperType, reference, reference> Dune::DiagonalMatrix< K, n >::Iterator

Iterator class for sequential access.

§ iterator

template<class K, int n>
typedef Iterator Dune::DiagonalMatrix< K, n >::iterator

typedef for stl compliant access

§ reference

template<class K, int n>
typedef row_type Dune::DiagonalMatrix< K, n >::reference

§ row_reference

template<class K, int n>
typedef row_type Dune::DiagonalMatrix< K, n >::row_reference

§ row_type

template<class K, int n>
typedef DiagonalRowVector<K,n> Dune::DiagonalMatrix< K, n >::row_type

Each row is implemented by a field vector.

§ RowIterator

template<class K, int n>
typedef Iterator Dune::DiagonalMatrix< K, n >::RowIterator

rename the iterators for easier access

§ size_type

template<class K, int n>
typedef std::size_t Dune::DiagonalMatrix< K, n >::size_type

The type used for the index access and size operations.

§ value_type

template<class K, int n>
typedef K Dune::DiagonalMatrix< K, n >::value_type

export the type representing the field

Member Enumeration Documentation

§ anonymous enum

template<class K, int n>
anonymous enum

We are at the leaf of the block recursion.

Enumerator
blocklevel 

The number of block levels we contain. This is 1.

§ anonymous enum

template<class K, int n>
anonymous enum

export size

Enumerator
rows 

The number of rows.

cols 

The number of columns.

Constructor & Destructor Documentation

§ DiagonalMatrix() [1/4]

template<class K, int n>
Dune::DiagonalMatrix< K, n >::DiagonalMatrix ( )
inline

Default constructor.

§ DiagonalMatrix() [2/4]

template<class K, int n>
Dune::DiagonalMatrix< K, n >::DiagonalMatrix ( const K &  k)
inline

Constructor initializing the whole matrix with a scalar.

§ DiagonalMatrix() [3/4]

template<class K, int n>
Dune::DiagonalMatrix< K, n >::DiagonalMatrix ( const FieldVector< K, n > &  diag)
inline

Constructor initializing the diagonal with a vector.

§ DiagonalMatrix() [4/4]

template<class K, int n>
Dune::DiagonalMatrix< K, n >::DiagonalMatrix ( std::initializer_list< K > const &  l)
inline

Construct diagonal matrix from an initializer list.

The elements of the list are copied into the diagonal elements of the matrix. If the initializer list is shorter than the matrix diagonal (which has n elements), the remaining matrix diagonal elements are left uninitialized. If the initializer list is longer, than only the first n elements will be copied into the matrix diagonal.

Member Function Documentation

§ beforeBegin() [1/2]

template<class K, int n>
Iterator Dune::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< K, n >::begin ( )
inline

begin iterator

§ begin() [2/2]

template<class K, int n>
ConstIterator Dune::DiagonalMatrix< K, n >::begin ( ) const
inline

begin iterator

§ determinant()

template<class K, int n>
K Dune::DiagonalMatrix< K, n >::determinant ( ) const
inline

calculates the determinant of this matrix

§ diagonal() [1/4]

template<class K, int n>
const K& Dune::DiagonalMatrix< K, n >::diagonal ( size_type  i) const
inline

Get const reference to diagonal entry.

§ diagonal() [2/4]

template<class K, int n>
K& Dune::DiagonalMatrix< K, n >::diagonal ( size_type  i)
inline

Get reference to diagonal entry.

§ diagonal() [3/4]

template<class K, int n>
const FieldVector<K,n>& Dune::DiagonalMatrix< K, n >::diagonal ( ) const
inline

Get const reference to diagonal vector.

§ diagonal() [4/4]

template<class K, int n>
FieldVector<K,n>& Dune::DiagonalMatrix< K, n >::diagonal ( )
inline

Get reference to diagonal vector.

§ end() [1/2]

template<class K, int n>
Iterator Dune::DiagonalMatrix< K, n >::end ( )
inline

end iterator

§ end() [2/2]

template<class K, int n>
ConstIterator Dune::DiagonalMatrix< K, n >::end ( ) const
inline

end iterator

§ exists()

template<class K, int n>
bool Dune::DiagonalMatrix< K, n >::exists ( size_type  i,
size_type  j 
) const
inline

return true when (i,j) is in pattern

§ frobenius_norm()

template<class K, int n>
double Dune::DiagonalMatrix< K, n >::frobenius_norm ( ) const
inline

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

§ frobenius_norm2()

template<class K, int n>
double Dune::DiagonalMatrix< K, n >::frobenius_norm2 ( ) const
inline

square of frobenius norm, need for block recursion

§ identical()

template<class K, int n>
bool Dune::DiagonalMatrix< K, n >::identical ( const DiagonalMatrix< K, n > &  other) const
inline

Check if matrix is the same object as the other matrix.

§ infinity_norm()

template<class K, int n>
double Dune::DiagonalMatrix< K, n >::infinity_norm ( ) const
inline

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

§ infinity_norm_real()

template<class K, int n>
double Dune::DiagonalMatrix< K, n >::infinity_norm_real ( ) const
inline

simplified infinity norm (uses Manhattan norm for complex values)

§ invert()

template<class K, int n>
void Dune::DiagonalMatrix< K, n >::invert ( )
inline

Compute inverse.

§ M()

template<class K, int n>
size_type Dune::DiagonalMatrix< K, n >::M ( ) const
inline

number of blocks in column direction

§ mmhv()

template<class K, int n>
template<class X , class Y >
void Dune::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< K, n >::mv ( const X &  x,
Y &  y 
) const
inline

y = A x

§ N()

template<class K, int n>
size_type Dune::DiagonalMatrix< K, n >::N ( ) const
inline

number of blocks in row direction

§ operator!=()

template<class K, int n>
bool Dune::DiagonalMatrix< K, n >::operator!= ( const DiagonalMatrix< K, n > &  other) const
inline

incomparison operator

§ operator*=()

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator*= ( const K &  k)
inline

vector space multiplication with scalar

§ operator+=() [1/2]

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator+= ( const DiagonalMatrix< K, n > &  y)
inline

vector space addition

§ operator+=() [2/2]

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator+= ( const K &  k)
inline

vector space multiplication with scalar

§ operator-=() [1/2]

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator-= ( const DiagonalMatrix< K, n > &  y)
inline

vector space subtraction

§ operator-=() [2/2]

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator-= ( const K &  k)
inline

vector space division by scalar

§ operator/=()

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator/= ( const K &  k)
inline

vector space division by scalar

§ operator=()

template<class K, int n>
DiagonalMatrix& Dune::DiagonalMatrix< K, n >::operator= ( const K &  k)
inline

Assignment from a scalar.

§ operator==()

template<class K, int n>
bool Dune::DiagonalMatrix< K, n >::operator== ( const DiagonalMatrix< K, n > &  other) const
inline

comparison operator

§ operator[]() [1/2]

template<class K, int n>
reference Dune::DiagonalMatrix< K, n >::operator[] ( size_type  i)
inline

Return reference object as row replacement.

§ operator[]() [2/2]

template<class K, int n>
const_reference Dune::DiagonalMatrix< K, n >::operator[] ( size_type  i) const
inline

Return const_reference object as row replacement.

§ size()

template<class K, int n>
size_type Dune::DiagonalMatrix< K, n >::size ( ) const
inline

§ solve()

template<class K, int n>
template<class V >
void Dune::DiagonalMatrix< K, n >::solve ( V &  x,
const V &  b 
) const
inline

Solve system A x = b.

§ umhv()

template<class K, int n>
template<class X , class Y >
void Dune::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< 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::DiagonalMatrix< K, n >::usmhv ( const typename FieldTraits< Y >::field_type 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::DiagonalMatrix< K, n >::usmtv ( const typename FieldTraits< Y >::field_type 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::DiagonalMatrix< K, n >::usmv ( const typename FieldTraits< Y >::field_type alpha,
const X &  x,
Y &  y 
) const
inline

y += alpha A x

Friends And Related Function Documentation

§ operator<<

template<class K, int n>
std::ostream& operator<< ( std::ostream &  s,
const DiagonalMatrix< K, n > &  a 
)
friend

Sends the matrix to an output stream.


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