Belos::LinearProblem< ScalarType, MV, OP > Class Template Reference

The Belos::LinearProblem class is a wrapper that encapsulates the general information needed for solving a linear system of equations. The general information is being held as either Belos::Operator or Belos::MultiVec objects. More...

#include <BelosLinearProblem.hpp>

List of all members.

Public Member Functions

Constructors/Destructor
 LinearProblem (void)
 Default Constructor.
 LinearProblem (const RefCountPtr< const OP > &A, const RefCountPtr< MV > &X, const RefCountPtr< const MV > &B)
 Unpreconditioned linear system constructor.
 LinearProblem (const LinearProblem< ScalarType, MV, OP > &Problem)
 Copy Constructor.
virtual ~LinearProblem (void)
 Destructor.
Set methods
void SetOperator (const RefCountPtr< const OP > &A)
 Set Operator A of linear problem AX = B.
void SetLHS (const RefCountPtr< MV > &X)
 Set left-hand-side X of linear problem AX = B.
void SetRHS (const RefCountPtr< const MV > &B)
 Set right-hand-side B of linear problem AX = B.
void SetLeftPrec (const RefCountPtr< const OP > &LP)
 Set left preconditioning operator (LP) of linear problem AX = B.
void SetRightPrec (const RefCountPtr< const OP > &RP)
 Set right preconditioning operator (RP) of linear problem AX = B.
void SetParameterList (const RefCountPtr< ParameterList > &PL)
 Set the parameter list for defining the behavior of the linear problem class.
void SetBlockSize (int blocksize)
 Set the blocksize of the linear problem. This information is used to set up the linear problem for block solvers.
void SetCurrLSVec ()
 Inform the linear problem that the solver is finished with the current linear system.
void AssertSymmetric ()
 Inform the linear problem that the operator is symmetric.
void SolutionUpdated (const MV *SolnUpdate=0, ScalarType scale=Teuchos::ScalarTraits< ScalarType >::one())
 Inform the linear problem that the solution has been updated.
Reset method
void Reset (const RefCountPtr< MV > &newX=null, const RefCountPtr< const MV > &newB=null)
 Reset the linear problem manager.
Accessor methods
RefCountPtr< const OP > GetOperator () const
 Get a pointer to the operator A.
RefCountPtr< MV > GetLHS () const
 Get a pointer to the left-hand side X.
RefCountPtr< const MV > GetRHS () const
 Get a pointer to the right-hand side B.
const MV & GetInitResVec ()
 Get a pointer to the initial residual vector.
const MV & GetCurrResVec (const MV *CurrSoln=0)
 Get a pointer to the current residual vector.
RefCountPtr< MV > GetCurrLHSVec ()
 Get a pointer to the current left-hand side (solution) of the linear system.
RefCountPtr< MV > GetCurrRHSVec ()
 Get a pointer to the current right-hand side of the linear system.
RefCountPtr< const OP > GetLeftPrec () const
 Get a pointer to the left preconditioning operator.
RefCountPtr< const OP > GetRightPrec () const
 Get a pointer to the right preconditioning operator.
RefCountPtr< ParameterListGetParameterList () const
 Get a pointer to the parameter list.
int GetBlockSize () const
 Get the default blocksize being used by the linear problem.
int GetCurrBlockSize () const
 Get the current blocksize being used by the linear problem.
int GetNumToSolve () const
 Get the current number of linear systems being solved for.
int GetRHSIndex () const
 Get the 0-based index of the first vector in the current right-hand side block being solved for.
bool IsSolutionUpdated () const
 Get the current status of the solution.
bool IsOperatorSymmetric () const
 Get operator symmetry bool.
Apply / Compute methods
ReturnType Apply (const MV &x, MV &y)
 Apply the composite operator of this linear problem to x, returning y.
ReturnType ApplyOp (const MV &x, MV &y)
 Apply ONLY the operator to x, returning y.
