std_array.cpp
Go to the documentation of this file.
1 
4 #include "eigenpy/std-array.hpp"
5 
6 using Eigen::VectorXd;
7 
8 std::array<int, 3> get_arr_3_ints() { return {1, 2, 3}; }
9 
10 std::array<VectorXd, 3> get_arr_3_vecs() {
11  std::array<VectorXd, 3> out;
12  out[0].setOnes(4);
13  out[1].setZero(2);
14  out[2].setRandom(10);
15  return out;
16 }
17 
18 struct test_struct {
19  std::array<int, 3> integs;
20  std::array<VectorXd, 2> vecs;
22  integs = {42, 3, -1};
23  vecs[0].setRandom(4); // 4 randoms between [-1,1]
24  vecs[1].setZero(11); // 11 zeroes
25  }
26 };
27 
28 BOOST_PYTHON_MODULE(std_array) {
29  using namespace eigenpy;
30 
31  enableEigenPy();
32 
35 
36  exposeStdArrayEigenSpecificType<VectorXd, 2>("VectorXd");
37  exposeStdArrayEigenSpecificType<VectorXd, 3>("VectorXd");
38  exposeStdVectorEigenSpecificType<VectorXd>("VectorXd");
39 
40  bp::def("get_arr_3_ints", get_arr_3_ints);
41  bp::def("get_arr_3_vecs", get_arr_3_vecs);
42 
43  bp::class_<test_struct>("test_struct", bp::init<>(bp::args("self")))
44  .def_readwrite("integs", &test_struct::integs)
45  .def_readwrite("vecs", &test_struct::vecs);
46 }
test_struct::vecs
std::array< VectorXd, 2 > vecs
Definition: std_array.cpp:20
eigenpy::StdArrayPythonVisitor
Expose an std::array (a C++11 fixed-size array) from a given type.
Definition: std-array.hpp:112
eigenpy::StdVectorPythonVisitor
Expose an std::vector from a type given as template argument.
Definition: std-vector.hpp:424
eigenpy::enableEigenPy
void EIGENPY_DLLAPI enableEigenPy()
Definition: eigenpy.cpp:43
get_arr_3_vecs
std::array< VectorXd, 3 > get_arr_3_vecs()
Definition: std_array.cpp:10
std-array.hpp
test_struct::integs
std::array< int, 3 > integs
Definition: std_array.cpp:19
test_struct
Definition: std_array.cpp:18
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(std_array)
Definition: std_array.cpp:28
get_arr_3_ints
std::array< int, 3 > get_arr_3_ints()
Definition: std_array.cpp:8
eigenpy
Definition: alignment.hpp:14
eigenpy::expose
void expose()
Call the expose function of a given type T.
Definition: expose.hpp:23
test_struct::test_struct
test_struct()
Definition: std_array.cpp:21


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Sat Nov 2 2024 02:14:45