44 #ifndef ROL_CONJUGATEGRADIENTS_H
45 #define ROL_CONJUGATEGRADIENTS_H
61 ROL::Ptr<Vector<Real> >
r_;
62 ROL::Ptr<Vector<Real> >
v_;
63 ROL::Ptr<Vector<Real> >
p_;
64 ROL::Ptr<Vector<Real> >
Ap_;
67 ConjugateGradients(Real absTol = 1.e-4, Real relTol = 1.e-2,
unsigned maxit = 100,
bool useInexact =
false)
71 int &iter,
int &flag ) {
80 Real rnorm = b.
norm();
82 Real itol = std::sqrt(ROL_EPSILON<Real>());
93 Real kappa(0), beta(0), alpha(0), tmp(0),
zero(0);
94 Real gv =
v_->dot(
r_->dual());
96 for (iter = 0; iter < (int)Krylov<Real>::getMaximumIteration(); iter++) {
102 kappa =
p_->dot(
Ap_->dual());
103 if ( kappa <= zero ) {
111 r_->axpy(-alpha,*
Ap_);
113 if ( rnorm < rtol ) {
117 itol = std::sqrt(ROL_EPSILON<Real>());
120 gv =
v_->dot(
r_->dual());
virtual ROL::Ptr< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
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 void zero()
Set to zero vector.
Defines the linear algebra or vector space interface.
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0_ zero()
ROL::Ptr< Vector< Real > > v_
virtual void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
Provides definitions of the Conjugate Gradient solver.
Provides definitions for Krylov solvers.
Provides the interface to apply a linear operator.
ConjugateGradients(Real absTol=1.e-4, Real relTol=1.e-2, unsigned maxit=100, bool useInexact=false)
ROL::Ptr< Vector< Real > > p_
ROL::Ptr< Vector< Real > > r_
virtual Real norm() const =0
Returns where .
ROL::Ptr< Vector< Real > > Ap_
Real run(Vector< Real > &x, LinearOperator< Real > &A, const Vector< Real > &b, LinearOperator< Real > &M, int &iter, int &flag)