10 #ifndef ROL_SECANTFACTORY_H
14 #ifndef ROL_BARZILAIBORWEIN_H
15 #define ROL_BARZILAIBORWEIN_H
26 class 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 {
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 {
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);
Ptr< SecantState< Real > > & get_state()