ReturnType ApplyLeftPrec (const MV &x, MV &y)
 Apply ONLY the left preconditioner to x, returning y.
ReturnType ApplyRightPrec (const MV &x, MV &y)
 Apply ONLY the right preconditioner to x, returning y.
ReturnType ComputeResVec (MV *R, const MV *X=0, const MV *B=0)
 Compute a residual R for this operator given a solution X, and right-hand side B.


Detailed Description

template<class ScalarType, class MV, class OP>
class Belos::LinearProblem< ScalarType, MV, OP >

The Belos::LinearProblem class is a wrapper that encapsulates the general information needed for solving a linear system of equations. The general information is being held as either Belos::Operator or Belos::MultiVec objects.

Definition at line 57 of file BelosLinearProblem.hpp.


Constructor & Destructor Documentation

template<class ScalarType, class MV, class OP>
Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem void   ) 
 

Default Constructor.

Creates an empty Belos::LinearProblem instance. The operator A, left-hand-side X and right-hand-side B must be set using the SetOperator(), SetLHS() and SetRHS() methods respectively.

Definition at line 379 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem const RefCountPtr< const OP > &  A,
const RefCountPtr< MV > &  X,
const RefCountPtr< const MV > &  B
 

Unpreconditioned linear system constructor.

Creates an unpreconditioned LinearProblem instance with the Belos::Operator (A), initial guess (X), and right hand side (B). Preconditioners can be set using the SetLeftPrec() and SetRightPrec() methods, and scaling can also be set using the SetLeftScale() and SetRightScale() methods.

Definition at line 396 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
Belos::LinearProblem< ScalarType, MV, OP >::LinearProblem const LinearProblem< ScalarType, MV, OP > &  Problem  ) 
 

Copy Constructor.

Makes copy of an existing LinearProblem instance.

Definition at line 420 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
Belos::LinearProblem< ScalarType, MV, OP >::~LinearProblem void   )  [virtual]
 

Destructor.

Completely deletes a LinearProblem object.

Definition at line 447 of file BelosLinearProblem.hpp.


Member Function Documentation

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetOperator const RefCountPtr< const OP > &  A  )  [inline]
 

Set Operator A of linear problem AX = B.

Sets a pointer to an Operator. No copy of the operator is made.

Definition at line 98 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetLHS const RefCountPtr< MV > &  X  ) 
 

Set left-hand-side X of linear problem AX = B.

Sets a pointer to a MultiVec. No copy of the object is made.

Definition at line 522 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetRHS const RefCountPtr< const MV > &  B  )  [inline]
 

Set right-hand-side B of linear problem AX = B.

Sets a pointer to a MultiVec. No copy of the object is made.

Definition at line 108 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetLeftPrec const RefCountPtr< const OP > &  LP  )  [inline]
 

Set left preconditioning operator (LP) of linear problem AX = B.

Sets a pointer to an Operator. No copy of the operator is made.

Definition at line 113 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetRightPrec const RefCountPtr< const OP > &  RP  )  [inline]
 

Set right preconditioning operator (RP) of linear problem AX = B.

Sets a pointer to an Operator. No copy of the operator is made.

Definition at line 118 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetParameterList const RefCountPtr< ParameterList > &  PL  )  [inline]
 

Set the parameter list for defining the behavior of the linear problem class.

Definition at line 121 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetBlockSize int  blocksize  )  [inline]
 

Set the blocksize of the linear problem. This information is used to set up the linear problem for block solvers.

Definition at line 124 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SetCurrLSVec  ) 
 

Inform the linear problem that the solver is finished with the current linear system.

Note:
This method is to be only used by the solver to inform the linear problem manager that it's finished with this block of linear systems. The next time the Curr(RHS/LHS)Vec() is called, the next linear system will be returned. Computing the next linear system isn't done in this method in case the blocksize is changed.

Definition at line 529 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::AssertSymmetric  )  [inline]
 

Inform the linear problem that the operator is symmetric.

