1#include "proxsuite-nlp/python/function.hpp" 
    8using context::C1Function;
 
    9using context::C2Function;
 
   10using context::ConstVectorRef;
 
   11using context::Function;
 
   12using context::Manifold;
 
   15void exposeFunctionOps();
 
   17void exposeFunctionTypes() {
 
   19  bp::class_<FunctionWrap, boost::noncopyable>(
 
   20      "BaseFunction", 
"Base class for functions.", bp::no_init)
 
   21      .def(bp::init<const Manifold &, const int>(
 
   22          bp::args(
"self", 
"manifold", 
"nr")))
 
   23      .def(bp::init<int, int, int>(bp::args(
"self", 
"nx", 
"ndx", 
"nr")))
 
   24      .def(
"__call__", bp::pure_virtual(&Function::operator()),
 
   25           bp::args(
"self", 
"x"), 
"Call the function.")
 
   27      .add_property(
"ndx", &
Function::ndx, 
"Input tangent space dimension.")
 
   28      .add_property(
"nr", &
Function::nr, 
"Function codimension.");
 
   33  bp::class_<C1FunctionWrap, bp::bases<Function>, boost::noncopyable>(
 
   34      "C1Function", 
"Base class for differentiable functions", bp::no_init)
 
   35      .def(bp::init<const Manifold &, const int>(
 
   36          bp::args(
"self", 
"manifold", 
"nr")))
 
   37      .def(bp::init<int, int, int>(bp::args(
"self", 
"nx", 
"ndx", 
"nr")))
 
   38      .def(
"computeJacobian", bp::pure_virtual(compJac1),
 
   39           bp::args(
"self", 
"x", 
"Jout"))
 
   40      .def(
"getJacobian", compJac2, bp::args(
"self", 
"x"),
 
   41           "Compute and return Jacobian.");
 
   43  bp::register_ptr_to_python<shared_ptr<C2Function>>();
 
   44  bp::class_<C2FunctionWrap, bp::bases<C1Function>, boost::noncopyable>(
 
   45      "C2Function", 
"Base class for twice-differentiable functions.",
 
   47      .def(bp::init<const Manifold &, const int>(
 
   48          bp::args(
"self", 
"manifold", 
"nr")))
 
   49      .def(bp::init<int, int, int>(bp::args(
"self", 
"nx", 
"ndx", 
"nr")))
 
   51           &C2FunctionWrap::default_vhp, bp::args(
"self", 
"x", 
"v", 
"Hout"))
 
   52      .def(
"getVHP", &C2FunctionWrap::getVHP, bp::args(
"self", 
"x", 
"v"),
 
   53           "Compute and return the vector-Hessian product.")
 
   56          +[](shared_ptr<C2Function> 
const &left,
 
   57              shared_ptr<C2Function> 
const &right) {
 
   58            return ::proxsuite::nlp::compose<Scalar>(left, right);
 
   60          "Composition operator. This composes the first argument over the " 
   66void exposeFunctionOps() {
 
   67  using ComposeFunction = ComposeFunctionTpl<Scalar>;
 
   69  const char *compose_doc = 
"Composition of two functions. This returns the " 
   70                            "composition of `f` over `g`.";
 
   71  bp::register_ptr_to_python<shared_ptr<ComposeFunction>>();
 
   72  bp::class_<ComposeFunction, bp::bases<C2Function>>(
"ComposeFunction",
 
   73                                                     compose_doc, bp::no_init)
 
   74      .def(bp::init<
const shared_ptr<C2Function> &,
 
   75                    const shared_ptr<C2Function> &>(bp::args(
"self", 
"f", 
"g")))
 
   77                    bp::make_function(&ComposeFunction::left,
 
   78                                      bp::return_internal_reference<>()),
 
   79                    "The left-hand side of the composition.")
 
   80      .add_property(
"right",
 
   81                    bp::make_function(&ComposeFunction::right,
 
   82                                      bp::return_internal_reference<>()),
 
   83                    "The right-hand side of the composition.");
 
   85  bp::def(
"compose", &::proxsuite::nlp::compose<context::Scalar>,
 
   86          bp::args(
"f", 
"g"), compose_doc);
 
virtual void computeJacobian(const ConstVectorRef &x, MatrixRef Jout) const=0
 
virtual void vectorHessianProduct(const ConstVectorRef &, const ConstVectorRef &, MatrixRef Hout) const