Dune::Matrix< T, A > Class Template Reference
[Sparse Matrix and Vector classes]

A generic dynamic matrix. More...

#include <dune/istl/matrix.hh>

List of all members.

Public Types

enum  { blocklevel = T::blocklevel+1 }
typedef T::field_type field_type
 Export the type representing the underlying field.
typedef T block_type
 Export the type representing the components.
typedef A allocator_type
 Export the allocator.
typedef BlockVector< T > row_type
 The type implementing a matrix row.
typedef A::size_type size_type
 Type for indices and sizes.
typedef BlockVector< row_type >
::iterator 
RowIterator
 Iterator over the matrix rows.
typedef row_type::iterator ColIterator
 Iterator for the entries of each row.
typedef BlockVector< row_type >
::const_iterator 
ConstRowIterator
 Const iterator over the matrix rows.
typedef row_type::const_iterator ConstColIterator
 Const iterator for the entries of each row.

Public Member Functions

 Matrix ()
 Create empty matrix.
 Matrix (size_type rows, size_type cols)
 Create uninitialized matrix of size rows x cols.
void setSize (size_type rows, size_type cols)
 Change the matrix size.
RowIterator begin ()
 Get iterator to first row.
RowIterator end ()
 Get iterator to one beyond last row.
RowIterator rbegin ()
 Get iterator to last row.
RowIterator rend ()
 Get iterator to one before first row.
ConstRowIterator begin () const
 Get const iterator to first row.
ConstRowIterator end () const
 Get const iterator to one beyond last row.
ConstRowIterator rbegin () const
 Get const iterator to last row.
ConstRowIterator rend () const
 Get const iterator to one before first row.
Matrixoperator= (const field_type &t)
 Assignment from scalar.
row_typeoperator[] (size_type row)
 The index operator.
const row_typeoperator[] (size_type row) const
 The const index operator.
size_type N () const
 Return the number of rows.
size_type M () const
 Return the number of columns.
size_type rowdim () const
 The number of scalar rows.
size_type coldim () const
 The number of scalar columns.
size_type rowdim (size_type r) const
 The number of scalar rows.
size_type coldim (size_type c) const
 The number of scalar columns.
Matrix< T > & operator*= (const field_type &scalar)
 Multiplication with a scalar.
Matrix< T > & operator/= (const field_type &scalar)
 Multiplication with a scalar.
Matrixoperator+= (const Matrix &b)
 Add the entries of another matrix to this one.
Matrixoperator-= (const Matrix &b)
 Subtract the entries of another matrix from this one.
Matrix transpose () const
 Return the transpose of the matrix.
template<class X , class Y >
transposedMult (const X &vec)
 Multiplication of the transposed matrix times a vector.
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 mmv (const X &x, Y &y) const
 y -= A x
template<class X , class Y >
void usmv (const field_type &alpha, const X &x, Y &y) const
 $ y += \alpha 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 mmtv (const X &x, Y &y) const
 y -= A^T x
template<class X , class Y >
void usmtv (const field_type &alpha, const X &x, Y &y) const
 y += alpha 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 mmhv (const X &x, Y &y) const
 y -= A^H x
template<class X , class Y >
void usmhv (const field_type &alpha, const X &x, Y &y) const
 y += alpha A^H x
double frobenius_norm () const
 frobenius norm: sqrt(sum over squared values of entries)
double frobenius_norm2 () const
 square of frobenius norm, need for block recursion
double infinity_norm () const
 infinity norm (row sum norm, how to generalize for blocks?)
double infinity_norm_real () const
 simplified infinity norm (uses Manhattan norm for complex values)
bool exists (size_type i, size_type j) const
 return true if (i,j) is in pattern

Protected Attributes

BlockVector< row_type,
allocator_type
data_
size_type cols_

Friends

Matrix< T > operator* (const Matrix< T > &m1, const Matrix< T > &m2)
 Generic matrix multiplication.
template<class X , class Y >
operator* (const Matrix< T > &m, const X &vec)
 Generic matrix-vector multiplication.

Detailed Description

template<class T, class A = ISTLAllocator>
class Dune::Matrix< T, A >

A generic dynamic matrix.

This matrix is currently implemented as a BlockVector of BlockVectors. That makes the code fairly simple, as we get all iterators for free. However, it is not the best way as far as efficiency is concerned.


