37 VectorXd fgrad = VectorXd::Zero(
npars);
38 MatrixXd fhessian = MatrixXd::Zero(
npars,
npars);
39 function->calcValGradHessian(x, fval, fgrad, fhessian);
42 grad = VectorXd::Zero(
npars);
44 for(
unsigned int i=0;i<
npars;++i)
46 val += fgrad(i)*fgrad(i);
49 for(
unsigned int j=0;j<
npars;++j)
51 for(
unsigned int i=0;i<
npars;++i)
53 grad(j) += fgrad(i)*fhessian(i,j);