58 using Secant<Real>::state_;
61 lBFGS(
int M,
bool useDefaultScaling =
true, Real Bscaling = Real(1))
62 :
Secant<Real>(M,useDefaultScaling,Bscaling) {}
65 void applyH( Vector<Real> &Hv,
const Vector<Real> &v )
const {
69 std::vector<Real> alpha(
state_->current+1,
zero);
70 for (
int i =
state_->current; i>=0; i--) {
71 alpha[i] =
state_->iterDiff[i]->dot(Hv);
72 alpha[i] /=
state_->product[i];
73 Hv.axpy(-alpha[i],(
state_->gradDiff[i])->dual());
77 Ptr<Vector<Real>> tmp = Hv.clone();
82 for (
int i = 0; i <=
state_->current; i++) {
84 beta = Hv.apply(*
state_->gradDiff[i]);
85 beta /=
state_->product[i];
86 Hv.axpy((alpha[i]-beta),*(
state_->iterDiff[i]));
91 void applyB( Vector<Real> &Bv,
const Vector<Real> &v )
const {
97 std::vector<Ptr<Vector<Real>>> a(
state_->current+1);
98 std::vector<Ptr<Vector<Real>>> b(
state_->current+1);
99 Real bv(0), av(0), bs(0), as(0);
100 for (
int i = 0; i <=
state_->current; i++) {
102 b[i]->set(*(
state_->gradDiff[i]));
103 b[i]->scale(one/sqrt(
state_->product[i]));
111 for (
int j = 0; j < i; j++) {
114 a[i]->axpy(bs,*b[j]);
117 a[i]->axpy(-as,*a[j]);
121 a[i]->scale(one/sqrt(as));
Objective_SerialSimOpt(const Ptr< Obj > &obj, const V &ui) z0 zero)()
Provides interface for and implements limited-memory secant operators.
virtual void applyB0(Vector< Real > &Bv, const Vector< Real > &v) const
const Ptr< SecantState< Real > > state_
virtual void applyH0(Vector< Real > &Hv, const Vector< Real > &v) const
void apply(Vector< Real > &Hv, const Vector< Real > &v, Real &tol) const
Provides definitions for limited-memory BFGS operators.
lBFGS(int M, bool useDefaultScaling=true, Real Bscaling=Real(1))
void applyH(Vector< Real > &Hv, const Vector< Real > &v) const
void applyB(Vector< Real > &Bv, const Vector< Real > &v) const