std_vector.cpp
Go to the documentation of this file.
1 #include <ostream>
5 
6 #include "eigenpy/eigenpy.hpp"
8 #include "eigenpy/std-vector.hpp"
9 
10 template <typename MatType>
12  const std::vector<MatType, Eigen::aligned_allocator<MatType> > &Ms) {
13  const std::size_t n = Ms.size();
14  for (std::size_t i = 0; i < n; i++) {
15  std::cout << "el[" << i << "] =\n" << Ms[i] << '\n';
16  }
17 }
18 
19 template <typename MatType>
20 std::vector<MatType, Eigen::aligned_allocator<MatType> > copy(
21  const std::vector<MatType, Eigen::aligned_allocator<MatType> > &Ms) {
22  std::vector<MatType, Eigen::aligned_allocator<MatType> > out = Ms;
23  return out;
24 }
25 
26 template <typename MatType>
27 void setZero(std::vector<MatType, Eigen::aligned_allocator<MatType> > &Ms) {
28  for (std::size_t i = 0; i < Ms.size(); i++) {
29  Ms[i].setZero();
30  }
31 }
32 
33 BOOST_PYTHON_MODULE(std_vector) {
34  namespace bp = boost::python;
35  using namespace eigenpy;
36 
37  enableEigenPy();
38 
39  bp::def("printVectorOfMatrix", printVectorOfMatrix<Eigen::VectorXd>);
40  bp::def("printVectorOfMatrix", printVectorOfMatrix<Eigen::MatrixXd>);
41 
42  bp::def("copyStdVector", copy<Eigen::MatrixXd>);
43  bp::def("copyStdVector", copy<Eigen::VectorXd>);
44 
45  exposeStdVectorEigenSpecificType<Eigen::Matrix3d>("Mat3d");
46  bp::def("printVectorOf3x3", printVectorOfMatrix<Eigen::Matrix3d>);
47  bp::def("copyStdVec_3x3", copy<Eigen::Matrix3d>, bp::args("mats"));
48 
49  typedef Eigen::Ref<Eigen::MatrixXd> RefXd;
51  bp::def("setZero", setZero<Eigen::MatrixXd>, "Sets the coeffs to 0.");
52 }
void EIGENPY_DLLAPI enableEigenPy()
Definition: eigenpy.cpp:29
void printVectorOfMatrix(const std::vector< MatType, Eigen::aligned_allocator< MatType > > &Ms)
Definition: std_vector.cpp:11
std::vector< MatType, Eigen::aligned_allocator< MatType > > copy(const std::vector< MatType, Eigen::aligned_allocator< MatType > > &Ms)
Definition: std_vector.cpp:20
void expose()
Call the expose function of a given type T.
Definition: expose.hpp:23
BOOST_PYTHON_MODULE(std_vector)
Definition: std_vector.cpp:33
void setZero(std::vector< MatType, Eigen::aligned_allocator< MatType > > &Ms)
Definition: std_vector.cpp:27
Expose an std::vector from a type given as template argument.
Definition: std-vector.hpp:376


eigenpy
Author(s): Justin Carpentier, Nicolas Mansard
autogenerated on Fri Jun 2 2023 02:10:26