| 14 | |
| 15 | template <typename FUNC> |
| 16 | void ExportStdMathFunction(py::module &m, string name, string description) |
| 17 | { |
| 18 | static RegisterClassForArchive<cl_UnaryOpCF<FUNC>, CoefficientFunction> reguopcf; |
| 19 | |
| 20 | m.def (name.c_str(), [name] (py::object x) -> py::object |
| 21 | { |
| 22 | FUNC func; |
| 23 | py::extract<double> ed(x); |
| 24 | if (ed.check()) return py::cast(func(ed())); |
| 25 | if (py::extract<Complex> (x).check()) |
| 26 | return py::cast(func(py::extract<Complex> (x)())); |
| 27 | if (py::extract<shared_ptr<CoefficientFunction>>(x).check()) |
| 28 | { |
| 29 | auto coef = py::extract<shared_ptr<CoefficientFunction>>(x)(); |
| 30 | return py::cast(UnaryOpCF(coef, func, FUNC::Name())); |
| 31 | } |
| 32 | throw py::type_error (string("can't compute math-function, type = ") |
| 33 | + typeid(FUNC).name()); |
| 34 | }, py::arg("x"), description.c_str()); |
| 35 | } |
| 36 | |
| 37 | template <typename FUNC> |
| 38 | void ExportStdMathFunction_(py::module &m, string name, |