Ifpack_DenseContainer Class Reference

Ifpack_DenseContainer: a class to define containers for dense matrices. More...

#include <Ifpack_DenseContainer.h>

Inheritance diagram for Ifpack_DenseContainer:

[legend]
List of all members.

[NOHEADER]

 Ifpack_DenseContainer (const int NumRows, const int NumVectors=1)
 Constructors/Destructors Default constructor.
 Ifpack_DenseContainer (const Ifpack_DenseContainer &rhs)
 Copy constructor.
virtual ~Ifpack_DenseContainer ()
 Destructor.

[NOHEADER]

Ifpack_DenseContaineroperator= (const Ifpack_DenseContainer &rhs)
 Overloaded operators. Operator=.

[NOHEADER]

virtual int NumRows () const
 Get/Set methods. Returns the number of rows of the matrix and LHS/RHS.
virtual int NumVectors () const
 Returns the number of vectors in LHS/RHS.
virtual int SetNumVectors (const int NumVectors)
 Sets the number of vectors for LHS/RHS.
virtual double & LHS (const int i, const int Vector=0)
 Returns the i-th component of the vector Vector of LHS.
virtual double & RHS (const int i, const int Vector=0)
 Returns the i-th component of the vector Vector of RHS.
virtual int & ID (const int i)
 Returns the ID associated to local row i.
virtual int SetMatrixElement (const int row, const int col, const double value)
 Set the matrix element (row,col) to value.
virtual int SetParameters (Teuchos::ParameterList &List)
 Sets all necessary parameters.
virtual bool IsInitialized () const
 Returns true is the container has been successfully initialized.
virtual bool IsComputed () const
 Returns true is the container has been successfully computed.
virtual const char * Label () const
 Returns the label of this container.
virtual int SetKeepNonFactoredMatrix (const bool flag)
 If flag is true, keeps a copy of the non-factored matrix.
virtual bool KeepNonFactoredMatrix () const
 Returns KeepNonFactoredMatrix_.
virtual const Epetra_SerialDenseMatrixLHS () const
 Returns the dense vector containing the LHS.
virtual const Epetra_SerialDenseMatrixRHS () const
 Returns the dense vector containing the RHS.
virtual const Epetra_SerialDenseMatrixMatrix () const
 Returns the dense matrix or its factors.
virtual const Epetra_SerialDenseMatrixNonFactoredMatrix () const
 Returns the non-factored dense matrix (only if stored).
virtual const Epetra_IntSerialDenseVectorID () const
 Returns the integer dense vector of IDs.

[NOHEADER]

virtual int Initialize ()
 Mathematical methods. Initialize the container.
virtual int Compute (const Epetra_RowMatrix &Matrix)
 Finalizes the linear system matrix and prepares for the application of the inverse.
virtual int Apply ()
 Apply the matrix to RHS, results are stored in LHS.
virtual int ApplyInverse ()
 Apply the inverse of the matrix to RHS, results are stored in LHS.

Public Member Functions

virtual double InitializeFlops () const
 Returns the flops in Initialize().
virtual double ComputeFlops () const
 Returns the flops in Compute().
virtual double ApplyFlops () const
 Returns the flops in Apply().
virtual double ApplyInverseFlops () const
 Returns the flops in ApplyInverse().
virtual ostream & Print (std::ostream &os) const
 Prints basic information on iostream. This function is used by operator<<.

Private Member Functions

virtual int Extract (const Epetra_RowMatrix &Matrix)
 Extract the submatrices identified by the ID set int ID().

Private Attributes

int NumRows_
 Number of rows in the container.
int NumVectors_
 Number of vectors in the container.
Epetra_SerialDenseMatrix NonFactoredMatrix_
 Dense matrix, that contains the non-factored matrix.
Epetra_SerialDenseMatrix Matrix_
 Dense matrix.
Epetra_SerialDenseMatrix LHS_
 Dense vector representing the LHS.
Epetra_SerialDenseMatrix RHS_
 Dense vector representing the RHS.
Epetra_SerialDenseSolver Solver_
 Dense solver (solution will be get using LAPACK).
Epetra_IntSerialDenseVector ID_
 Sets of local rows.
bool KeepNonFactoredMatrix_
 If true, keeps a copy of the non-factored matrix.
bool IsInitialized_
 If true, the container has been successfully initialized.
bool IsComputed_
 If true, the container has been successfully computed.
