Public Member Functions | Private Member Functions | Private Attributes

ProductMatrix< VECTOR > Class Template Reference
[Derived matrices]

Inheritance diagram for ProductMatrix< VECTOR >:
Inheritance graph
[legend]

List of all members.

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 >, ProductMatrix
< VECTOR > > 
mem

Detailed Description

template<class VECTOR>
class ProductMatrix< VECTOR >

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 23709 2011-05-17 04:34:08Z bangerth @f$
//
//    Copyright (C) 2005, 2006, 2010 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 ProductMatrix for documentation of this example

#include <deal.II/base/logstream.h>
#include <deal.II/lac/matrix_lib.h>
#include <deal.II/lac/full_matrix.h>
#include <deal.II/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;
}

Author:
Guido Kanschat, 2000, 2001, 2002, 2005

Definition at line 44 of file matrix_lib.h.


Constructor & Destructor Documentation

template<class VECTOR >
ProductMatrix< VECTOR >::ProductMatrix (  )

Standard constructor. Matrices and the memory pool must be added later using initialize().

Definition at line 579 of file matrix_lib.h.

template<class VECTOR >
ProductMatrix< VECTOR >::ProductMatrix ( VectorMemory< VECTOR > &  mem )

Constructor only assigning the memory pool. Matrices must be added by reinit() later.

Definition at line 585 of file matrix_lib.h.

template<class VECTOR >
template<class MATRIX1 , class MATRIX2 >
ProductMatrix< VECTOR >::ProductMatrix ( const MATRIX1 &  m1,
const MATRIX2 &  m2,
VectorMemory< VECTOR > &  mem 
)

Constructor. Additionally to the two constituting matrices, a memory pool for the auxiliary vector must be provided.

Definition at line 592 of file matrix_lib.h.

References ProductMatrix< VECTOR >::m1, and ProductMatrix< VECTOR >::m2.

template<class VECTOR >
ProductMatrix< VECTOR >::~ProductMatrix (  )

Destructor.

Definition at line 634 of file matrix_lib.h.


Member Function Documentation

template<class VECTOR >
template<class MATRIX1 , class MATRIX2 >
void ProductMatrix< VECTOR >::reinit ( const MATRIX1 &  m1,
const MATRIX2 &  m2 
)

Change the matrices.

Definition at line 606 of file matrix_lib.h.

template<class VECTOR >
template<class MATRIX1 , class MATRIX2 >
void ProductMatrix< VECTOR >::initialize ( const MATRIX1 &  m1,
const MATRIX2 &  m2,
VectorMemory< VECTOR > &  mem 
)

Change the matrices and memory pool.

Definition at line 620 of file matrix_lib.h.

template<class VECTOR >
void ProductMatrix< VECTOR >::clear (  ) [virtual]

Reset pointer and release the matrix pointed to.

Implements PointerMatrixBase< VECTOR >.

Definition at line 643 of file matrix_lib.h.

template<class VECTOR >
void ProductMatrix< VECTOR >::vmult ( VECTOR &  w,
const VECTOR &  v 
) const [virtual]

Matrix-vector product w = m1 * m2 * v.

Implements PointerMatrixBase< VECTOR >.

Definition at line 654 of file matrix_lib.h.

References Assert, and StandardExceptions::ExcNotInitialized().

template<class VECTOR >
void ProductMatrix< VECTOR >::Tvmult ( VECTOR &  w,
const VECTOR &  v 
) const [virtual]

Tranposed matrix-vector product w = m2T * m1T * v.

Implements PointerMatrixBase< VECTOR >.

Definition at line 686 of file matrix_lib.h.

References Assert, and StandardExceptions::ExcNotInitialized().

template<class VECTOR >
void ProductMatrix< VECTOR >::vmult_add ( VECTOR &  w,
const VECTOR &  v 
) const [virtual]

Adding matrix-vector product w += m1 * m2 * v

Implements PointerMatrixBase< VECTOR >.

Definition at line 670 of file matrix_lib.h.

References Assert, and StandardExceptions::ExcNotInitialized().

template<class VECTOR >
void ProductMatrix< VECTOR >::Tvmult_add ( VECTOR &  w,
const VECTOR &  v 
) const [virtual]

Adding, tranposed matrix-vector product w += m2T * m1T * v.

Implements PointerMatrixBase< VECTOR >.

Definition at line 702 of file matrix_lib.h.

References Assert, and StandardExceptions::ExcNotInitialized().

template<class VECTOR >
const void * ProductMatrix< VECTOR >::get (  ) const [private, virtual]

Return some kind of identifier.

Implements PointerMatrixBase< VECTOR >.

Definition at line 718 of file matrix_lib.h.


Member Data Documentation

template<class VECTOR>
PointerMatrixBase<VECTOR>* ProductMatrix< VECTOR >::m1 [private]

The left matrix of the product.

Definition at line 129 of file matrix_lib.h.

Referenced by ProductMatrix< VECTOR >::ProductMatrix().

template<class VECTOR>
PointerMatrixBase<VECTOR>* ProductMatrix< VECTOR >::m2 [private]

The right matrix of the product.

Definition at line 134 of file matrix_lib.h.

Referenced by ProductMatrix< VECTOR >::ProductMatrix().

template<class VECTOR>
SmartPointer<VectorMemory<VECTOR>,ProductMatrix<VECTOR> > ProductMatrix< VECTOR >::mem [private]

Memory for auxiliary vector.

Definition at line 139 of file matrix_lib.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Fri Feb 3 2012 06:04:10 by doxygen 1.7.2