68 std::vector<Teuchos::RCP<Vector<Real> > > a(state->current+1);
69 std::vector<Teuchos::RCP<Vector<Real> > > b(state->current+1);
70 Real bv = 0.0, av = 0.0, bs = 0.0, as = 0.0;
71 for (
int i = 0; i <= state->current; i++) {
73 b[i]->set(*(state->iterDiff[i]));
74 b[i]->scale(1.0/sqrt(state->product[i]));
75 bv = b[i]->dot(v.
dual());
79 applyH0(*a[i],*(state->gradDiff[i]),x);
81 for (
int j = 0; j < i; j++) {
82 bs = b[j]->dot((state->gradDiff[i])->dual());
84 as = a[j]->dot((state->gradDiff[i])->dual());
85 a[i]->axpy(-as,*a[j]);
87 as = a[i]->dot((state->gradDiff[i])->dual());
88 a[i]->scale(1.0/sqrt(as));
89 av = a[i]->dot(v.
dual());
100 if (state->iter != 0 && state->current != -1) {
101 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
102 Hv.
scale(state->product[state->current]/ss);
113 std::vector<Real> alpha(state->current+1,0.0);
114 for (
int i = state->current; i>=0; i--) {
115 alpha[i] = state->gradDiff[i]->dot(Bv);
116 alpha[i] /= state->product[i];
117 Bv.
axpy(-alpha[i],(state->iterDiff[i])->dual());
121 Teuchos::RCP<Vector<Real> > tmp = Bv.
clone();
126 for (
int i = 0; i <= state->current; i++) {
127 beta = state->iterDiff[i]->dot(Bv.
dual());
128 beta /= state->product[i];
129 Bv.
axpy((alpha[i]-beta),*(state->gradDiff[i]));
139 if (state->iter != 0 && state->current != -1) {
140 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
141 Bv.
scale(ss/state->product[state->current]);
virtual const Vector & dual() const
Return dual representation of , for example, the result of applying a Riesz map, or change of basis...
virtual void scale(const Real alpha)=0
Compute where .
virtual void axpy(const Real alpha, const Vector &x)
Compute where .
Provides definitions for limited-memory DFP operators.
virtual Teuchos::RCP< Vector > clone() const =0
Clone to make a new (uninitialized) vector.
void applyB(Vector< Real > &Bv, const Vector< Real > &v, const Vector< Real > &x)
Defines the linear algebra or vector space interface.
Provides interface for and implements limited-memory secant operators.
Teuchos::RCP< SecantState< Real > > & get_state()
void applyH(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &x)
virtual void applyH0(Vector< Real > &Hv, const Vector< Real > &v, const Vector< Real > &x)
virtual void set(const Vector &x)
Set where .
virtual void applyB0(Vector< Real > &Bv, const Vector< Real > &v, const Vector< Real > &x)