string Label_
 Label for this object.
double ComputeFlops_
 Flops in Compute().
double ApplyFlops_
 Flops in Apply().
double ApplyInverseFlops_
 Flops in ApplyInverse().

Detailed Description

Ifpack_DenseContainer: a class to define containers for dense matrices.

To understand what an IFPACK container is, please refer to the documentation of the pure virtual class Ifpack_Container. Currently, containers are used by class Ifpack_BlockRelaxation.

Using block methods, one needs to store all diagonal blocks and to be also to apply the inverse of each diagonal block. Using class Ifpack_DenseContainer, one can store the blocks as dense matrices, which can be advantageous when the blocks are small. Otherwise, class Ifpack_SparseContainer is probably more appropriate.

A typical use of a container is as follows:

#include "Ifpack_DenseContainer.h"
...

// local matrix of (5,5), with two vectors for solution and rhs.
Ifpack_Container* Container = new
  Ifpack_DenseContainer(5,5);
  
// assign local rows 1, 5, 12, 13, 16 to this container
Container(0) = 1;
Container(1) = 5;
Container(2) = 12;
Container(3) = 13;
Container(4) = 16;

// Now extract the submatrix corresponding to rows and columns:
// 1. initialize the container.
Container.Initialize();
// 2. extract matrix values from an Epetra_RowMatrix A,
// and compute LU factors of the submatrix identified by rows
// and columns 1, 5, 12, 13 and 16 using LAPACK
Container.Compute(A);

// We can set the RHS as follows:
Container.RHS(0) = 1.0;
Container.RHS(1) = 2.0;
Container.RHS(2) = 3.0;
Container.RHS(3) = 4.0;
Container.RHS(4) = 5.0;

// The linear system with the submatrix is solved as follows:
Container.ApplyInverse().

A call to Compute() computes the LU factorization of the linear system matrix, using LAPACK (more precisely, by calling the corresponding routines in Epetra_SerialDenseSolver). The default behavior is to store the matrix factors by overwriting the linear system matrix itself. This way, method Apply() fails, as the original matrix does no longer exists. An alternative is to call KeepNonFactoredMatrix(true), which forces Ifpack_DenseContainer to maintain in memory a copy of the non-factored matrix.

Author:
Marzio Sala, SNL 9214.
Date:
Last update Nov-04.

Definition at line 75 of file Ifpack_DenseContainer.h.


Constructor & Destructor Documentation

Ifpack_DenseContainer::Ifpack_DenseContainer const int  NumRows,
const int  NumVectors = 1
[inline]
 

Constructors/Destructors Default constructor.

Definition at line 82 of file Ifpack_DenseContainer.h.

Ifpack_DenseContainer::Ifpack_DenseContainer const Ifpack_DenseContainer rhs  )  [inline]
 

Copy constructor.

Definition at line 94 of file Ifpack_DenseContainer.h.

virtual Ifpack_DenseContainer::~Ifpack_DenseContainer  )  [inline, virtual]
 

Destructor.

Definition at line 110 of file Ifpack_DenseContainer.h.


Member Function Documentation

Ifpack_DenseContainer& Ifpack_DenseContainer::operator= const Ifpack_DenseContainer rhs  )  [inline]
 

Overloaded operators. Operator=.

Definition at line 117 of file Ifpack_DenseContainer.h.

int Ifpack_DenseContainer::NumRows  )  const [virtual]
 

Get/Set methods. Returns the number of rows of the matrix and LHS/RHS.

Implements Ifpack_Container.

Definition at line 6 of file Ifpack_DenseContainer.cpp.

virtual int Ifpack_DenseContainer::NumVectors  )  const [inline, virtual]
 

Returns the number of vectors in LHS/RHS.

Implements Ifpack_Container.

Definition at line 144 of file Ifpack_DenseContainer.h.

virtual int Ifpack_DenseContainer::SetNumVectors const int  NumVectors  )  [inline, virtual]
 

Sets the number of vectors for LHS/RHS.

Implements Ifpack_Container.

Definition at line 150 of file Ifpack_DenseContainer.h.

double & Ifpack_DenseContainer::LHS const int  i,
const int  Vector = 0
[virtual]
 

Returns the i-th component of the vector Vector of LHS.

Implements Ifpack_Container.

Definition at line 49 of file Ifpack_DenseContainer.cpp.

double & Ifpack_DenseContainer::RHS const int  i,
const int  Vector = 0
[virtual]
 