This knowledge may allow the operator to take advantage of the linear problem symmetry. However, this should not be set to true if the preconditioner is not symmetric, or symmetrically applied.

Definition at line 139 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::SolutionUpdated const MV *  SolnUpdate = 0,
ScalarType  scale = Teuchos::ScalarTraits< ScalarType >::one()
 

Inform the linear problem that the solution has been updated.

Next time GetCurrResVecs is called, a new residual will be computed. This keeps the linear problem from having to recompute the residual vector everytime it's asked for if the solution hasn't been updated.

Definition at line 564 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
void Belos::LinearProblem< ScalarType, MV, OP >::Reset const RefCountPtr< MV > &  newX = null,
const RefCountPtr< const MV > &  newB = null
 

Reset the linear problem manager.

This is useful for solving the linear system with another right-hand side. The internal flags will be set as if the linear system manager was just initialized.

Definition at line 581 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<const OP> Belos::LinearProblem< ScalarType, MV, OP >::GetOperator  )  const [inline]
 

Get a pointer to the operator A.

Definition at line 165 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<MV> Belos::LinearProblem< ScalarType, MV, OP >::GetLHS  )  const [inline]
 

Get a pointer to the left-hand side X.

Definition at line 168 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<const MV> Belos::LinearProblem< ScalarType, MV, OP >::GetRHS  )  const [inline]
 

Get a pointer to the right-hand side B.

Definition at line 171 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
const MV & Belos::LinearProblem< ScalarType, MV, OP >::GetInitResVec  ) 
 

Get a pointer to the initial residual vector.

Note:
This may be the preconditioned residual, if the linear problem is left-preconditioned.

Definition at line 594 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
const MV & Belos::LinearProblem< ScalarType, MV, OP >::GetCurrResVec const MV *  CurrSoln = 0  ) 
 

Get a pointer to the current residual vector.

Parameters:
CurrSoln [in] If non-null, then this is the LHS that is used to compute the current residual. If null, then GetCurrLHSVec() is used.
Note, the current residual is always computed with respect to GetCurrRHSVec().

Note:
  • This method computes the true residual of the current linear system with respect to GetCurrRHSVec() and GetCurrLHSVec() if CurrSoln==NULL or with respect to *CurrSoln if CurrSoln!=NULL.
  • If the solution hasn't been updated in the LinearProblem and a current solution has been computed by the solver (like GMRES), it can be passed into this method to compute the residual.

Definition at line 612 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr< MV > Belos::LinearProblem< ScalarType, MV, OP >::GetCurrLHSVec  ) 
 

Get a pointer to the current left-hand side (solution) of the linear system.

This method is called by the solver or any method that is interested in the current linear system being solved for.

  1. If the solution has been updated by the solver, then this vector is current ( see SolutionUpdated() ).
  2. If there is no linear system to solve, this method will return a NULL pointer

Definition at line 635 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr< MV > Belos::LinearProblem< ScalarType, MV, OP >::GetCurrRHSVec  ) 
 

Get a pointer to the current right-hand side of the linear system.

This method is called by the solver of any method that is interested in the current linear system being solved for.

  1. If the solution has been updated by the solver, then this vector is current ( see SolutionUpdated() ).
  2. If there is no linear system to solve, this method will return a NULL pointer

Definition at line 645 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<const OP> Belos::LinearProblem< ScalarType, MV, OP >::GetLeftPrec  )  const [inline]
 

Get a pointer to the left preconditioning operator.

Definition at line 218 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<const OP> Belos::LinearProblem< ScalarType, MV, OP >::GetRightPrec  )  const [inline]
 

Get a pointer to the right preconditioning operator.

Definition at line 221 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
RefCountPtr<ParameterList> Belos::LinearProblem< ScalarType, MV, OP >::GetParameterList  )  const [inline]
 

Get a pointer to the parameter list.

Definition at line 224 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
int Belos::LinearProblem< ScalarType, MV, OP >::GetBlockSize  )  const [inline]
 

