59 template<
class ScalarT>
64 ScalarT eval(
const std::vector<ScalarT> &x);
78 template<
class ScalarT>
86 for(
unsigned i=0; i<x.size(); ++i) {
88 kdotx += double(i+1)*x[i];
92 J = xdotx + pow(kdotx,2)/4.0 + pow(kdotx,4)/16.0;
122 Teuchos::RCP<const std::vector<Real> > xp =
124 return zfunc_.eval(*xp);
129 Teuchos::RCP<std::vector<Real> > gp =
131 Teuchos::RCP<const std::vector<Real> > xp =
134 unsigned n = xp->size();
136 std::vector<GradType> x_grad(n);
138 for(
unsigned i=0; i<n; ++i) {
139 x_grad[i] = (*xp)[i];
143 GradType J_grad = zfuncGrad_.eval(x_grad);
145 for(
unsigned i=0; i<n; ++i) {
146 (*gp)[i] = J_grad.dx(i);
153 Teuchos::RCP<std::vector<Real> > hvp =
155 Teuchos::RCP<const std::vector<Real> > vp =
157 Teuchos::RCP<const std::vector<Real> > xp =
160 unsigned n = xp->size();
162 std::vector<HessVecType> x_hessvec(n);
164 for(
unsigned i=0; i<n; ++i) {
166 tmp.fastAccessDx(0)= (*vp)[i];
168 x_hessvec[i].diff(i,n);
172 HessVecType J_hessvec = zfuncHessVec_.eval(x_hessvec);
174 for(
unsigned i=0; i<n; ++i) {
175 (*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 .
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.
Provides the std::vector implementation of the ROL::Vector interface.
Sacado::Fad::SFad< Real, 1 > DirDerivType
Sacado::Fad::DFad< Real > GradType
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.