Member Typedef Documentation

template<class T, class A = ISTLAllocator>
typedef A Dune::Matrix< T, A >::allocator_type

Export the allocator.

template<class T, class A = ISTLAllocator>
typedef T Dune::Matrix< T, A >::block_type

Export the type representing the components.

template<class T, class A = ISTLAllocator>
typedef row_type::iterator Dune::Matrix< T, A >::ColIterator

Iterator for the entries of each row.

template<class T, class A = ISTLAllocator>
typedef row_type::const_iterator Dune::Matrix< T, A >::ConstColIterator

Const iterator for the entries of each row.

template<class T, class A = ISTLAllocator>
typedef BlockVector<row_type>::const_iterator Dune::Matrix< T, A >::ConstRowIterator

Const iterator over the matrix rows.

template<class T, class A = ISTLAllocator>
typedef T::field_type Dune::Matrix< T, A >::field_type

Export the type representing the underlying field.

template<class T, class A = ISTLAllocator>
typedef BlockVector<T> Dune::Matrix< T, A >::row_type

The type implementing a matrix row.

template<class T, class A = ISTLAllocator>
typedef BlockVector<row_type>::iterator Dune::Matrix< T, A >::RowIterator

Iterator over the matrix rows.

template<class T, class A = ISTLAllocator>
typedef A::size_type Dune::Matrix< T, A >::size_type

Type for indices and sizes.


Member Enumeration Documentation

template<class T, class A = ISTLAllocator>
anonymous enum
Enumerator:
blocklevel 

The number of nesting levels the matrix contains.


Constructor & Destructor Documentation

template<class T, class A = ISTLAllocator>
Dune::Matrix< T, A >::Matrix (  )  [inline]

Create empty matrix.

template<class T, class A = ISTLAllocator>
Dune::Matrix< T, A >::Matrix ( size_type  rows,
size_type  cols 
) [inline]

Create uninitialized matrix of size rows x cols.

References Dune::Matrix< T, A >::data_.


Member Function Documentation

template<class T, class A = ISTLAllocator>
ConstRowIterator Dune::Matrix< T, A >::begin (  )  const [inline]

Get const iterator to first row.

References Dune::base_array_unmanaged< B, A >::begin(), and Dune::Matrix< T, A >::data_.

template<class T, class A = ISTLAllocator>
RowIterator Dune::Matrix< T, A >::begin (  )  [inline]
template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::coldim ( size_type  c  )  const [inline]

The number of scalar columns.

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::coldim (  )  const [inline]
template<class T, class A = ISTLAllocator>
ConstRowIterator Dune::Matrix< T, A >::end (  )  const [inline]

Get const iterator to one beyond last row.

References Dune::Matrix< T, A >::data_, and Dune::base_array_unmanaged< B, A >::end().

template<class T, class A = ISTLAllocator>
RowIterator Dune::Matrix< T, A >::end (  )  [inline]
template<class T, class A = ISTLAllocator>
bool Dune::Matrix< T, A >::exists ( size_type  i,
size_type  j 
) const [inline]

return true if (i,j) is in pattern

References Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
double Dune::Matrix< T, A >::frobenius_norm (  )  const [inline]

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

References Dune::Matrix< T, A >::frobenius_norm2().

template<class T, class A = ISTLAllocator>
double Dune::Matrix< T, A >::frobenius_norm2 (  )  const [inline]

square of frobenius norm, need for block recursion

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

Referenced by Dune::Matrix< T, A >::frobenius_norm().

template<class T, class A = ISTLAllocator>
double Dune::Matrix< T, A >::infinity_norm (  )  const [inline]

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

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
double Dune::Matrix< T, A >::infinity_norm_real (  )  const [inline]

simplified infinity norm (uses Manhattan norm for complex values)

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::M (  )  const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::mmhv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::mmtv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::mmv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::mtv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::mv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::N (  )  const [inline]
template<class T, class A = ISTLAllocator>
Matrix<T>& Dune::Matrix< T, A >::operator*= ( const field_type scalar  )  [inline]
template<class T, class A = ISTLAllocator>
Matrix& Dune::Matrix< T, A >::operator+= ( const Matrix< T, A > &  b  )  [inline]

Add the entries of another matrix to this one.

