Public Member Functions | |
ProductMatrix () | |
ProductMatrix (VectorMemory< VECTOR > &mem) | |
template<class MATRIX1 , class MATRIX2 > | |
ProductMatrix (const MATRIX1 &m1, const MATRIX2 &m2, VectorMemory< VECTOR > &mem) | |
template<class MATRIX1 , class MATRIX2 > | |
void | reinit (const MATRIX1 &m1, const MATRIX2 &m2) |
template<class MATRIX1 , class MATRIX2 > | |
void | initialize (const MATRIX1 &m1, const MATRIX2 &m2, VectorMemory< VECTOR > &mem) |
~ProductMatrix () | |
void | clear () |
virtual void | vmult (VECTOR &w, const VECTOR &v) const |
virtual void | Tvmult (VECTOR &w, const VECTOR &v) const |
virtual void | vmult_add (VECTOR &w, const VECTOR &v) const |
virtual void | Tvmult_add (VECTOR &w, const VECTOR &v) const |
Private Member Functions | |
virtual const void * | get () const |
Private Attributes | |
PointerMatrixBase< VECTOR > * | m1 |
PointerMatrixBase< VECTOR > * | m2 |
SmartPointer< VectorMemory < VECTOR > > | mem |
Poor man's matrix product of two quadratic matrices. Stores two quadratic matrices m1 and m2 of arbitrary types and implements matrix-vector multiplications for the product M1M2 by performing multiplication with both factors consecutively.
Here an example multiplying two different FullMatrix objects:
//--------------------------------------------------------------------------- // @f$Id: product_matrix.cc 16263 2008-05-28 16:41:01Z kanschat @f$ // // Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer // to the file deal.II/doc/license.html for the text and // further information on this license. // //--------------------------------------------------------------------------- // See documentation of Product for documentation of this example #include <base/logstream.h> #include <lac/matrix_lib.h> #include <lac/full_matrix.h> #include <lac/vector.h> using namespace dealii; double Adata[] = { .5, .1, .4, .2 }; double Bdata[] = { .866, .5, -.5, .866 }; int main() { FullMatrix<float> A(2,2); FullMatrix<double> B(2,2); A.fill(Adata); B.fill(Bdata); GrowingVectorMemory<Vector<double> > mem; ProductMatrix<Vector<double> > AB(A,B,mem); Vector<double> u(2); Vector<double> v(2); u(0) = 1.; u(1) = 2.; AB.vmult(v,u); deallog << v(0) << '\t' << v(1) << std::endl; AB.Tvmult(v,u); deallog << v(0) << '\t' << v(1) << std::endl; }
ProductMatrix< VECTOR >::ProductMatrix | ( | ) | [inline] |
Standard constructor. Matrices and the memory pool must be added later using initialize().
ProductMatrix< VECTOR >::ProductMatrix | ( | VectorMemory< VECTOR > & | mem | ) | [inline] |
Constructor only assigning the memory pool. Matrices must be added by reinit() later.
ProductMatrix< VECTOR >::ProductMatrix | ( | const MATRIX1 & | m1, | |
const MATRIX2 & | m2, | |||
VectorMemory< VECTOR > & | mem | |||
) | [inline] |
Constructor. Additionally to the two constituting matrices, a memory pool for the auxiliary vector must be provided.
References ProductMatrix< VECTOR >::m1, and ProductMatrix< VECTOR >::m2.
ProductMatrix< VECTOR >::~ProductMatrix | ( | ) | [inline] |
Destructor.
References ProductMatrix< VECTOR >::m1, and ProductMatrix< VECTOR >::m2.
void ProductMatrix< VECTOR >::reinit | ( | const MATRIX1 & | m1, | |
const MATRIX2 & | m2 | |||
) | [inline] |
Change the matrices.
References ProductMatrix< VECTOR >::m1, and ProductMatrix< VECTOR >::m2.
void ProductMatrix< VECTOR >::initialize | ( | const MATRIX1 & | m1, | |
const MATRIX2 & | m2, | |||
VectorMemory< VECTOR > & | mem | |||
) | [inline] |
Change the matrices and memory pool.
References ProductMatrix< VECTOR >::m1, ProductMatrix< VECTOR >::m2, and ProductMatrix< VECTOR >::mem.
void ProductMatrix< VECTOR >::clear | ( | ) | [inline, virtual] |
Reset pointer and release the matrix pointed to.
Implements PointerMatrixBase< VECTOR >.
References ProductMatrix< VECTOR >::m1, and ProductMatrix< VECTOR >::m2.
void ProductMatrix< VECTOR >::vmult | ( | VECTOR & | w, | |
const VECTOR & | v | |||
) | const [inline, virtual] |
Matrix-vector product w = m1 * m2 * v.
Implements PointerMatrixBase< VECTOR >.
References Assert, ProductMatrix< VECTOR >::m1, ProductMatrix< VECTOR >::m2, and ProductMatrix< VECTOR >::mem.
void ProductMatrix< VECTOR >::Tvmult | ( | VECTOR & | w, | |
const VECTOR & | v | |||
) | const [inline, virtual] |
Tranposed matrix-vector product w = m2T * m1T * v.
Implements PointerMatrixBase< VECTOR >.
References Assert, ProductMatrix< VECTOR >::m1, ProductMatrix< VECTOR >::m2, and ProductMatrix< VECTOR >::mem.
void ProductMatrix< VECTOR >::vmult_add | ( | VECTOR & | w, | |
const VECTOR & | v | |||
) | const [inline, virtual] |
Adding matrix-vector product w += m1 * m2 * v
Implements PointerMatrixBase< VECTOR >.
References Assert, ProductMatrix< VECTOR >::m1, ProductMatrix< VECTOR >::m2, and ProductMatrix< VECTOR >::mem.
void ProductMatrix< VECTOR >::Tvmult_add | ( | VECTOR & | w, | |
const VECTOR & | v | |||
) | const [inline, virtual] |
Adding, tranposed matrix-vector product w += m2T * m1T * v.
Implements PointerMatrixBase< VECTOR >.
References Assert, ProductMatrix< VECTOR >::m1, ProductMatrix< VECTOR >::m2, and ProductMatrix< VECTOR >::mem.
const void * ProductMatrix< VECTOR >::get | ( | ) | const [inline, private, virtual] |
Return some kind of identifier.
Implements PointerMatrixBase< VECTOR >.
References ProductMatrix< VECTOR >::m1.
PointerMatrixBase<VECTOR>* ProductMatrix< VECTOR >::m1 [private] |
The left matrix of the product.
Referenced by ProductMatrix< VECTOR >::clear(), ProductMatrix< VECTOR >::get(), ProductMatrix< VECTOR >::initialize(), ProductMatrix< VECTOR >::ProductMatrix(), ProductMatrix< VECTOR >::reinit(), ProductMatrix< VECTOR >::Tvmult(), ProductMatrix< VECTOR >::Tvmult_add(), ProductMatrix< VECTOR >::vmult(), ProductMatrix< VECTOR >::vmult_add(), and ProductMatrix< VECTOR >::~ProductMatrix().
PointerMatrixBase<VECTOR>* ProductMatrix< VECTOR >::m2 [private] |
The right matrix of the product.
Referenced by ProductMatrix< VECTOR >::clear(), ProductMatrix< VECTOR >::initialize(), ProductMatrix< VECTOR >::ProductMatrix(), ProductMatrix< VECTOR >::reinit(), ProductMatrix< VECTOR >::Tvmult(), ProductMatrix< VECTOR >::Tvmult_add(), ProductMatrix< VECTOR >::vmult(), ProductMatrix< VECTOR >::vmult_add(), and ProductMatrix< VECTOR >::~ProductMatrix().
SmartPointer<VectorMemory<VECTOR> > ProductMatrix< VECTOR >::mem [private] |
Memory for auxiliary vector.
Referenced by ProductMatrix< VECTOR >::initialize(), ProductMatrix< VECTOR >::Tvmult(), ProductMatrix< VECTOR >::Tvmult_add(), ProductMatrix< VECTOR >::vmult(), and ProductMatrix< VECTOR >::vmult_add().