54 #ifndef ROL_ROSENBROCK_HPP 55 #define ROL_ROSENBROCK_HPP 65 template<
class Real,
class XPrim=StdVector<Real>,
class XDual=StdVector<Real> >
71 typedef typename vector::size_type
uint;
79 template<
class VectorType>
81 return Teuchos::dyn_cast<
const VectorType>((x)).getVector();
84 template<
class VectorType>
86 return Teuchos::dyn_cast<VectorType>(x).
getVector();
95 RCP<const vector> xp = getVector<XPrim>(x);
99 for(
uint i=0; i<n/2; i++ ) {
100 val +=
alpha_ * pow(pow((*xp)[2*i],2) - (*xp)[2*i+1], 2);
101 val += pow((*xp)[2*i] - 1.0, 2);
114 RCP<const vector> xp = getVector<XPrim>(x);
115 RCP<vector> gp = getVector<XDual>(g);
118 for(
uint i=0; i<n/2; i++ ) {
119 (*gp)[2*i] = 4.0*
alpha_*(pow((*xp)[2*i],2) - (*xp)[2*i+1])*(*xp)[2*i] + 2.0*((*xp)[2*i]-1.0);
120 (*gp)[2*i+1] = -2.0*
alpha_*(pow((*xp)[2*i],2) - (*xp)[2*i+1]);
133 RCP<const vector> xp = getVector<XPrim>(x);
134 RCP<const vector> vp = getVector<XPrim>(v);
135 RCP<vector> hvp = getVector<XDual>(hv);
138 for(
uint i=0; i<n/2; i++ ) {
139 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
140 Real h12 = -4.0*
alpha_*(*xp)[2*i];
143 (*hvp)[2*i] = h11*(*vp)[2*i] + h12*(*vp)[2*i+1];
144 (*hvp)[2*i+1] = h12*(*vp)[2*i] + h22*(*vp)[2*i+1];
152 RCP<const vector> xp = getVector<XPrim>(x);
153 RCP<const vector> vp = getVector<XDual>(v);
154 RCP<vector> hvp = getVector<XPrim>(hv);
157 for(
uint i=0; i<n/2; i++ ) {
158 Real h11 = 4.0*
alpha_*(3.0*pow((*xp)[2*i],2)-(*xp)[2*i+1]) + 2.0;
159 Real h12 = -4.0*
alpha_*(*xp)[2*i];
162 (*hvp)[2*i] = (1.0/(h11*h22-h12*h12))*( h22*(*vp)[2*i] - h12*(*vp)[2*i+1]);
163 (*hvp)[2*i+1] = (1.0/(h11*h22-h12*h12))*(-h12*(*vp)[2*i] + h11*(*vp)[2*i+1]);
168 template<
class Real,
class XPrim,
class XDual>
176 Teuchos::RCP<std::vector<Real> > x0p = Teuchos::rcp(
new std::vector<Real>(n,0.0));
177 for (
int i = 0; i < n/2; i++ ) {
181 x0 = Teuchos::rcp(
new XPrim(x0p));
184 Teuchos::RCP<std::vector<Real> > xp = Teuchos::rcp(
new std::vector<Real>(n,0.0));
185 for (
int i = 0; i < n; i++ ) {
188 x = Teuchos::rcp(
new XPrim(xp));
Provides the interface to evaluate objective functions.
Teuchos::RCP< vector > getVector(V &x)
std::vector< Real > vector
Rosenbrock's function.
virtual void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
void invHessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply inverse Hessian approximation to vector.
Defines the linear algebra or vector space interface.
Teuchos::RCP< const vector > getVector(const V &x)
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Real value(const Vector< Real > &x, Real &tol)
Compute value.
void getRosenbrock(Teuchos::RCP< Objective< Real > > &obj, Teuchos::RCP< Vector< Real > > &x0, Teuchos::RCP< Vector< Real > > &x)
Objective_Rosenbrock(Real alpha=100.0)