Parameters:
b The matrix to add to this one. Its size has to be the same as the size of this matrix.

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), Dune::Matrix< T, A >::N(), row, and Dune::base_array_unmanaged< B, A >::size().

template<class T, class A = ISTLAllocator>
Matrix& Dune::Matrix< T, A >::operator-= ( const Matrix< T, A > &  b  )  [inline]

Subtract the entries of another matrix from this one.

Parameters:
b The matrix to add to this one. Its size has to be the same as the size of this matrix.

References Dune::Matrix< T, A >::data_, Dune::Matrix< T, A >::M(), Dune::Matrix< T, A >::N(), row, and Dune::base_array_unmanaged< B, A >::size().

template<class T, class A = ISTLAllocator>
Matrix<T>& Dune::Matrix< T, A >::operator/= ( const field_type scalar  )  [inline]
template<class T, class A = ISTLAllocator>
Matrix& Dune::Matrix< T, A >::operator= ( const field_type t  )  [inline]
template<class T, class A = ISTLAllocator>
const row_type& Dune::Matrix< T, A >::operator[] ( size_type  row  )  const [inline]

The const index operator.

References Dune::Matrix< T, A >::data_, and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
row_type& Dune::Matrix< T, A >::operator[] ( size_type  row  )  [inline]

The index operator.

References Dune::Matrix< T, A >::data_, and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
ConstRowIterator Dune::Matrix< T, A >::rbegin (  )  const [inline]

Get const iterator to last row.

References Dune::Matrix< T, A >::data_, and Dune::base_array_unmanaged< B, A >::rbegin().

template<class T, class A = ISTLAllocator>
RowIterator Dune::Matrix< T, A >::rbegin (  )  [inline]
template<class T, class A = ISTLAllocator>
ConstRowIterator Dune::Matrix< T, A >::rend (  )  const [inline]

Get const iterator to one before first row.

References Dune::Matrix< T, A >::data_, and Dune::base_array_unmanaged< B, A >::rend().

template<class T, class A = ISTLAllocator>
RowIterator Dune::Matrix< T, A >::rend (  )  [inline]

Get iterator to one before first row.

References Dune::Matrix< T, A >::data_, and Dune::base_array_unmanaged< B, A >::rend().

template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::rowdim ( size_type  r  )  const [inline]
template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::rowdim (  )  const [inline]
template<class T, class A = ISTLAllocator>
void Dune::Matrix< T, A >::setSize ( size_type  rows,
size_type  cols 
) [inline]

Change the matrix size.

The way the data is handled is unpredictable.

References Dune::Matrix< T, A >::cols_, Dune::Matrix< T, A >::data_, and Dune::BlockVector< B, A >::resize().

template<class T, class A = ISTLAllocator>
Matrix Dune::Matrix< T, A >::transpose (  )  const [inline]

Return the transpose of the matrix.

References Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
template<class X , class Y >
Y Dune::Matrix< T, A >::transposedMult ( const X &  vec  )  [inline]

Multiplication of the transposed matrix times a vector.

References Dune::Matrix< T, A >::M(), and Dune::Matrix< T, A >::N().

template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::umhv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::umtv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::umv ( const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::usmhv ( const field_type alpha,
const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::usmtv ( const field_type alpha,
const X &  x,
Y &  y 
) const [inline]
template<class T, class A = ISTLAllocator>
template<class X , class Y >
void Dune::Matrix< T, A >::usmv ( const field_type alpha,
const X &  x,
Y &  y 
) const [inline]

Friends And Related Function Documentation

template<class T, class A = ISTLAllocator>
template<class X , class Y >
Y operator* ( const Matrix< T > &  m,
const X &  vec 
) [friend]

Generic matrix-vector multiplication.

template<class T, class A = ISTLAllocator>
Matrix<T> operator* ( const Matrix< T > &  m1,
const Matrix< T > &  m2 
) [friend]

Generic matrix multiplication.


Member Data Documentation

template<class T, class A = ISTLAllocator>
size_type Dune::Matrix< T, A >::cols_ [protected]
template<class T, class A = ISTLAllocator>
BlockVector<row_type, allocator_type> Dune::Matrix< T, A >::data_ [protected]

The documentation for this class was generated from the following file:
Generated on Sat Apr 24 11:13:49 2010 for dune-istl by  doxygen 1.6.3