Merge branch 'main' of github.com:Rconybea/xo-pyexpression
This commit is contained in:
commit
db02e7c08c
1 changed files with 36 additions and 10 deletions
|
|
@ -55,6 +55,7 @@ namespace xo {
|
||||||
py::class_<Expression,
|
py::class_<Expression,
|
||||||
rp<Expression>>(m, "Expression")
|
rp<Expression>>(m, "Expression")
|
||||||
.def_property_readonly("extype", &Expression::extype)
|
.def_property_readonly("extype", &Expression::extype)
|
||||||
|
.def_property_readonly("valuetype", &Expression::valuetype)
|
||||||
.def("get_free_variables", &Expression::get_free_variables)
|
.def("get_free_variables", &Expression::get_free_variables)
|
||||||
.def("__repr__", &Expression::display_string);
|
.def("__repr__", &Expression::display_string);
|
||||||
;
|
;
|
||||||
|
|
@ -103,26 +104,49 @@ namespace xo {
|
||||||
py::doc("number of arguments to this function (not counting return value)"))
|
py::doc("number of arguments to this function (not counting return value)"))
|
||||||
;
|
;
|
||||||
|
|
||||||
using Fn_dbl_dbl_type = double (*)(double);
|
using int32_t = std::int32_t;
|
||||||
|
|
||||||
m.def("make_sqrt_pm", []() { return make_primitive<Fn_dbl_dbl_type>("sqrt", sqrt, false /*!explicit*/, llvmintrinsic::invalid); },
|
py::class_<Primitive<int32_t (*)(int32_t, int32_t)>,
|
||||||
py::doc("create primitive representing the ::sqrt() function"));
|
PrimitiveInterface,
|
||||||
m.def("make_sin_pm", []() { return make_primitive<Fn_dbl_dbl_type>("sin", ::sin, false /*!explicit*/, llvmintrinsic::invalid); },
|
rp<Primitive<int32_t (*)(int32_t, int32_t)>>>(m, "Primitive_i32_i32")
|
||||||
py::doc("create primitive representing the ::sin() function"));
|
;
|
||||||
m.def("make_cos_pm", []() { return make_primitive<Fn_dbl_dbl_type>("cos", ::cos, false /*!explicit*/, llvmintrinsic::invalid); },
|
|
||||||
py::doc("create primitive representing the ::cos() function"));
|
|
||||||
m.def("make_pow_pm", []() { return make_primitive<double (*)(double, double)>("pow", ::pow, false /*!explicit*/, llvmintrinsic::invalid); },
|
|
||||||
py::doc("create primitive representing the ::pow() function"));
|
|
||||||
|
|
||||||
py::class_<Primitive<double (*)(double)>,
|
py::class_<Primitive<double (*)(double)>,
|
||||||
PrimitiveInterface,
|
PrimitiveInterface,
|
||||||
rp<Primitive<double (*)(double)>>>(m, "Primitive_double_double")
|
rp<Primitive<double (*)(double)>>>(m, "Primitive_double_double")
|
||||||
;
|
;
|
||||||
|
using Fn_dbl_dbl_type = double (*)(double);
|
||||||
|
|
||||||
|
m.def("make_sqrt_pm", []() { return make_primitive<double (*)(double)>("sqrt",
|
||||||
|
::sqrt,
|
||||||
|
false /*!explicit_symbol_def*/,
|
||||||
|
llvmintrinsic::fp_sqrt); },
|
||||||
|
py::doc("create primitive representing the ::sqrt() function"));
|
||||||
|
m.def("make_sin_pm",
|
||||||
|
[]() { return make_primitive<Fn_dbl_dbl_type>("sin",
|
||||||
|
::sin,
|
||||||
|
false /*!explicit_symbol_def*/,
|
||||||
|
llvmintrinsic::fp_sin); },
|
||||||
|
py::doc("create primitive representing the ::sin() function"));
|
||||||
|
m.def("make_cos_pm",
|
||||||
|
[]() { return make_primitive<Fn_dbl_dbl_type>("cos",
|
||||||
|
::cos,
|
||||||
|
false /*!explicit_symbol_def*/,
|
||||||
|
llvmintrinsic::fp_cos); },
|
||||||
|
py::doc("create primitive representing the ::cos() function"));
|
||||||
|
|
||||||
py::class_<Primitive<double (*)(double, double)>,
|
py::class_<Primitive<double (*)(double, double)>,
|
||||||
PrimitiveInterface,
|
PrimitiveInterface,
|
||||||
rp<Primitive<double (*)(double, double)>>>(m, "Primitive_double_double_double")
|
rp<Primitive<double (*)(double, double)>>>(m, "Primitive_double_double_double")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
m.def("make_pow_pm",
|
||||||
|
[]() { return make_primitive<double (*)(double, double)>("pow",
|
||||||
|
::pow,
|
||||||
|
false /*!explicit_symbol_def*/,
|
||||||
|
llvmintrinsic::fp_pow); },
|
||||||
|
py::doc("create primitive representing the ::pow() function"));
|
||||||
|
|
||||||
// ----- Apply -----
|
// ----- Apply -----
|
||||||
|
|
||||||
py::class_<Apply, Expression, rp<Apply>>(m, "Apply")
|
py::class_<Apply, Expression, rp<Apply>>(m, "Apply")
|
||||||
|
|
@ -138,7 +162,9 @@ namespace xo {
|
||||||
.def_property_readonly("name", &Variable::name, py::doc("variable name"))
|
.def_property_readonly("name", &Variable::name, py::doc("variable name"))
|
||||||
;
|
;
|
||||||
|
|
||||||
m.def("make_var", &make_var);
|
m.def("make_var", &make_var,
|
||||||
|
py::arg("name"),
|
||||||
|
py::arg("var_type"));
|
||||||
|
|
||||||
// ----- Lambdas -----
|
// ----- Lambdas -----
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue