66 std::vector<Teuchos::RCP<Vector<Real> > > a(state->current+1);
67 std::vector<Teuchos::RCP<Vector<Real> > > b(state->current+1);
68 Real bv = 0.0, av = 0.0, bs = 0.0, as = 0.0;
69 for (
int i = 0; i <= state->current; i++) {
71 b[i]->set(*(state->iterDiff[i]));
72 b[i]->scale(1.0/sqrt(state->product[i]));
73 bv = b[i]->dot(v.
dual());
77 applyH0(*a[i],*(state->gradDiff[i]),x);
79 for (
int j = 0; j < i; j++) {
80 bs = b[j]->dot((state->gradDiff[i])->dual());
82 as = a[j]->dot((state->gradDiff[i])->dual());
83 a[i]->axpy(-as,*a[j]);
85 as = a[i]->dot((state->gradDiff[i])->dual());
86 a[i]->scale(1.0/sqrt(as));
87 av = a[i]->dot(v.
dual());
98 if (state->iter != 0 && state->current != -1) {
99 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
100 Hv.
scale(state->product[state->current]/ss);
111 std::vector<Real> alpha(state->current+1,0.0);
112 for (
int i = state->current; i>=0; i--) {
113 alpha[i] = state->gradDiff[i]->dot(Bv);
114 alpha[i] /= state->product[i];
115 Bv.
axpy(-alpha[i],(state->iterDiff[i])->dual());
119 Teuchos::RCP<Vector<Real> > tmp = Bv.
clone();
124 for (
int i = 0; i <= state->current; i++) {
125 beta = state->iterDiff[i]->dot(Bv.
dual());
126 beta /= state->product[i];
127 Bv.
axpy((alpha[i]-beta),*(state->gradDiff[i]));
137 if (state->iter != 0 && state->current != -1) {
138 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
139 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)