};
-/**
- * Poor man's matrix product. Stores two matrices $m_1$ and $m_2$ and
- * implements matrix-vector multiplications for the product $m_1 m_2$
- * by performing multiplication with both factors consecutively.
- *
- * @author Guido Kanschat, 2000, 2001, 2002
- */
-template<class MATRIX1, class MATRIX2, class VECTOR>
-class ProductMatrix : public PointerMatrixBase<VECTOR>
-{
- public:
- /**
- * Constructor. Additionally to
- * the two constituting matrices, a
- * memory pool for the auxiliary
- * vector must be provided.
- */
- ProductMatrix(const MATRIX1& m1,
- const MATRIX2& m2,
- VectorMemory<VECTOR>& mem);
-
- /**
- * Matrix-vector product.
- */
- virtual void vmult (VECTOR& dst,
- const VECTOR& src) const;
-
- /**
- * Tranposed matrix-vector product.
- */
- virtual void Tvmult (VECTOR& dst,
- const VECTOR& src) const;
-
- /**
- * Matrix-vector product, adding to
- * @p{dst}.
- */
- virtual void vmult_add (VECTOR& dst,
- const VECTOR& src) const;
-
- /**
- * Tranposed matrix-vector product,
- * adding to @p{dst}.
- */
- virtual void Tvmult_add (VECTOR& dst,
- const VECTOR& src) const;
-
- private:
- /**
- * The left matrix of the product.
- */
- SmartPointer<const MATRIX1> m1;
-
- /**
- * The right matrix of the product.
- */
- SmartPointer<const MATRIX2> m2;
-
- /**
- * Memory for auxiliary vector.
- */
- SmartPointer<VectorMemory<VECTOR> > mem;
-};
-
-
//----------------------------------------------------------------------//
template<class VECTOR>
}
-//----------------------------------------------------------------------//
-
-template<class MATRIX1, class MATRIX2, class VECTOR>
-ProductMatrix<MATRIX1, MATRIX2, VECTOR>::ProductMatrix (
- const MATRIX1& mat1,
- const MATRIX2& mat2,
- VectorMemory<VECTOR>& m)
- : m1(&mat1),
- m2(&mat2),
- mem(&m)
-{}
-
-
-template<class MATRIX1, class MATRIX2, class VECTOR>
-void
-ProductMatrix<MATRIX1, MATRIX2, VECTOR>::vmult (VECTOR& dst,
- const VECTOR& src) const
-{
- VECTOR* v = mem->alloc();
- v->reinit(dst);
- m2->vmult (*v, src);
- m1->vmult (dst, *v);
- mem->free(v);
-}
-
-
-template<class MATRIX1, class MATRIX2, class VECTOR>
-void
-ProductMatrix<MATRIX1, MATRIX2, VECTOR>::vmult_add (VECTOR& dst,
- const VECTOR& src) const
-{
- VECTOR* v = mem->alloc();
- v->reinit(dst);
- m2->vmult (*v, src);
- m1->vmult_add (dst, *v);
- mem->free(v);
-}
-
-
-template<class MATRIX1, class MATRIX2, class VECTOR>
-void
-ProductMatrix<MATRIX1, MATRIX2, VECTOR>::Tvmult (
- VECTOR& dst,
- const VECTOR& src) const
-{
- VECTOR* v = mem->alloc();
- v->reinit(dst);
- m1->Tvmult (*v, src);
- m2->Tvmult (dst, *v);
- mem->free(v);
-}
-
-
-template<class MATRIX1, class MATRIX2, class VECTOR>
-void
-ProductMatrix<MATRIX1, MATRIX2, VECTOR>::Tvmult_add (
- VECTOR& dst,
- const VECTOR& src) const
-{
- VECTOR* v = mem->alloc();
- v->reinit(dst);
- m1->Tvmult (*v, src);
- m2->Tvmult_add (dst, *v);
- mem->free(v);
-}
-
#endif