SysMatrix< T > Class Template Reference

A class template for handling describing linear operators on GridVec<T> objects. More...

#include <SysMatrix.hpp>

Collaboration diagram for SysMatrix< T >:

Collaboration graph
[legend]
List of all members.

Public Member Functions

SparseMatrix< T > & operator() (int i, int j)
 Returns the block (i, j).
SparseMatrix< T > * FIBlock (int row)
 Returns the first initialized block in a row.
void AttachCoarse (SysMatrix< T > *the_coarse)
 Access to the coarser level.
SysMatrix< T > * Coarse ()
int NRows () const
 Returns the number of rows.
int NCols () const
 Returns the number of columns.
bool IsDstVector (GridVec< T > &x)
 Returns true if 'x' has the right size for the range of the matrix.
void Reset (int the_n_rows, int the_n_cols)
 Sets merely the number of blocks.
void Reset (int the_n_rows, int the_n_cols, const Array< Array< int > > &grid_sizes, const Array< int > &src_blk_size, const Array< int > &dst_blk_size, const Array< int > &min_line_entries)
 Sets the sizes for the blocks.
void Reset (int the_n_rows, int the_n_cols, const Array< Array< int > > &grid_sizes, const Array< int > &min_line_entries)
 Sets the sizes if the blocks are scalar matrices.
void Reset (const Array< int > &grid_sizes, int the_src_block_size, int the_dst_block_size, int the_min_line_entries=0)
 Makes a one-row-one-column system.
void Reset (const Array< int > &grid_sizes, int the_min_line_entries=0)
 Makes a one-row-one-column system (the scalar version).
 SysMatrix ()
 Creates a dummy object.
 SysMatrix (const SysMatrix< T > &src)
 Duplication.
 SysMatrix (int the_n_rows, int the_n_cols)
 Merely sets the numbers of the blocks.
 SysMatrix (int the_n_rows, int the_n_columns, const Array< Array< int > > &grid_sizes, const Array< int > &src_blk_size, const Array< int > &dst_blk_size, const Array< int > &min_line_entries)
 cf. the remark for 'Reset'
 SysMatrix (int the_n_rows, int the_n_columns, const Array< Array< int > > &grid_sizes, const Array< int > &min_line_entries)
 The scalar version; cf. the remark for 'Reset'.
 SysMatrix (const Array< int > &grid_sizes, int the_src_block_size, int the_dst_block_size, int the_min_line_entries=0)
 One block, several components in a block.
 SysMatrix (const Array< int > &grid_sizes, int the_min_line_entries=0)
 Tne block, the scalar case.
SysMatrix< T > & SetZero ()
 Sets all the blocks to zero.
SysMatrix< T > & operator= (const SysMatrix< T > &src)
 Copies the sizes and the blocks.
SysMatrix< T > & SetZeroRows (int from_row, int to_row)
 Sets given rows to zero.
GridVec< T > & mul (GridVec< T > &x, GridVec< T > &y)
 Operation $x \leftarrow A \cdot y$ for a given vector y, returns x.
GridVec< T > & add_mul (GridVec< T > &x, GridVec< T > &y)
 Multiplication and addition: $x \leftarrow x + A \cdot y$, for given vectors x, y. Returns x.
GridVec< T > & sub_mul (GridVec< T > &x, GridVec< T > &y)
 Multiplication and subtraction: $x \leftarrow x - A \cdot y$ for given vectors x, y. Returns x.
GridVec< T > & add_a_mul (GridVec< T > &x, T a, GridVec< T > &y)
 Multiplication and addition: $x \leftarrow x + a A \cdot y$ for given vectors x, y and a scalar a. Returns x.
GridVec< T > & residual (GridVec< T > &f, GridVec< T > &x, GridVec< T > &r)
 Computation of the residual: $r \leftarrow f - A \cdot x$ for given 'f' and 'x'. Returns r.
scal_prod (GridVec< T > &x, GridVec< T > &y)
 The energy scalar product $(Ax, y)$.
SysMatrix< T > & operator *= (T a)
 Multiplies 'this' matrix by a scalar.

Detailed Description

template<typename T>
class SysMatrix< T >

A class template for handling describing linear operators on GridVec<T> objects.

This composite linear operator is represented by a square array of matrices. Note that some matrices in the array may be uninitialized or reset by the Reset() method. These blocks are treated as zero and do not occupy memory. There can be even lines of such uninitialized blocks. For these lines, the sizes of the vectors are not checked. Inserting such lines can be used to define linear operators on a part of a vector.

To create/assemble a SysMatrix , there are two ways:

  1. Use the class constructors or 'Reset' methods where all the sizes
    of the blocks are specified. Then you get a ready-to-use matrix
    with all parts initialized. This is especially convinient for
    matrices consisting of a single block.
  2. Use the class constructor of the 'Reset' method to merely specify
    the number of the blocks. After that the blocks are uninitialized.
    Initialize the blocks you need by SparseMatrix<T>Reset methods.
    This is how you can get some uninitialized (i.e. zero) blocks in
    you matrix and save memory.

