RVLUmin::CGStep< Scalar > Class Template Reference

Single iteration of the Conjugate Gradient method for solution of SPD linear systems. More...

#include <cgalg.hh>

Inheritance diagram for RVLUmin::CGStep< Scalar >:

RVLAlg::Algorithm List of all members.

Public Member Functions

void run ()
 Execute a single CG step.
 CGStep (Vector< Scalar > &x0, LinearOp< Scalar > const &inA, Vector< Scalar > const &rhs, atype &_rnormsq)
 constructor:

Protected Member Functions

void restart ()
 restart CG for the current x.

Protected Attributes

Vector< Scalar > & x
const LinearOp< Scalar > & A
Vector< Scalar > const & b
Vector< Scalar > r
Scalar curv
atype & rnormsq
Vector< Scalar > p
Vector< Scalar > w

Detailed Description

template<typename Scalar>
class RVLUmin::CGStep< Scalar >

Single iteration of the Conjugate Gradient method for solution of SPD linear systems.

Stores const references for linear map, represented as RVL::LinearOp, and right-hand side vector, represented as RVL::Vector. Updates solution vector and residual norm, for which the class stores mutable references. Detection of negative curvature (implying failure of SPD condition) throws exception. Uses RVL::ProtectedDivision to compute alpha, beta, with default zerodivide tolerance.

Definition at line 82 of file cgalg.hh.


Constructor & Destructor Documentation

template<typename Scalar>
RVLUmin::CGStep< Scalar >::CGStep ( Vector< Scalar > &  x0,
LinearOp< Scalar > const &  inA,
Vector< Scalar > const &  rhs,
atype &  _rnormsq 
)

constructor:

Parameters:
x0 - mutable reference to solution vector (external), updated by CGStep::run()
inA - const reference to LinearOp (external) defining problem; presumed to be SPD
rhs - const reference to RHS or target vector (external)
_rnormsq - mutable reference to residual norm-squared scalar; constructor initializes, CGStep::run() updates

Definition at line 147 of file cgalg.hh.


Member Function Documentation

template<typename Scalar>
void RVLUmin::CGStep< Scalar >::run (  )  [virtual]

Execute a single CG step.

If CG finds a direction of negative curvature <p, Ap> < 0, it will NOT take a step

Implements RVLAlg::Algorithm.

Definition at line 92 of file cgalg.hh.

References RVLUmin::CGStep< Scalar >::A, RVLUmin::CGStep< Scalar >::curv, RVLUmin::CGStep< Scalar >::p, RVLUmin::CGStep< Scalar >::r, RVLUmin::realgt(), RVLUmin::CGStep< Scalar >::rnormsq, RVLUmin::CGStep< Scalar >::w, and RVLUmin::CGStep< Scalar >::x.

template<typename Scalar>
void RVLUmin::CGStep< Scalar >::restart (  )  [protected]

restart CG for the current x.

This should only be used if x is modified outside of this algorithm.

Definition at line 163 of file cgalg.hh.

References RVLUmin::CGStep< Scalar >::A, RVLUmin::CGStep< Scalar >::b, RVLUmin::CGStep< Scalar >::p, RVLUmin::CGStep< Scalar >::r, RVLUmin::CGStep< Scalar >::rnormsq, RVLUmin::CGStep< Scalar >::w, and RVLUmin::CGStep< Scalar >::x.


Member Data Documentation

template<typename Scalar>
Vector<Scalar>& RVLUmin::CGStep< Scalar >::x [protected]

Definition at line 171 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
const LinearOp<Scalar>& RVLUmin::CGStep< Scalar >::A [protected]

Definition at line 172 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
Vector<Scalar> const& RVLUmin::CGStep< Scalar >::b [protected]

Definition at line 173 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart().

template<typename Scalar>
Vector<Scalar> RVLUmin::CGStep< Scalar >::r [protected]

Definition at line 174 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
Scalar RVLUmin::CGStep< Scalar >::curv [protected]

Definition at line 175 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
atype& RVLUmin::CGStep< Scalar >::rnormsq [protected]

Definition at line 176 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
Vector<Scalar> RVLUmin::CGStep< Scalar >::p [protected]

Definition at line 177 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().

template<typename Scalar>
Vector<Scalar> RVLUmin::CGStep< Scalar >::w [protected]

Definition at line 178 of file cgalg.hh.

Referenced by RVLUmin::CGStep< Scalar >::restart(), and RVLUmin::CGStep< Scalar >::run().


The documentation for this class was generated from the following file:
Generated on 5 Jan 2017 for RvlUmin by  doxygen 1.4.7