independent.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 INRIA
3  */
4 
5 #ifndef __pycppad_independent_hpp__
6 #define __pycppad_independent_hpp__
7 
8 #include "pycppad/fwd.hpp"
9 
10 #include <eigenpy/eigenpy.hpp>
11 #include <cppad/core/independent/independent.hpp>
12 
13 namespace pycppad
14 {
15  namespace bp = boost::python;
16 
17  template<typename ADVector>
19  : public bp::def_visitor< IndependentVisitor<ADVector> >
20  {
21  typedef Eigen::Ref<ADVector> RefADVector;
22 
23  public:
24 
25  static void Independent(RefADVector x,
26  const size_t abort_op_index_,
27  const bool record_compare_)
28  {
29  ADVector x_(x), dynamic(0);
30  ::CppAD::Independent(x_, abort_op_index_, record_compare_, dynamic);
31  x = x_;
32  }
33 
34  static void expose(const std::string & func_name = "Independent")
35  {
36  bp::def(func_name.c_str(),&Independent,
37  (bp::arg("x"), bp::arg("abort_op_index") = 0, bp::arg("record_compare") = true),
38  "Define a variable as Independent."
39  "Parameters:\n"
40  "\tx: variable\n"
41  "\tabort_op_index: operator index at which execution will be aborted (during the recording of operations). The value zero corresponds to not aborting (will not match).\n"
42  "\trecord_compare: should comparison operators be recorded.\n"
43  );
44  }
45  };
46 }
47 #endif //#ifndef __pycppad_ad_hpp__
Definition: independent.hpp:20
static void Independent(RefADVector x, const size_t abort_op_index_, const bool record_compare_)
Definition: independent.hpp:25
static void expose(const std::string &func_name="Independent")
Definition: independent.hpp:34
Definition: ad.hpp:15