44 #ifndef ROL_CONJUGATEGRADIENTS_H 45 #define ROL_CONJUGATEGRADIENTS_H 63 Teuchos::RCP<Vector<Real> >
r_;
64 Teuchos::RCP<Vector<Real> >
v_;
65 Teuchos::RCP<Vector<Real> >
p_;
66 Teuchos::RCP<Vector<Real> >
Ap_;
69 ConjugateGradients(Real absTol = 1.e-4, Real relTol = 1.e-2,
unsigned maxit = 100,
bool useInexact =
false)
70 :
Krylov<Real>(absTol,relTol,maxit), isInitialized_(false), useInexact_(useInexact) {}
73 int &iter,
int &flag ) {
74 if ( !isInitialized_ ) {
79 isInitialized_ =
true;
82 Real rnorm = b.
norm();
89 M.
apply(*v_, *r_, itol);
99 Real gv = v_->dot(r_->dual());
101 for (iter = 0; iter < (int)Krylov<Real>::getMaximumIteration(); iter++) {
105 A.
apply(*Ap_, *p_, itol);
107 kappa = p_->dot(Ap_->dual());
108 if ( kappa <= 0.0 ) {
116 r_->axpy(-alpha,*Ap_);
118 if ( rnorm < rtol ) {
123 M.
apply(*v_, *r_, itol);
125 gv = v_->dot(r_->dual());
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Teuchos::RCP< Vector< Real > > v_
Contains definitions of custom data types in ROL.
virtual void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const =0
Apply linear operator.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< Vector< Real > > r_
void run(Vector< Real > &x, LinearOperator< Real > &A, const Vector< Real > &b, LinearOperator< Real > &M, int &iter, int &flag)
Provides definitions of the Conjugate Gradient solver.
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
Teuchos::RCP< Vector< Real > > Ap_
ConjugateGradients(Real absTol=1.e-4, Real relTol=1.e-2, unsigned maxit=100, bool useInexact=false)
virtual Real norm() const =0
Returns where .
Teuchos::RCP< Vector< Real > > p_
static const double ROL_EPSILON
Platform-dependent machine epsilon.