51 #include "Teuchos_ParameterList.hpp" 60 std::vector<Teuchos::RCP<Vector<Real> > >
iterDiff;
61 std::vector<Teuchos::RCP<Vector<Real> > >
gradDiff;
73 Teuchos::RCP<SecantState<Real> >
state_;
81 Secant(
int M = 10 ) : isInitialized_(false) {
88 Teuchos::RCP<SecantState<Real> >&
get_state() {
return state_; }
89 const Teuchos::RCP<SecantState<Real> >&
get_state()
const {
return state_; }
94 const Real snorm,
const int iter ) {
96 if ( !isInitialized_ ) {
97 state_->iterate = x.
clone();
98 isInitialized_ =
true;
100 state_->iterate->set(x);
104 gradDiff->axpy(-one,gp);
106 Real sy = s.
dot(gradDiff->dual());
107 if (sy > ROL_EPSILON<Real>()*snorm*snorm) {
108 if (state_->current < state_->storage-1) {
112 state_->iterDiff.erase(state_->iterDiff.begin());
113 state_->gradDiff.erase(state_->gradDiff.begin());
114 state_->product.erase(state_->product.begin());
116 state_->iterDiff.push_back(s.
clone());
117 state_->iterDiff[state_->current]->set(s);
118 state_->gradDiff.push_back(grad.
clone());
119 state_->gradDiff[state_->current]->set(*gradDiff);
120 state_->product.push_back(sy);
130 if (state_->iter != 0 && state_->current != -1) {
131 Real yy = state_->gradDiff[state_->current]->dot(*(state_->gradDiff[state_->current]));
132 Hv.
scale(state_->product[state_->current]/yy);
142 if (state_->iter != 0 && state_->current != -1) {
143 Real yy = state_->gradDiff[state_->current]->dot(*(state_->gradDiff[state_->current]));
144 Bv.
scale(yy/state_->product[state_->current]);
150 Teuchos::RCP<Vector<Real> > vec = x.
clone();
151 Teuchos::RCP<Vector<Real> > Hvec = x.
clone();
152 Teuchos::RCP<Vector<Real> > Bvec = x.
clone();
159 vec->axpy(-one,*Bvec);
160 std::cout <<
" ||BHv-v|| = " << vec->norm() <<
"\n";
166 vec->axpy(-one,*Hvec);
167 std::cout <<
" ||HBv-v|| = " << vec->norm() <<
"\n";
std::vector< Teuchos::RCP< Vector< Real > > > iterDiff
virtual void scale(const Real alpha)=0
Compute where .
Teuchos::RCP< Vector< Real > > iterate
std::vector< Teuchos::RCP< Vector< Real > > > gradDiff
void test(const Vector< Real > &x, const Vector< Real > &s) const
Contains definitions of custom data types in ROL.
void applyInverse(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply inverse of linear operator.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
Defines the linear algebra or vector space interface.
virtual Real dot(const Vector &x) const =0
Compute where .
virtual void applyH0(Vector< Real > &Hv, const Vector< Real > &v) const
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
const Teuchos::RCP< SecantState< Real > > & get_state() const
Provides interface for and implements limited-memory secant operators.
virtual void updateStorage(const Vector< Real > &x, const Vector< Real > &grad, const Vector< Real > &gp, const Vector< Real > &s, const Real snorm, const int iter)
std::vector< Real > product2
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Apply linear operator.
Teuchos::RCP< SecantState< Real > > & get_state()
Provides the interface to apply a linear operator.
Teuchos::RCP< SecantState< Real > > state_
virtual void set(const Vector &x)
Set where .
std::vector< Real > product
virtual void applyB0(Vector< Real > &Bv, const Vector< Real > &v) const