Returns the i-th component of the vector Vector of RHS.

Implements Ifpack_Container.

Definition at line 55 of file Ifpack_DenseContainer.cpp.

int & Ifpack_DenseContainer::ID const int  i  )  [virtual]
 

Returns the ID associated to local row i.

The set of (local) rows assigned to this container is defined by calling ID(i) = j, where i (from 0 to NumRows()) indicates the container-row, and j indicates the local row in the calling process.

This is usually used to recorder the local row ID (on calling process) of the i-th row in the container.

Implements Ifpack_Container.

Definition at line 97 of file Ifpack_DenseContainer.cpp.

int Ifpack_DenseContainer::SetMatrixElement const int  row,
const int  col,
const double  value
[virtual]
 

Set the matrix element (row,col) to value.

Implements Ifpack_Container.

Definition at line 62 of file Ifpack_DenseContainer.cpp.

virtual int Ifpack_DenseContainer::SetParameters Teuchos::ParameterList &  List  )  [inline, virtual]
 

Sets all necessary parameters.

Implements Ifpack_Container.

Definition at line 191 of file Ifpack_DenseContainer.h.

virtual bool Ifpack_DenseContainer::IsInitialized  )  const [inline, virtual]
 

Returns true is the container has been successfully initialized.

Implements Ifpack_Container.

Definition at line 197 of file Ifpack_DenseContainer.h.

virtual bool Ifpack_DenseContainer::IsComputed  )  const [inline, virtual]
 

Returns true is the container has been successfully computed.

Implements Ifpack_Container.

Definition at line 203 of file Ifpack_DenseContainer.h.

virtual const char* Ifpack_DenseContainer::Label  )  const [inline, virtual]
 

Returns the label of this container.

Implements Ifpack_Container.

Definition at line 209 of file Ifpack_DenseContainer.h.

virtual int Ifpack_DenseContainer::SetKeepNonFactoredMatrix const bool  flag  )  [inline, virtual]
 

If flag is true, keeps a copy of the non-factored matrix.

Definition at line 215 of file Ifpack_DenseContainer.h.

virtual bool Ifpack_DenseContainer::KeepNonFactoredMatrix  )  const [inline, virtual]
 

Returns KeepNonFactoredMatrix_.

Definition at line 222 of file Ifpack_DenseContainer.h.

virtual const Epetra_SerialDenseMatrix& Ifpack_DenseContainer::LHS  )  const [inline, virtual]
 

Returns the dense vector containing the LHS.

Definition at line 228 of file Ifpack_DenseContainer.h.

virtual const Epetra_SerialDenseMatrix& Ifpack_DenseContainer::RHS  )  const [inline, virtual]
 

Returns the dense vector containing the RHS.

Definition at line 234 of file Ifpack_DenseContainer.h.

virtual const Epetra_SerialDenseMatrix& Ifpack_DenseContainer::Matrix  )  const [inline, virtual]
 

Returns the dense matrix or its factors.

Definition at line 240 of file Ifpack_DenseContainer.h.

virtual const Epetra_SerialDenseMatrix& Ifpack_DenseContainer::NonFactoredMatrix  )  const [inline, virtual]
 

Returns the non-factored dense matrix (only if stored).

Definition at line 246 of file Ifpack_DenseContainer.h.

virtual const Epetra_IntSerialDenseVector& Ifpack_DenseContainer::ID  )  const [inline, virtual]
 

Returns the integer dense vector of IDs.

Definition at line 252 of file Ifpack_DenseContainer.h.

int Ifpack_DenseContainer::Initialize  )  [virtual]
 

Mathematical methods. Initialize the container.

Implements Ifpack_Container.

Definition at line 12 of file Ifpack_DenseContainer.cpp.

int Ifpack_DenseContainer::Compute const Epetra_RowMatrix Matrix  )  [virtual]
 

Finalizes the linear system matrix and prepares for the application of the inverse.

Implements Ifpack_Container.

Definition at line 160 of file Ifpack_DenseContainer.cpp.

int Ifpack_DenseContainer::Apply  )  [virtual]
 

Apply the matrix to RHS, results are stored in LHS.

Implements Ifpack_Container.

Definition at line 190 of file Ifpack_DenseContainer.cpp.

int Ifpack_DenseContainer::ApplyInverse  )  [virtual]
 

Apply the inverse of the matrix to RHS, results are stored in LHS.

