5 #ifndef __pycppad_ad_fun_hpp__
6 #define __pycppad_ad_fun_hpp__
12 namespace bp = boost::python;
14 template<
typename Scalar>
16 :
public bp::def_visitor< ADFunVisitor<Scalar> >
19 typedef ::CppAD::ADFun<Scalar> ADFun;
20 typedef Eigen::Matrix<::CppAD::AD<Scalar>, Eigen::Dynamic, 1> ADVector;
21 typedef Eigen::Ref<ADVector> RefADVector;
22 typedef Eigen::Matrix<Scalar, Eigen::Dynamic, 1> Vector;
27 return f.Forward(q, xq);
30 template<
class PyClass>
36 bp::make_constructor(&constructor,bp::default_call_policies(),bp::args(
"x",
"y")))
38 .def(
"from_json", &ADFun::from_json, bp::args(
"self",
"json"))
41 .def(
"size_order", &ADFun::size_order, bp::arg(
"self"))
42 .def(
"Dependent",&Dependent,
43 bp::args(
"self",
"x",
"y"))
44 .def(
"Forward", (Vector (ADFun::*)(
size_t ,
size_t,
const Vector&))(&ADFun::Forward),
45 bp::args(
"self",
"q",
"r",
"x"))
47 bp::args(
"self",
"q",
"xq"))
48 .def(
"Reverse", (Vector (ADFun::*)(
size_t,
const Vector&))(&ADFun::Reverse),
49 bp::args(
"self",
"p",
"v"))
50 .def(
"Reverse", (Vector (ADFun::*)(
size_t,
const Vector&))(&ADFun::Reverse),
51 bp::args(
"self",
"p",
"v"))
52 .def(
"Hessian", (Vector (ADFun::*)(
const Vector&,
const Vector&))(&ADFun::Hessian),
53 bp::args(
"self",
"x",
"w"))
54 .def(
"Hessian", (Vector (ADFun::*)(
const Vector&,
size_t))(&ADFun::Hessian),
55 bp::args(
"self",
"x",
"i"))
56 .def(
"Jacobian", (Vector (ADFun::*)(
const Vector&))(&ADFun::Jacobian),
57 bp::args(
"self",
"x"))
58 .def(
"optimize", &ADFun::optimize, bp::args(
"self",
"options"))
64 static void Dependent(ADFun &
self, RefADVector x, RefADVector y)
67 self.Dependent(x_,y_);
71 static ADFun* constructor(RefADVector x, RefADVector y)
74 ADFun * f =
new ADFun(x_,y_);
83 static std::string class_name;
94 static void expose(
const std::string & class_name =
"ADFun")
97 bp::class_<ADFun, boost::noncopyable>(class_name.c_str(),
98 "Class used to hold function objects.\n\n",
Definition: ad_fun.hpp:17
static void expose(const std::string &class_name="ADFun")
Definition: ad_fun.hpp:94
void visit(PyClass &cl) const
Definition: ad_fun.hpp:31
static Vector Forward_multiple(ADFun &f, size_t q, const Vector &xq)
Definition: ad_fun.hpp:26
static void set_class_name(const std::string &class_name)
Definition: ad_fun.hpp:87
static std::string & get_class_name()
Definition: ad_fun.hpp:81