* @author Guido Kanschat
* @date 2000-2005, 2010
*/
-template <typename number = double, typename BLOCK_VECTOR=BlockVector<number> >
+template <typename number = double, typename BlockVectorType=BlockVector<number> >
class BlockMatrixArray : public Subscriptor
{
public:
/**
* Matrix-vector multiplication.
*/
- void vmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void vmult (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Matrix-vector multiplication adding to <tt>dst</tt>.
*/
- void vmult_add(BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void vmult_add(BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Transposed matrix-vector multiplication.
*/
- void Tvmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void Tvmult (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Transposed matrix-vector multiplication adding to <tt>dst</tt>.
*/
- void Tvmult_add (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void Tvmult_add (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Matrix scalar product between two vectors (at least for a symmetric
* matrix).
*/
- number matrix_scalar_product (const BLOCK_VECTOR &u,
- const BLOCK_VECTOR &v) const;
+ number matrix_scalar_product (const BlockVectorType &u,
+ const BlockVectorType &v) const;
/**
* Compute $u^T M u$. This is the square of the norm induced by the matrix
* assuming the matrix is symmetric positive definitive.
*/
- number matrix_norm_square (const BLOCK_VECTOR &u) const;
+ number matrix_norm_square (const BlockVectorType &u) const;
/**
* Print the block structure as a LaTeX-array. This output will not be very
/**
* The matrix block itself.
*/
- PointerMatrixBase<typename BLOCK_VECTOR::BlockType > *matrix;
+ PointerMatrixBase<typename BlockVectorType::BlockType > *matrix;
};
/**
* @ingroup Preconditioners
* @author Guido Kanschat, 2001, 2005
*/
-template <typename number = double, typename BLOCK_VECTOR = BlockVector<number> >
+template <typename number = double, typename BlockVectorType = BlockVector<number> >
class BlockTrianglePrecondition
- : private BlockMatrixArray<number,BLOCK_VECTOR>
+ : private BlockMatrixArray<number,BlockVectorType>
{
public:
/**
/**
* Preconditioning.
*/
- void vmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void vmult (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Preconditioning adding to <tt>dst</tt>.
*/
- void vmult_add (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void vmult_add (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Transposed preconditioning
*/
- void Tvmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void Tvmult (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Transposed preconditioning adding to <tt>dst</tt>.
*/
- void Tvmult_add (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const;
+ void Tvmult_add (BlockVectorType &dst,
+ const BlockVectorType &src) const;
/**
* Make function of base class available.
*/
- using BlockMatrixArray<number,BLOCK_VECTOR>::print_latex;
+ using BlockMatrixArray<number,BlockVectorType>::print_latex;
/**
* Make function of base class available.
*/
- using BlockMatrixArray<number,BLOCK_VECTOR>::n_block_rows;
+ using BlockMatrixArray<number,BlockVectorType>::n_block_rows;
/**
* Make function of base class available.
*/
- using BlockMatrixArray<number,BLOCK_VECTOR>::n_block_cols;
- using BlockMatrixArray<number,BLOCK_VECTOR>::clear;
- using BlockMatrixArray<number,BLOCK_VECTOR>::Subscriptor::subscribe;
- using BlockMatrixArray<number,BLOCK_VECTOR>::Subscriptor::unsubscribe;
+ using BlockMatrixArray<number,BlockVectorType>::n_block_cols;
+ using BlockMatrixArray<number,BlockVectorType>::clear;
+ using BlockMatrixArray<number,BlockVectorType>::Subscriptor::subscribe;
+ using BlockMatrixArray<number,BlockVectorType>::Subscriptor::unsubscribe;
/**
* @addtogroup Exceptions
* Add all off-diagonal contributions and return the entry of the diagonal
* element for one row.
*/
- void do_row (BLOCK_VECTOR &dst,
+ void do_row (BlockVectorType &dst,
size_type row_num) const;
/**
#ifndef DOXYGEN
//---------------------------------------------------------------------------
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
template <typename MatrixType>
inline
-BlockMatrixArray<number, BLOCK_VECTOR>::Entry::Entry (
- const MatrixType &m,
- size_type row,
- size_type col,
- number prefix,
- bool transpose)
+BlockMatrixArray<number, BlockVectorType>::Entry::Entry
+(const MatrixType &m,
+ size_type row,
+ size_type col,
+ number prefix,
+ bool transpose)
:
row (row),
col (col),
prefix (prefix),
transpose (transpose),
- matrix (new_pointer_matrix_base(m, typename BLOCK_VECTOR::BlockType(), typeid(*this).name()))
+ matrix (new_pointer_matrix_base(m, typename BlockVectorType::BlockType(), typeid(*this).name()))
{}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
template <typename MatrixType>
inline
void
-BlockMatrixArray<number, BLOCK_VECTOR>::enter (const MatrixType &matrix,
- unsigned int row,
- unsigned int col,
- number prefix,
- bool transpose)
+BlockMatrixArray<number, BlockVectorType>::enter (const MatrixType &matrix,
+ unsigned int row,
+ unsigned int col,
+ number prefix,
+ bool transpose)
{
Assert(row<n_block_rows(), ExcIndexRange(row, 0, n_block_rows()));
Assert(col<n_block_cols(), ExcIndexRange(col, 0, n_block_cols()));
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
template <class STREAM>
inline
void
-BlockMatrixArray<number, BLOCK_VECTOR>::print_latex (STREAM &out) const
+BlockMatrixArray<number, BlockVectorType>::print_latex (STREAM &out) const
{
out << "\\begin{array}{"
<< std::string(n_block_cols(), 'c')
Table<2,std::string> array(n_block_rows(), n_block_cols());
- typedef std::map<const PointerMatrixBase<typename BLOCK_VECTOR::BlockType > *, std::string> NameMap;
+ typedef std::map<const PointerMatrixBase<typename BlockVectorType::BlockType > *, std::string> NameMap;
NameMap matrix_names;
typename std::vector<Entry>::const_iterator m = entries.begin();
{
std::pair<typename NameMap::iterator, bool> x =
matrix_names.insert(
- std::pair<const PointerMatrixBase<typename BLOCK_VECTOR::BlockType >*, std::string> (m->matrix,
+ std::pair<const PointerMatrixBase<typename BlockVectorType::BlockType >*, std::string> (m->matrix,
std::string("M")));
std::ostringstream stream;
stream << matrix_number++;
out << "\\end{array}" << std::endl;
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
template <typename MatrixType>
inline
void
-BlockTrianglePrecondition<number, BLOCK_VECTOR>::enter (const MatrixType &matrix,
- size_type row,
- size_type col,
- number prefix,
- bool transpose)
+BlockTrianglePrecondition<number, BlockVectorType>::enter (const MatrixType &matrix,
+ size_type row,
+ size_type col,
+ number prefix,
+ bool transpose)
{
- BlockMatrixArray<number, BLOCK_VECTOR>::enter(matrix, row, col, prefix, transpose);
+ BlockMatrixArray<number, BlockVectorType>::enter(matrix, row, col, prefix, transpose);
}
DEAL_II_NAMESPACE_OPEN
-template <typename number, typename BLOCK_VECTOR>
-BlockMatrixArray<number,BLOCK_VECTOR>::Entry::Entry (const Entry &e)
+template <typename number, typename BlockVectorType>
+BlockMatrixArray<number,BlockVectorType>::Entry::Entry (const Entry &e)
:
row(e.row),
col(e.col),
-template <typename number, typename BLOCK_VECTOR>
-BlockMatrixArray<number,BLOCK_VECTOR>::Entry::~Entry ()
+template <typename number, typename BlockVectorType>
+BlockMatrixArray<number,BlockVectorType>::Entry::~Entry ()
{
if (matrix)
delete matrix;
}
-template <typename number, typename BLOCK_VECTOR>
-BlockMatrixArray<number,BLOCK_VECTOR>::BlockMatrixArray ()
+template <typename number, typename BlockVectorType>
+BlockMatrixArray<number,BlockVectorType>::BlockMatrixArray ()
: block_rows (0),
block_cols (0)
{}
-template <typename number, typename BLOCK_VECTOR>
-BlockMatrixArray<number,BLOCK_VECTOR>::BlockMatrixArray (
- const unsigned int n_block_rows,
- const unsigned int n_block_cols)
+template <typename number, typename BlockVectorType>
+BlockMatrixArray<number,BlockVectorType>::BlockMatrixArray
+(const unsigned int n_block_rows,
+ const unsigned int n_block_cols)
: block_rows (n_block_rows),
block_cols (n_block_cols)
{}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::initialize (
- const unsigned int n_block_rows,
- const unsigned int n_block_cols)
+BlockMatrixArray<number,BlockVectorType>::initialize
+(const unsigned int n_block_rows,
+ const unsigned int n_block_cols)
{
block_rows = n_block_rows;
block_cols = n_block_cols;
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::reinit (
- const unsigned int n_block_rows,
- const unsigned int n_block_cols)
+BlockMatrixArray<number,BlockVectorType>::reinit
+(const unsigned int n_block_rows,
+ const unsigned int n_block_cols)
{
clear();
block_rows = n_block_rows;
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::clear ()
+BlockMatrixArray<number,BlockVectorType>::clear ()
{
entries.clear();
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::vmult_add (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockMatrixArray<number,BlockVectorType>::vmult_add (BlockVectorType &dst,
+ const BlockVectorType &src) const
{
- GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
+ GrowingVectorMemory<typename BlockVectorType::BlockType > mem;
Assert (dst.n_blocks() == block_rows,
ExcDimensionMismatch(dst.n_blocks(), block_rows));
Assert (src.n_blocks() == block_cols,
ExcDimensionMismatch(src.n_blocks(), block_cols));
- typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
- typename BLOCK_VECTOR::BlockType &aux = *p_aux;
+ typename VectorMemory<typename BlockVectorType::BlockType >::Pointer p_aux(mem);
+ typename BlockVectorType::BlockType &aux = *p_aux;
typename std::vector<Entry>::const_iterator m = entries.begin();
typename std::vector<Entry>::const_iterator end = entries.end();
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::vmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockMatrixArray<number,BlockVectorType>::vmult (BlockVectorType &dst,
+ const BlockVectorType &src) const
{
dst = 0.;
vmult_add (dst, src);
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::Tvmult_add (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockMatrixArray<number,BlockVectorType>::Tvmult_add (BlockVectorType &dst,
+ const BlockVectorType &src) const
{
- GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
+ GrowingVectorMemory<typename BlockVectorType::BlockType > mem;
Assert (dst.n_blocks() == block_cols,
ExcDimensionMismatch(dst.n_blocks(), block_cols));
Assert (src.n_blocks() == block_rows,
typename std::vector<Entry>::const_iterator m = entries.begin();
typename std::vector<Entry>::const_iterator end = entries.end();
- typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
- typename BLOCK_VECTOR::BlockType &aux = *p_aux;
+ typename VectorMemory<typename BlockVectorType::BlockType >::Pointer p_aux(mem);
+ typename BlockVectorType::BlockType &aux = *p_aux;
for (; m != end ; ++m)
{
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockMatrixArray<number,BLOCK_VECTOR>::Tvmult (BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockMatrixArray<number,BlockVectorType>::Tvmult (BlockVectorType &dst,
+ const BlockVectorType &src) const
{
dst = 0.;
Tvmult_add (dst, src);
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
number
-BlockMatrixArray<number,BLOCK_VECTOR>::matrix_scalar_product (
- const BLOCK_VECTOR &u,
- const BLOCK_VECTOR &v) const
+BlockMatrixArray<number,BlockVectorType>::matrix_scalar_product
+(const BlockVectorType &u,
+ const BlockVectorType &v) const
{
- GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
+ GrowingVectorMemory<typename BlockVectorType::BlockType > mem;
Assert (u.n_blocks() == block_rows,
ExcDimensionMismatch(u.n_blocks(), block_rows));
Assert (v.n_blocks() == block_cols,
ExcDimensionMismatch(v.n_blocks(), block_cols));
- typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
- typename BLOCK_VECTOR::BlockType &aux = *p_aux;
+ typename VectorMemory<typename BlockVectorType::BlockType >::Pointer p_aux(mem);
+ typename BlockVectorType::BlockType &aux = *p_aux;
typename std::vector<Entry>::const_iterator m;
typename std::vector<Entry>::const_iterator end = entries.end();
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
number
-BlockMatrixArray<number,BLOCK_VECTOR>::matrix_norm_square (
- const BLOCK_VECTOR &u) const
+BlockMatrixArray<number,BlockVectorType>::matrix_norm_square
+(const BlockVectorType &u) const
{
return matrix_scalar_product(u,u);
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
unsigned int
-BlockMatrixArray<number,BLOCK_VECTOR>::n_block_rows () const
+BlockMatrixArray<number,BlockVectorType>::n_block_rows () const
{
return block_rows;
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
unsigned int
-BlockMatrixArray<number,BLOCK_VECTOR>::n_block_cols () const
+BlockMatrixArray<number,BlockVectorType>::n_block_cols () const
{
return block_cols;
}
//---------------------------------------------------------------------------
-template <typename number, typename BLOCK_VECTOR>
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::BlockTrianglePrecondition()
- : BlockMatrixArray<number,BLOCK_VECTOR> (),
+template <typename number, typename BlockVectorType>
+BlockTrianglePrecondition<number,BlockVectorType>::BlockTrianglePrecondition()
+ : BlockMatrixArray<number,BlockVectorType> (),
backward(false)
{}
-template <typename number, typename BLOCK_VECTOR>
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::BlockTrianglePrecondition(
- const unsigned int block_rows)
+template <typename number, typename BlockVectorType>
+BlockTrianglePrecondition<number,BlockVectorType>::BlockTrianglePrecondition
+(const unsigned int block_rows)
:
- BlockMatrixArray<number,BLOCK_VECTOR> (block_rows, block_rows),
+ BlockMatrixArray<number,BlockVectorType> (block_rows, block_rows),
backward(false)
{}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::reinit (
- const unsigned int n)
+BlockTrianglePrecondition<number,BlockVectorType>::reinit
+(const unsigned int n)
{
- BlockMatrixArray<number,BLOCK_VECTOR>::reinit(n,n);
+ BlockMatrixArray<number,BlockVectorType>::reinit(n,n);
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::do_row (
- BLOCK_VECTOR &dst,
- size_type row_num) const
+BlockTrianglePrecondition<number,BlockVectorType>::do_row
+(BlockVectorType &dst,
+ size_type row_num) const
{
- GrowingVectorMemory<typename BLOCK_VECTOR::BlockType > mem;
- typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator
+ GrowingVectorMemory<typename BlockVectorType::BlockType > mem;
+ typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator
m = this->entries.begin();
- typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator
+ typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator
end = this->entries.end();
- std::vector<typename std::vector<typename BlockMatrixArray<number,BLOCK_VECTOR>::Entry>::const_iterator>
+ std::vector<typename std::vector<typename BlockMatrixArray<number,BlockVectorType>::Entry>::const_iterator>
diagonals;
- typename VectorMemory<typename BLOCK_VECTOR::BlockType >::Pointer p_aux(mem);
- typename BLOCK_VECTOR::BlockType &aux = *p_aux;
+ typename VectorMemory<typename BlockVectorType::BlockType >::Pointer p_aux(mem);
+ typename BlockVectorType::BlockType &aux = *p_aux;
aux.reinit(dst.block(row_num), true);
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::vmult_add (
- BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockTrianglePrecondition<number,BlockVectorType>::vmult_add
+(BlockVectorType &dst,
+ const BlockVectorType &src) const
{
Assert (dst.n_blocks() == n_block_rows(),
ExcDimensionMismatch(dst.n_blocks(), n_block_rows()));
Assert (src.n_blocks() == n_block_cols(),
ExcDimensionMismatch(src.n_blocks(), n_block_cols()));
- BLOCK_VECTOR aux;
+ BlockVectorType aux;
aux.reinit(dst);
vmult(aux, src);
dst.add(aux);
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::vmult (
- BLOCK_VECTOR &dst,
- const BLOCK_VECTOR &src) const
+BlockTrianglePrecondition<number,BlockVectorType>::vmult
+(BlockVectorType &dst,
+ const BlockVectorType &src) const
{
Assert (dst.n_blocks() == n_block_rows(),
ExcDimensionMismatch(dst.n_blocks(), n_block_rows()));
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::Tvmult (
- BLOCK_VECTOR &,
- const BLOCK_VECTOR &) const
+BlockTrianglePrecondition<number,BlockVectorType>::Tvmult
+(BlockVectorType &,
+ const BlockVectorType &) const
{
Assert (false, ExcNotImplemented());
}
-template <typename number, typename BLOCK_VECTOR>
+template <typename number, typename BlockVectorType>
void
-BlockTrianglePrecondition<number,BLOCK_VECTOR>::Tvmult_add (
- BLOCK_VECTOR &,
- const BLOCK_VECTOR &) const
+BlockTrianglePrecondition<number,BlockVectorType>::Tvmult_add
+(BlockVectorType &,
+ const BlockVectorType &) const
{
Assert (false, ExcNotImplemented());
}