namespaces_pybind.cpp
Go to the documentation of this file.
1 #include <pybind11/eigen.h>
2 #include <pybind11/stl_bind.h>
3 #include <pybind11/pybind11.h>
4 #include <pybind11/operators.h>
5 #include "gtsam/nonlinear/utilities.h" // for RedirectCout.
6 
7 #include "path/to/ns1.h"
8 #include "path/to/ns1/ClassB.h"
9 #include "path/to/ns2.h"
10 #include "path/to/ns2/ClassA.h"
11 #include "path/to/ns3.h"
12 #include "gtsam/nonlinear/Values.h"
13 
14 
15 
16 
17 using namespace std;
18 
19 namespace py = pybind11;
20 
21 PYBIND11_MODULE(namespaces_py, m_) {
22  m_.doc() = "pybind11 wrapper of namespaces_py";
23 
24  pybind11::module m_ns1 = m_.def_submodule("ns1", "ns1 submodule");
25 
26  py::class_<ns1::ClassA, std::shared_ptr<ns1::ClassA>>(m_ns1, "ClassA")
27  .def(py::init<>());
28 
29  py::class_<ns1::ClassB, std::shared_ptr<ns1::ClassB>>(m_ns1, "ClassB")
30  .def(py::init<>());
31 
32  m_ns1.def("aGlobalFunction",[](){return ns1::aGlobalFunction();}); pybind11::module m_ns2 = m_.def_submodule("ns2", "ns2 submodule");
33 
34  py::class_<ns2::ClassA, std::shared_ptr<ns2::ClassA>>(m_ns2, "ClassA")
35  .def(py::init<>())
36  .def("memberFunction",[](ns2::ClassA* self){return self->memberFunction();})
37  .def("nsArg",[](ns2::ClassA* self, const ns1::ClassB& arg){return self->nsArg(arg);}, py::arg("arg"))
38  .def("nsReturn",[](ns2::ClassA* self, double q){return self->nsReturn(q);}, py::arg("q"))
39  .def_static("afunction",[](){return ns2::ClassA::afunction();});
40  pybind11::module m_ns2_ns3 = m_ns2.def_submodule("ns3", "ns3 submodule");
41 
42  py::class_<ns2::ns3::ClassB, std::shared_ptr<ns2::ns3::ClassB>>(m_ns2_ns3, "ClassB")
43  .def(py::init<>());
44 
45  py::class_<ns2::ClassC, std::shared_ptr<ns2::ClassC>>(m_ns2, "ClassC")
46  .def(py::init<>());
47 
48  m_ns2.attr("aNs2Var") = ns2::aNs2Var;
49  m_ns2.def("aGlobalFunction",[](){return ns2::aGlobalFunction();});
50  m_ns2.def("overloadedGlobalFunction",[](const ns1::ClassA& a){return ns2::overloadedGlobalFunction(a);}, py::arg("a"));
51  m_ns2.def("overloadedGlobalFunction",[](const ns1::ClassA& a, double b){return ns2::overloadedGlobalFunction(a, b);}, py::arg("a"), py::arg("b"));
52  py::class_<ClassD, std::shared_ptr<ClassD>>(m_, "ClassD")
53  .def(py::init<>());
54 
55  m_.attr("aGlobalVar") = aGlobalVar; pybind11::module m_gtsam = m_.def_submodule("gtsam", "gtsam submodule");
56 
57  py::class_<gtsam::Values, std::shared_ptr<gtsam::Values>>(m_gtsam, "Values")
58  .def(py::init<>())
59  .def(py::init<const gtsam::Values&>(), py::arg("other"))
60  .def("insert_vector",[](gtsam::Values* self, size_t j, const gtsam::Vector& vector){ self->insert(j, vector);}, py::arg("j"), py::arg("vector"))
61  .def("insert",[](gtsam::Values* self, size_t j, const gtsam::Vector& vector){ self->insert(j, vector);}, py::arg("j"), py::arg("vector"))
62  .def("insert_matrix",[](gtsam::Values* self, size_t j, const gtsam::Matrix& matrix){ self->insert(j, matrix);}, py::arg("j"), py::arg("matrix"))
63  .def("insert",[](gtsam::Values* self, size_t j, const gtsam::Matrix& matrix){ self->insert(j, matrix);}, py::arg("j"), py::arg("matrix"));
64 
65 
66 #include "python/specializations.h"
67 
68 }
69 
module_ module
Definition: pybind11.h:1265
Scalar * b
Definition: benchVecAdd.cpp:17
A non-templated config holding any types of Manifold-group elements.
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:1175
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
Definition: BFloat16.h:88
Definition: cast.h:1238
module_ & def(const char *name_, Func &&f, const Extra &...extra)
Definition: pybind11.h:1152
Eigen::VectorXd Vector
Definition: Vector.h:38
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
EIGEN_DEVICE_FUNC const Scalar & q
PYBIND11_MODULE(namespaces_py, m_)
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
std::ptrdiff_t j


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:56