25 #include <pybind11/pybind11.h>
26 #include <pybind11/stl.h>
32 using namespace pybind11::literals;
40 template <
typename ReturnT>
42 auto const name =
"Function" + suffix;
46 cls.def(py::init<unsigned int>(),
"nParams"_a);
49 table::io::python::addPersistableMethods<Function<ReturnT>>(
cls);
51 cls.def(
"getNParameters", &Function<ReturnT>::getNParameters);
52 cls.def(
"getParameters", &Function<ReturnT>::getParameters, py::return_value_policy::copy);
53 cls.def(
"getParameter", &Function<ReturnT>::getParameter,
"index"_a);
54 cls.def(
"isLinearCombination", &Function<ReturnT>::isLinearCombination);
55 cls.def(
"setParameter", &Function<ReturnT>::setParameter,
"index"_a,
"value"_a);
56 cls.def(
"setParameters", &Function<ReturnT>::setParameters);
57 cls.def(
"toString", &Function<ReturnT>::toString,
"prefix"_a =
"");
60 template <
typename ReturnT>
62 auto const name =
"Function1" + suffix;
67 table::io::python::addPersistableMethods<Function1<ReturnT>>(
cls);
70 cls.def(
"__call__", &Function1<ReturnT>::operator(),
"x"_a);
71 cls.def(
"toString", &Function1<ReturnT>::toString,
"prefix"_a =
"");
72 cls.def(
"computeCache", &Function1<ReturnT>::computeCache,
"n"_a);
75 template <
typename ReturnT>
77 auto const name =
"Function2" + suffix;
82 table::io::python::addPersistableMethods<Function2<ReturnT>>(
cls);
85 cls.def(
"__call__", &Function2<ReturnT>::operator(),
"x"_a,
"y"_a);
86 cls.def(
"toString", &Function2<ReturnT>::toString,
"prefix"_a =
"");
87 cls.def(
"getDFuncDParameters", &Function2<ReturnT>::getDFuncDParameters,
"x"_a,
"y"_a);
90 template <
typename ReturnT>
92 auto const name =
"BasePolynomialFunction2" + suffix;
98 cls.def(
"getOrder", &BasePolynomialFunction2<ReturnT>::getOrder);
99 cls.def(
"isLinearCombination", &BasePolynomialFunction2<ReturnT>::isLinearCombination);
100 cls.def_static(
"nParametersFromOrder", &BasePolynomialFunction2<ReturnT>::nParametersFromOrder,
102 cls.def_static(
"orderFromNParameters", &BasePolynomialFunction2<ReturnT>::orderFromNParameters,
104 cls.def(
"getDFuncDParameters", &BasePolynomialFunction2<ReturnT>::getDFuncDParameters,
"x"_a,
"y"_a);
107 template <
typename ReturnT>
109 auto const name =
"NullFunction1" + suffix;
114 cls.def(py::init<>());
119 template <
typename ReturnT>
121 auto const name =
"NullFunction2" + suffix;
126 cls.def(py::init<>());
131 template <
typename ReturnT>
133 declareFunction<ReturnT>(mod, suffix);
134 declareFunction1<ReturnT>(mod, suffix);
135 declareFunction2<ReturnT>(mod, suffix);
136 declareBasePolynomialFunction2<ReturnT>(mod, suffix);
137 declareNullFunction1<ReturnT>(mod, suffix);
138 declareNullFunction2<ReturnT>(mod, suffix);
144 declareAllFunctions<float>(mod,
"F");
145 declareAllFunctions<double>(mod,
"D");