The template depends on a type T. This type should satisfy the conditions listed in small_matrix.hpp for small matrices.


Constructor & Destructor Documentation

template<typename T>
SysMatrix< T >::SysMatrix (  )  [inline]

Creates a dummy object.

template<typename T>
SysMatrix< T >::SysMatrix ( const SysMatrix< T > &  src  )  [inline]

Duplication.

template<typename T>
SysMatrix< T >::SysMatrix ( int  the_n_rows,
int  the_n_cols 
) [inline]

Merely sets the numbers of the blocks.

Parameters:
[in] the_n_rows 
[in] the_n_cols The numbers of the blocks

template<typename T>
SysMatrix< T >::SysMatrix ( int  the_n_rows,
int  the_n_columns,
const Array< Array< int > > &  grid_sizes,
const Array< int > &  src_blk_size,
const Array< int > &  dst_blk_size,
const Array< int > &  min_line_entries 
) [inline]

cf. the remark for 'Reset'

Parameters:
[in] the_n_rows 
[in] the_n_columns The numbers of the blocks
[in] grid_sizes The sizes of the grids
[in] src_blk_size The sizes of the domain point-blocks
[in] dst_blk_size The sizes of the range point-blocks
[in] min_line_entries The min. num. of blocks in lines

template<typename T>
SysMatrix< T >::SysMatrix ( int  the_n_rows,
int  the_n_columns,
const Array< Array< int > > &  grid_sizes,
const Array< int > &  min_line_entries 
) [inline]

The scalar version; cf. the remark for 'Reset'.

Parameters:
[in] the_n_rows 
[in] the_n_columns The numbers of the blocks
[in] grid_sizes The sizes of the grids
[in] min_line_entries The min. num. of blocks in lines

template<typename T>
SysMatrix< T >::SysMatrix ( const Array< int > &  grid_sizes,
int  the_src_block_size,
int  the_dst_block_size,
int  the_min_line_entries = 0 
) [inline]

One block, several components in a block.

Parameters:
[in] grid_sizes Array of the grid sizes (without the blocks)
[in] the_src_block_size The size of the blocks of the source vectors
[in] the_dst_block_size The size of the blocks of the dst. vectors
[in] the_min_line_entries The mininum num. of blocks in the lines

template<typename T>
SysMatrix< T >::SysMatrix ( const Array< int > &  grid_sizes,
int  the_min_line_entries = 0 
) [inline]

Tne block, the scalar case.

Parameters:
[in] grid_sizes Array of the grid sizes (without the blocks)
[in] the_min_line_entries The mininum num. of blocks in the lines


Member Function Documentation

template<typename T>
SparseMatrix<T>& SysMatrix< T >::operator() ( int  i,
int  j 
) [inline]

Returns the block (i, j).

template<typename T>
SparseMatrix<T>* SysMatrix< T >::FIBlock ( int  row  )  [inline]

Returns the first initialized block in a row.

Parameters:
[in] row The row to look through
Returns:
The first initialized block in a row, if there are no initialized blocks in the line, the function returns NULL.

template<typename T>
void SysMatrix< T >::AttachCoarse ( SysMatrix< T > *  the_coarse  )  [inline]

Access to the coarser level.

template<typename T>
SysMatrix<T>* SysMatrix< T >::Coarse (  )  [inline]

template<typename T>
int SysMatrix< T >::NRows (  )  const [inline]

Returns the number of rows.

template<typename T>
int SysMatrix< T >::NCols (  )  const [inline]

Returns the number of columns.

template<typename T>
bool SysMatrix< T >::IsDstVector ( GridVec< T > &  x  )  [inline]

Returns true if 'x' has the right size for the range of the matrix.

template<typename T>
void SysMatrix< T >::Reset ( int  the_n_rows,
int  the_n_cols 
) [inline]

Sets merely the number of blocks.

Parameters:
[in] the_n_rows The numbers of the blocks
[in] the_n_cols The numbers of the blocks

template<typename T>
void SysMatrix< T >::Reset ( int  the_n_rows,
int  the_n_cols,
const Array< Array< int > > &  grid_sizes,
const Array< int > &  src_blk_size,
const Array< int > &  dst_blk_size,
const Array< int > &  min_line_entries 
) [inline]

Sets the sizes for the blocks.

Parameters:
[in] the_n_rows 
[in] the_n_cols The numbers of the blocks
[in] grid_sizes The sizes of the grids
[in] src_blk_size The sizes of the domain point-blocks
[in] dst_blk_size The sizes of the range point-blocks
[in] min_line_entries The min. num. of blocks in lines
Note:
'grid_sizes' should have 'the_n_rows' elements that correspond to the sizes of the range grid. 'src_blk_size' and 'dst_blk_size' should have 'the_n_cols' and 'the_n_rows' elements, respectively. 'min_line_entries' should store 'the_n_cols * the_n_rows' elements.

