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 
utilities.h
Contains generic global functions designed particularly for the matlab interface.
b
Scalar * b
Definition: benchVecAdd.cpp:17
gtsam::Matrix
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:39
gtsam::Vector
Eigen::VectorXd Vector
Definition: Vector.h:38
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
Eigen::numext::q
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:1984
module
module_ module
Definition: pybind11.h:1282
arg
Definition: cast.h:1277
arg
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
matrix
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
Definition: gtsam/3rdparty/Eigen/blas/common.h:110
pybind11.h
module_::def_submodule
module_ def_submodule(const char *name, const char *doc=nullptr)
Definition: pybind11.h:1192
a
ArrayXXi a
Definition: Array_initializer_list_23_cxx11.cpp:1
gtsam::Values
Definition: Values.h:65
std
Definition: BFloat16.h:88
pybind11
Definition: wrap/pybind11/pybind11/__init__.py:1
eigen.h
module_::def
module_ & def(const char *name_, Func &&f, const Extra &...extra)
Definition: pybind11.h:1169
operators.h
stl_bind.h
Values.h
A non-templated config holding any types of Manifold-group elements.
PYBIND11_MODULE
PYBIND11_MODULE(namespaces_py, m_)
Definition: namespaces_pybind.cpp:21


gtsam
Author(s):
autogenerated on Mon Jul 1 2024 03:02:16