2 #include <boost/function.hpp>
4 #include <boost/shared_ptr.hpp>
10 using boost::function;
11 using Eigen::VectorXd;
12 using Eigen::MatrixXd;
16 typedef boost::shared_ptr<ScalarOfVector> ScalarOfVectorPtr;
17 typedef boost::shared_ptr<VectorOfVector> VectorOfVectorPtr;
18 typedef boost::shared_ptr<MatrixOfVector> MatrixOfVectorPtr;
22 virtual double operator()(
const VectorXd& x)
const = 0;
23 double call(
const VectorXd& x)
const {
return operator()(x);}
26 typedef function<double(VectorXd)> boost_func;
27 static ScalarOfVectorPtr construct(
const boost_func&);
34 virtual VectorXd operator()(
const VectorXd& x)
const = 0;
35 VectorXd call(
const VectorXd& x)
const {
return operator()(x);}
38 typedef function<VectorXd(VectorXd)> boost_func;
39 static VectorOfVectorPtr construct(
const boost_func&);
46 virtual MatrixXd operator()(
const VectorXd& x)
const = 0;
47 MatrixXd call(
const VectorXd& x)
const {
return operator()(x);}
50 typedef function<MatrixXd(VectorXd)> boost_func;
51 static MatrixOfVectorPtr construct(
const boost_func&);
57 VectorXd calcForwardNumGrad(
const ScalarOfVector& f,
const VectorXd& x,
double epsilon);
58 MatrixXd calcForwardNumJac(
const VectorOfVector& f,
const VectorXd& x,
double epsilon);
59 void calcGradAndDiagHess(
const ScalarOfVector& f,
const VectorXd& x,
double epsilon,
60 double& y, VectorXd& grad, VectorXd& hess);
61 void calcGradHess(ScalarOfVectorPtr f,
const VectorXd& x,
double epsilon,
62 double& y, VectorXd& grad, MatrixXd& hess);
63 VectorOfVectorPtr forwardNumGrad(ScalarOfVectorPtr f,
double epsilon);
64 MatrixOfVectorPtr forwardNumJac(VectorOfVectorPtr f,
double epsilon);