template<typename T>
void SysMatrix< T >::Reset ( int  the_n_rows,
int  the_n_cols,
const Array< Array< int > > &  grid_sizes,
const Array< int > &  min_line_entries 
) [inline]

Sets the sizes if the blocks are scalar matrices.

Parameters:
[in] the_n_rows 
[in] the_n_cols The numbers of the blocks
[in] grid_sizes The sizes of the grids
[in] min_line_entries The min. num. of blocks in lines
Note:
'grid_sizes' should have 'the_n_rows' elements that correspond to the sizes of the range grid. 'min_line_entries' should store 'the_n_cols * the_n_rows' elements.

template<typename T>
void SysMatrix< T >::Reset ( const Array< int > &  grid_sizes,
int  the_src_block_size,
int  the_dst_block_size,
int  the_min_line_entries = 0 
) [inline]

Makes a one-row-one-column system.

Parameters:
[in] grid_sizes Array of the grid sizes (without the blocks)
[in] the_src_block_size The size of the blocks of the source vectors
[in] the_dst_block_size The size of the blocks of the dst. vectors
[in] the_min_line_entries The mininum num. of blocks in the lines

template<typename T>
void SysMatrix< T >::Reset ( const Array< int > &  grid_sizes,
int  the_min_line_entries = 0 
) [inline]

Makes a one-row-one-column system (the scalar version).

Parameters:
[in] grid_sizes Array of the grid sizes (without the blocks)
[in] the_min_line_entries The mininum num. of blocks in the lines

template<typename T>
SysMatrix<T>& SysMatrix< T >::SetZero (  )  [inline]

Sets all the blocks to zero.

template<typename T>
SysMatrix<T>& SysMatrix< T >::operator= ( const SysMatrix< T > &  src  )  [inline]

Copies the sizes and the blocks.

template<typename T>
SysMatrix<T>& SysMatrix< T >::SetZeroRows ( int  from_row,
int  to_row 
) [inline]

Sets given rows to zero.

Parameters:
[in] from_row Index of the first row
[in] to_row Index of the last row

template<typename T>
GridVec< T > & SysMatrix< T >::mul ( GridVec< T > &  x,
GridVec< T > &  y 
) [inline]

Operation $x \leftarrow A \cdot y$ for a given vector y, returns x.

The arrays x and y may not coincide. The function returns the reference to x. 'x' and 'y' should have the corresponding sizes.

Parameters:
[in] x The result
[in] y The vector to multiply

template<typename T>
GridVec< T > & SysMatrix< T >::add_mul ( GridVec< T > &  x,
GridVec< T > &  y 
) [inline]

Multiplication and addition: $x \leftarrow x + A \cdot y$, for given vectors x, y. Returns x.

The function returns the reference to x. 'x' and 'y' should have the corresponding sizes.

Parameters:
[in] x The first summand and the result
[in] y The vector to multiply

template<typename T>
GridVec< T > & SysMatrix< T >::sub_mul ( GridVec< T > &  x,
GridVec< T > &  y 
) [inline]

Multiplication and subtraction: $x \leftarrow x - A \cdot y$ for given vectors x, y. Returns x.

The function returns the reference to x. 'x' and 'y' should have the corresponding sizes.

Parameters:
[in] x The result is saved here
[in] y 

template<typename T>
GridVec< T > & SysMatrix< T >::add_a_mul ( GridVec< T > &  x,
a,
GridVec< T > &  y 
) [inline]

Multiplication and addition: $x \leftarrow x + a A \cdot y$ for given vectors x, y and a scalar a. Returns x.

The function returns the reference to x. 'x' and 'y' should have the corresponding sizes.

Parameters:
[in] x The first summand and the result
[in] a The scalar
[in] y The vector to multiply

template<typename T>
GridVec< T > & SysMatrix< T >::residual ( GridVec< T > &  f,
GridVec< T > &  x,
GridVec< T > &  r 
) [inline]

Computation of the residual: $r \leftarrow f - A \cdot x$ for given 'f' and 'x'. Returns r.

The residual is saved in 'r' which is not expected to be initialized, except for the size. The sizes of 'f' and 'r' should be equal and consistent with the size of 'x'. The function returns the reference to 'r'.

Parameters:
[in] f The right-hand side of the system
[in] x The current guess of the solution
[in] r To save the residual

template<typename T>
T SysMatrix< T >::scal_prod ( GridVec< T > &  x,
GridVec< T > &  y 
) [inline]

The energy scalar product $(Ax, y)$.

'x' and 'y' should have the corresponding sizes.

template<typename T>
SysMatrix< T > & SysMatrix< T >::operator *= ( a  )  [inline]

Multiplies 'this' matrix by a scalar.

Parameters:
[in] a The scalar
Returns:
'this'


The documentation for this class was generated from the following file:
Generated on Fri Sep 21 12:34:41 2007 for SG2 by  doxygen 1.5.2