Implements Ifpack_Container.

Definition at line 82 of file Ifpack_DenseContainer.cpp.

virtual double Ifpack_DenseContainer::InitializeFlops  )  const [inline, virtual]
 

Returns the flops in Initialize().

Implements Ifpack_Container.

Definition at line 274 of file Ifpack_DenseContainer.h.

virtual double Ifpack_DenseContainer::ComputeFlops  )  const [inline, virtual]
 

Returns the flops in Compute().

Implements Ifpack_Container.

Definition at line 279 of file Ifpack_DenseContainer.h.

virtual double Ifpack_DenseContainer::ApplyFlops  )  const [inline, virtual]
 

Returns the flops in Apply().

Implements Ifpack_Container.

Definition at line 284 of file Ifpack_DenseContainer.h.

virtual double Ifpack_DenseContainer::ApplyInverseFlops  )  const [inline, virtual]
 

Returns the flops in ApplyInverse().

Implements Ifpack_Container.

Definition at line 289 of file Ifpack_DenseContainer.h.

virtual ostream& Ifpack_DenseContainer::Print std::ostream &  os  )  const [virtual]
 

Prints basic information on iostream. This function is used by operator<<.

Implements Ifpack_Container.

int Ifpack_DenseContainer::Extract const Epetra_RowMatrix Matrix  )  [private, virtual]
 

Extract the submatrices identified by the ID set int ID().

Definition at line 104 of file Ifpack_DenseContainer.cpp.


Member Data Documentation

int Ifpack_DenseContainer::NumRows_ [private]
 

Number of rows in the container.

Definition at line 303 of file Ifpack_DenseContainer.h.

int Ifpack_DenseContainer::NumVectors_ [private]
 

Number of vectors in the container.

Definition at line 305 of file Ifpack_DenseContainer.h.

Epetra_SerialDenseMatrix Ifpack_DenseContainer::NonFactoredMatrix_ [private]
 

Dense matrix, that contains the non-factored matrix.

Definition at line 307 of file Ifpack_DenseContainer.h.

Epetra_SerialDenseMatrix Ifpack_DenseContainer::Matrix_ [private]
 

Dense matrix.

Definition at line 309 of file Ifpack_DenseContainer.h.

Epetra_SerialDenseMatrix Ifpack_DenseContainer::LHS_ [private]
 

Dense vector representing the LHS.

Definition at line 311 of file Ifpack_DenseContainer.h.

Epetra_SerialDenseMatrix Ifpack_DenseContainer::RHS_ [private]
 

Dense vector representing the RHS.

Definition at line 313 of file Ifpack_DenseContainer.h.

Epetra_SerialDenseSolver Ifpack_DenseContainer::Solver_ [private]
 

Dense solver (solution will be get using LAPACK).

Definition at line 315 of file Ifpack_DenseContainer.h.

Epetra_IntSerialDenseVector Ifpack_DenseContainer::ID_ [private]
 

Sets of local rows.

Definition at line 317 of file Ifpack_DenseContainer.h.

bool Ifpack_DenseContainer::KeepNonFactoredMatrix_ [private]
 

If true, keeps a copy of the non-factored matrix.

Definition at line 319 of file Ifpack_DenseContainer.h.

bool Ifpack_DenseContainer::IsInitialized_ [private]
 

If true, the container has been successfully initialized.

Definition at line 321 of file Ifpack_DenseContainer.h.

bool Ifpack_DenseContainer::IsComputed_ [private]
 

If true, the container has been successfully computed.

Definition at line 323 of file Ifpack_DenseContainer.h.

string Ifpack_DenseContainer::Label_ [private]
 

Label for this object.

Definition at line 325 of file Ifpack_DenseContainer.h.

double Ifpack_DenseContainer::ComputeFlops_ [private]
 

Flops in Compute().

Definition at line 328 of file Ifpack_DenseContainer.h.

double Ifpack_DenseContainer::ApplyFlops_ [private]
 

Flops in Apply().

Definition at line 330 of file Ifpack_DenseContainer.h.

double Ifpack_DenseContainer::ApplyInverseFlops_ [private]
 

Flops in ApplyInverse().

Definition at line 332 of file Ifpack_DenseContainer.h.


The documentation for this class was generated from the following files:
Generated on Thu Sep 18 12:37:30 2008 for Ifpack Package Browser (Single Doxygen Collection) by doxygen 1.3.9.1