59 template<
class ScalarT>
66 ScalarT eval(
const std::vector<ScalarT> &x);
80 template<
class ScalarT>
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;
129 return dynamic_cast<const SV&
>(x).getVector();
134 return dynamic_cast<SV&
>(x).getVector();
144 ROL::Ptr<const vector> xp = getVector(x);
145 return zfunc_.eval(*xp);
151 ROL::Ptr<const vector> xp = getVector(x);
152 ROL::Ptr<vector> gp = getVector(g);
156 std::vector<GradType> x_grad(n);
158 for(
uint i=0; i<n; ++i) {
159 x_grad[i] = (*xp)[i];
163 GradType J_grad = zfuncGrad_.eval(x_grad);
165 for(
uint i=0; i<n; ++i) {
166 (*gp)[i] = J_grad.dx(i);
175 ROL::Ptr<vector> hvp = getVector(hv);
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);
191 HessVecType J_hessvec = zfuncHessVec_.eval(x_hessvec);
193 for(
uint i=0; i<n; ++i) {
194 (*hvp)[i] = (J_hessvec.dx(i)).fastAccessDx(0);
Provides the interface to evaluate objective functions.
FunctionZakharov< HessVecType > zfuncHessVec_
ScalarT eval(const std::vector< ScalarT > &x)
A Sacado-accessible version of the Zakharov function to differentiate Where .
typename PV< Real >::size_type size_type
FunctionZakharov< Real > zfunc_
void gradient(Vector< Real > &g, const Vector< Real > &x, Real &tol)
Compute gradient.
FunctionZakharov< GradType > zfuncGrad_
Defines the linear algebra or vector space interface.
ROL::Ptr< vector > getVector(V &x)
Sacado::Fad::SFad< Real, 1 > DirDerivType
ROL::Ptr< const vector > getVector(const V &x)
Sacado::Fad::DFad< Real > GradType
std::vector< Real > vector
Zakharov_Sacado_Objective()
Real value(const Vector< Real > &x, Real &tol)
Compute value.
Sacado::Fad::DFad< DirDerivType > HessVecType
void hessVec(Vector< Real > &hv, const Vector< Real > &v, const Vector< Real > &x, Real &tol)
Apply Hessian approximation to vector.