* access to its own typedefs.
*/
typedef BlockMatrixBase<SparseMatrix<number> > BaseClass;
-
+
/**
* Typedef the type of the underlying
* matrix.
* Destructor.
*/
virtual ~BlockSparseMatrix ();
-
-
- /**
+
+
+ /**
* Pseudo copy operator only copying
* empty objects. The sizes of the block
* matrices need to be the same.
BlockSparseMatrix &
operator = (const BlockSparseMatrix &);
- /**
+ /**
* This operator assigns a scalar to a
* matrix. Since this does usually not
* make much sense (should we set all
- * matrix entries to this value? Only the
- * nonzero entries of the sparsity
+ * matrix entries to this value? Only
+ * the nonzero entries of the sparsity
* pattern?), this operation is only
* allowed if the actual value to be
* assigned is zero. This operator only
* exists to allow for the obvious
- * notation <tt>matrix=0</tt>, which sets
- * all elements of the matrix to zero,
- * but keep the sparsity pattern
+ * notation <tt>matrix=0</tt>, which
+ * sets all elements of the matrix to
+ * zero, but keep the sparsity pattern
* previously used.
*/
- BlockSparseMatrix<number> &
+ BlockSparseMatrix &
operator = (const double d);
/**
* object to have no blocks at all.
*/
void clear ();
-
+
/**
* Reinitialize the sparse matrix
* with the given sparsity
* (with absolute value larger than
* threshold) of all the blocks.
*/
- unsigned int n_actually_nonzero_elements (const double threshold = 0.0) const;
+ unsigned int n_actually_nonzero_elements (const double threshold = 0.0) const;
/**
* Matrix-vector multiplication:
template <typename nonblock_number>
void vmult (Vector<nonblock_number> &dst,
const Vector<nonblock_number> &src) const;
-
+
/**
* Matrix-vector multiplication:
* let $dst = M^T*src$ with $M$
template <typename block_number>
void Tvmult (BlockVector<block_number> &dst,
const BlockVector<block_number> &src) const;
-
+
/**
* Matrix-vector
* multiplication. Just like the
template <typename nonblock_number>
void Tvmult (Vector<nonblock_number> &dst,
const Vector<nonblock_number> &src) const;
-
+
/**
* Apply the Jacobi
* preconditioner, which
*/
const BlockSparsityPattern &
get_sparsity_pattern () const;
-
+
/**
* Determine an estimate for the
* memory consumption (in bytes)
/** @addtogroup Exceptions
* @{ */
-
+
/**
* Exception
*/
DeclException0 (ExcBlockDimensionMismatch);
- //@}
+ //@}
private:
/**
* Pointer to the block sparsity
+template <typename number>
+inline
+BlockSparseMatrix<number> &
+BlockSparseMatrix<number>::operator = (const double d)
+{
+ Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+ for (unsigned int r=0; r<this->n_block_rows(); ++r)
+ for (unsigned int c=0; c<this->n_block_cols(); ++c)
+ this->block(r,c) = d;
+
+ return *this;
+}
+
+
+
template <typename number>
template <typename block_number>
inline
{
BaseClass::vmult_block_block (dst, src);
}
-
+
template <typename number>
{
BaseClass::vmult_block_nonblock (dst, src);
}
-
+
template <typename number>
{
BaseClass::vmult_nonblock_block (dst, src);
}
-
+
template <typename number>
}
+
template <typename number>
template <typename block_number>
inline
{
BaseClass::Tvmult_block_block (dst, src);
}
-
+
template <typename number>
{
BaseClass::Tvmult_block_nonblock (dst, src);
}
-
+
template <typename number>
{
BaseClass::Tvmult_nonblock_block (dst, src);
}
-
+
template <typename number>
}
+
template <typename number>
template <class BlockVectorType>
+inline
void
BlockSparseMatrix<number>::
precondition_Jacobi (BlockVectorType &dst,
}
+
template <typename number>
template <typename number2>
+inline
void
BlockSparseMatrix<number>::
precondition_Jacobi (Vector<number2> &dst,
return *this;
}
-
-
-template <typename number>
-BlockSparseMatrix<number> &
-BlockSparseMatrix<number>::operator = (const double d)
-{
- Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
-
- for (unsigned int r=0; r<this->n_block_rows(); ++r)
- for (unsigned int c=0; c<this->n_block_cols(); ++c)
- this->block(r,c) = d;
-
- return *this;
-}
-
template <typename number>
Assert (d==number(0), ExcScalarAssignmentOnlyForZeroValue());
if (this->n_elements() != 0)
- std::fill_n (this->val, this->n_elements(), number());
+ memset (this->val, 0, this->n_elements()*sizeof(number));
return *this;
}
namespace PETScWrappers
{
-
+
/*! @addtogroup PETScWrappers
*@{
*/
* access to its own typedefs.
*/
typedef BlockMatrixBase<SparseMatrix> BaseClass;
-
+
/**
* Typedef the type of the underlying
* matrix.
*/
~BlockSparseMatrix ();
- /**
+ /**
* Pseudo copy operator only copying
* empty objects. The sizes of the block
* matrices need to be the same.
*/
void reinit (const unsigned int n_block_rows,
const unsigned int n_block_columns);
-
+
/**
* This function collects the
* sizes of the sub-objects and
*/
void vmult (Vector &dst,
const Vector &src) const;
-
+
/**
* Matrix-vector multiplication:
* let $dst = M^T*src$ with $M$
*/
void Tvmult (BlockVector &dst,
const BlockVector &src) const;
-
+
/**
* Matrix-vector
* multiplication. Just like the
* only one block.
*/
void Tvmult (Vector &dst,
- const Vector &src) const;
+ const Vector &src) const;
/**
* Make the clear() function in the
* protected.
*/
using BlockMatrixBase<SparseMatrix>::clear;
-
+
/** @addtogroup Exceptions
* @{
*/
-
+
/**
* Exception
*/
// ------------- inline and template functions -----------------
+ inline
+ BlockSparseMatrix &
+ BlockSparseMatrix::operator = (const double d)
+ {
+ Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+ for (unsigned int r=0; r<this->n_block_rows(); ++r)
+ for (unsigned int c=0; c<this->n_block_cols(); ++c)
+ this->block(r,c) = d;
+
+ return *this;
+ }
+
+
+
inline
void
BlockSparseMatrix::vmult (BlockVector &dst,
{
BaseClass::vmult_block_block (dst, src);
}
-
+
inline
{
BaseClass::vmult_block_nonblock (dst, src);
}
-
+
inline
{
BaseClass::vmult_nonblock_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_block_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_block_nonblock (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_nonblock_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_nonblock_nonblock (dst, src);
}
-
+
}
DEAL_II_NAMESPACE_CLOSE
/*! @addtogroup PETScWrappers
*@{
- */
+ */
/**
* Blocked sparse matrix based on the PETScWrappers::SparseMatrix class. This
* access to its own typedefs.
*/
typedef BlockMatrixBase<SparseMatrix> BaseClass;
-
+
/**
* Typedef the type of the underlying
* matrix.
*/
~BlockSparseMatrix ();
- /**
+ /**
* Pseudo copy operator only copying
* empty objects. The sizes of the
* block matrices need to be the
* previously used.
*/
BlockSparseMatrix &
- operator = (const PetscScalar d);
+ operator = (const double d);
/**
* Resize the matrix, by setting
* she desires.
*/
void reinit (const unsigned int n_block_rows,
- const unsigned int n_block_columns);
+ const unsigned int n_block_columns);
/**
* Matrix-vector multiplication:
*/
void vmult (Vector &dst,
const Vector &src) const;
-
+
/**
* Matrix-vector multiplication:
* let $dst = M^T*src$ with $M$
*/
void Tvmult (BlockVector &dst,
const BlockVector &src) const;
-
+
/**
* Matrix-vector
* multiplication. Just like the
* only one block.
*/
void Tvmult (Vector &dst,
- const Vector &src) const;
+ const Vector &src) const;
/**
* This function collects the
* the sub-objects.
*/
void collect_sizes ();
-
+
/**
* Return a reference to the MPI
* communicator object in use with
// ------------- inline and template functions -----------------
+ inline
+ BlockSparseMatrix &
+ BlockSparseMatrix::operator = (const double d)
+ {
+ Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+ for (unsigned int r=0; r<this->n_block_rows(); ++r)
+ for (unsigned int c=0; c<this->n_block_cols(); ++c)
+ this->block(r,c) = d;
+
+ return *this;
+ }
+
+
+
inline
void
BlockSparseMatrix::vmult (BlockVector &dst,
{
BaseClass::vmult_block_block (dst, src);
}
-
+
inline
{
BaseClass::vmult_block_nonblock (dst, src);
}
-
+
inline
{
BaseClass::vmult_nonblock_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_block_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_block_nonblock (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_nonblock_block (dst, src);
}
-
+
inline
{
BaseClass::Tvmult_nonblock_nonblock (dst, src);
}
-
+
}
-
+
}
// ------------- inline and template functions -----------------
+
+
+ inline
+ BlockSparseMatrix &
+ BlockSparseMatrix::operator = (const double d)
+ {
+ Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+
+ for (unsigned int r=0; r<this->n_block_rows(); ++r)
+ for (unsigned int c=0; c<this->n_block_cols(); ++c)
+ this->block(r,c) = d;
+
+ return *this;
+ }
+
+
+
inline
bool
BlockSparseMatrix::is_compressed () const
}
-
- BlockSparseMatrix &
- BlockSparseMatrix::operator = (const double d)
- {
- for (unsigned int r=0; r<this->n_block_rows(); ++r)
- for (unsigned int c=0; c<this->n_block_cols(); ++c)
- this->block(r,c) = d;
-
- return *this;
- }
-
-
void
BlockSparseMatrix::
reinit (const unsigned int n_block_rows,
}
-
- BlockSparseMatrix &
- BlockSparseMatrix::operator = (const PetscScalar d)
- {
- for (unsigned int r=0; r<this->n_block_rows(); ++r)
- for (unsigned int c=0; c<this->n_block_cols(); ++c)
- this->block(r,c) = d;
-
- return *this;
- }
-
-
void
BlockSparseMatrix::
reinit (const unsigned int n_block_rows,
- BlockSparseMatrix &
- BlockSparseMatrix::operator = (const double d)
- {
- for (unsigned int r=0; r<this->n_block_rows(); ++r)
- for (unsigned int c=0; c<this->n_block_cols(); ++c)
- this->block(r,c) = d;
-
- return *this;
- }
-
-
-
void
BlockSparseMatrix::
reinit (const unsigned int n_block_rows,