59template<
class ScalarT>
66 ScalarT
eval(
const std::vector<ScalarT> &x);
80template<
class ScalarT>
83 typedef typename std::vector<ScalarT>::size_type uint;
90 for(uint i=0; i<x.size(); ++i) {
92 kdotx += ScalarT(i+1)*x[i];
96 J = xdotx + pow(kdotx,2)/4.0 + pow(kdotx,4)/16.0;
113 typedef typename vector::size_type
uint;
144 ROL::Ptr<const vector> xp =
getVector(x);
151 ROL::Ptr<const vector> xp =
getVector(x);
156 std::vector<GradType> x_grad(n);
158 for(
uint i=0; i<n; ++i) {
159 x_grad[i] = (*xp)[i];
165 for(
uint i=0; i<n; ++i) {
166 (*gp)[i] = J_grad.dx(i);
176 ROL::Ptr<const vector> vp =
getVector(v);
177 ROL::Ptr<const vector> xp =
getVector(x);
181 std::vector<HessVecType> x_hessvec(n);
183 for(
uint i=0; i<n; ++i) {
185 tmp.fastAccessDx(0)= (*vp)[i];
187 x_hessvec[i].diff(i,n);
193 for(
uint i=0; i<n; ++i) {
194 (*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