Get the default blocksize being used by the linear problem.

Definition at line 227 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
int Belos::LinearProblem< ScalarType, MV, OP >::GetCurrBlockSize  )  const [inline]
 

Get the current blocksize being used by the linear problem.

This may be different from the default blocksize set for the linear problem in the event that the default blocksize doesn't divide evenly into the number of right-hand sides, but it should not be more than the default blocksize.

Definition at line 234 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
int Belos::LinearProblem< ScalarType, MV, OP >::GetNumToSolve  )  const [inline]
 

Get the current number of linear systems being solved for.

Since the block size is independent of the number of right-hand sides, it is important to know how many linear systems are being solved for when the status is checked. This is informative for residual checks because the entire block of residuals may not be of interest. Thus, this number can be anywhere between 1 and the blocksize of the linear system.

Definition at line 243 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
int Belos::LinearProblem< ScalarType, MV, OP >::GetRHSIndex  )  const [inline]
 

Get the 0-based index of the first vector in the current right-hand side block being solved for.

Since the block size is independent of the number of right-hand sides for some solvers (GMRES, CG, etc.), it is important to know which right-hand sides are being solved for. That may mean you need to update the information about the norms of your initial residual vector for weighting purposes. This information can keep you from querying the solver for information that rarely changes.

Definition at line 253 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
bool Belos::LinearProblem< ScalarType, MV, OP >::IsSolutionUpdated  )  const [inline]
 

Get the current status of the solution.

This only means that the current linear system being solved for ( obtained by GetCurr<LHS/RHS>Vec() ) has been updated by the solver. This will be true every iteration for solvers like CG, but not true until restarts for GMRES.

Definition at line 260 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
bool Belos::LinearProblem< ScalarType, MV, OP >::IsOperatorSymmetric  )  const [inline]
 

Get operator symmetry bool.

Definition at line 263 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
ReturnType Belos::LinearProblem< ScalarType, MV, OP >::Apply const MV &  x,
MV &  y
 

Apply the composite operator of this linear problem to x, returning y.

This application is the composition of the left/right preconditioner and operator. Most Krylov methods will use this application method within their code.

Precondition:

Definition at line 655 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
ReturnType Belos::LinearProblem< ScalarType, MV, OP >::ApplyOp const MV &  x,
MV &  y
 

Apply ONLY the operator to x, returning y.

This application is only of the linear problem operator, no preconditioners are applied. Flexible variants of Krylov methods will use this application method within their code.

Precondition:

Definition at line 691 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
ReturnType Belos::LinearProblem< ScalarType, MV, OP >::ApplyLeftPrec const MV &  x,
MV &  y
 

Apply ONLY the left preconditioner to x, returning y.

This application is only of the left preconditioner, which may be required for flexible variants of Krylov methods.

Note:
This will return Undefined if the left preconditioner is not defined for this operator.

Definition at line 700 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
ReturnType Belos::LinearProblem< ScalarType, MV, OP >::ApplyRightPrec const MV &  x,
MV &  y
 

Apply ONLY the right preconditioner to x, returning y.

This application is only of the right preconditioner, which may be required for flexible variants of Krylov methods.

Note:
This will return Undefined if the right preconditioner is not defined for this operator.

Definition at line 709 of file BelosLinearProblem.hpp.

template<class ScalarType, class MV, class OP>
ReturnType Belos::LinearProblem< ScalarType, MV, OP >::ComputeResVec MV *  R,
const MV *  X = 0,
const MV *  B = 0
 

Compute a residual R for this operator given a solution X, and right-hand side B.

This method will compute the residual for the current linear system if X and B are null pointers. The result will be returned into R. Otherwise R = OP(A)X - B will be computed and returned.

Note:
This residual will be a preconditioned residual if the system has a left preconditioner.

Definition at line 718 of file BelosLinearProblem.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Sep 18 12:30:13 2008 for Belos by doxygen 1.3.9.1