25template<
class ScalarT>
32 ScalarT
eval(
const std::vector<ScalarT> &x);
46template<
class ScalarT>
49 typedef typename std::vector<ScalarT>::size_type luint;
56 for(luint i=0; i<x.size(); ++i) {
58 kdotx += ScalarT(i+1)*x[i];
62 J = xdotx + pow(kdotx,2)/4.0 + pow(kdotx,4)/16.0;
79 typedef typename vector::size_type
luint;
110 ROL::Ptr<const vector> xp =
getVector(x);
117 ROL::Ptr<const vector> xp =
getVector(x);
120 luint n = xp->size();
122 std::vector<GradType> x_grad(n);
124 for(
luint i=0; i<n; ++i) {
125 x_grad[i] = (*xp)[i];
131 for(
luint i=0; i<n; ++i) {
132 (*gp)[i] = J_grad.dx(i);
142 ROL::Ptr<const vector> vp =
getVector(v);
143 ROL::Ptr<const vector> xp =
getVector(x);
145 luint n = xp->size();
147 std::vector<HessVecType> x_hessvec(n);
149 for(
luint i=0; i<n; ++i) {
151 tmp.fastAccessDx(0)= (*vp)[i];
153 x_hessvec[i].diff(i,n);
159 for(
luint i=0; i<n; ++i) {
160 (*hvp)[i] = (J_hessvec.dx(i)).fastAccessDx(0);
ScalarT eval(const std::vector< ScalarT > &x)
A Sacado-accessible version of the Zakharov function to differentiate.
Provides the interface to evaluate objective functions.
Provides the ROL::Vector interface for scalar values, to be used, for example, with scalar constraint...
Defines the linear algebra or vector space interface.
ROL::Ptr< const vector > getVector(const V &x)
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.
Zakharov_Sacado_Objective()
FunctionZakharov< HessVecType > zfuncHessVec_
Sacado::Fad::DFad< Real > GradType
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
Sacado::Fad::SFad< Real, 1 > DirDerivType
Real value(const Vector< Real > &x, Real &tol)
Compute value.
std::vector< Real > vector
FunctionZakharov< GradType > zfuncGrad_
FunctionZakharov< Real > zfunc_
ROL::Ptr< vector > getVector(V &x)
Sacado::Fad::DFad< DirDerivType > HessVecType