13#include <dune/fufem/dunepython.hh>
15#include <autodiff/forward/real/real.hpp>
27template <std::
size_t order,
class T>
28struct Conversion<autodiff::Real<order, T>>
32 useDefaultConstructorConversion =
true
40 static void toC(PyObject* list, autodiff::Real<order, T>& v) {
41 auto rlist = Reference(Imp::inc(list));
47 auto wF = Callable(rlist.get(
"__getitem__"));
48 for (std::size_t i = 0; i < order + 1; ++i)
49 v[i] = PyFloat_AsDouble(wF(i));
57 static PyObject*
toPy(
const autodiff::Real<order, T>& v) {
58 auto pyMain = Python::main();
59 Python::Module module = pyMain.import(
"autodiff");
61 auto real1stClass = module.get(
"real1st");
62 auto real1st = Callable(Imp::inc(real1stClass))();
63 auto wF = Callable(Imp::inc(real1st).get(
"__setitem__"));
64 for (std::size_t i = 0; i < order + 1; ++i)
Definition: pythonautodiffdefinitions.hh:17
static void toC(PyObject *list, autodiff::Real< order, T > &v)
Convert autodiff::Real to PyObject*.
Definition: pythonautodiffdefinitions.hh:40
static PyObject * toPy(const autodiff::Real< order, T > &v)
Convert PyObject* to autodiff::Real.
Definition: pythonautodiffdefinitions.hh:57