10#ifndef ROL_SECANTFACTORY_H
14#ifndef ROL_BARZILAIBORWEIN_H
15#define ROL_BARZILAIBORWEIN_H
26class BarzilaiBorwein :
public Secant<Real> {
32 BarzilaiBorwein(
int type = 1) : Secant<Real>(1), type_(type) {}
35 void applyH( Vector<Real> &Hv,
const Vector<Real> &v )
const {
37 const ROL::Ptr<SecantState<Real> >& state = Secant<Real>::get_state();
40 if ( state->iter != 0 && state->current != -1 ) {
42 Real yy = state->gradDiff[state->current]->dot(*(state->gradDiff[state->current]));
43 Hv.scale(state->product[state->current]/yy);
45 else if ( type_ == 2 ) {
46 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
47 Hv.scale(ss/state->product[state->current]);
53 void applyB( Vector<Real> &Bv,
const Vector<Real> &v )
const {
55 const ROL::Ptr<SecantState<Real> >& state = Secant<Real>::get_state();
58 if ( state->iter != 0 && state->current != -1 ) {
60 Real yy = state->gradDiff[state->current]->dot(*(state->gradDiff[state->current]));
61 Bv.scale(yy/state->product[state->current]);
63 else if ( type_ == 2 ) {
64 Real ss = state->iterDiff[state->current]->dot(*(state->iterDiff[state->current]));
65 Bv.scale(state->product[state->current]/ss);