|
| 1 | +/* |
| 2 | + * Copyright 2014-2019, CNRS |
| 3 | + * Copyright 2018-2020, INRIA |
| 4 | + */ |
| 5 | + |
| 6 | +#include "eigenpy/eigenpy.hpp" |
| 7 | +#include <iostream> |
| 8 | + |
| 9 | +using namespace Eigen; |
| 10 | +using namespace eigenpy; |
| 11 | + |
| 12 | +template<typename MatType> |
| 13 | +void printMatrix(const Eigen::Ref<MatType> & mat) |
| 14 | +{ |
| 15 | + if(MatType::IsVectorAtCompileTime) |
| 16 | + std::cout << "isVector" << std::endl; |
| 17 | + std::cout << "size: cols " << mat.cols() << " rows " << mat.rows() << std::endl; |
| 18 | + std::cout << mat << std::endl; |
| 19 | +} |
| 20 | + |
| 21 | +template<typename VecType> |
| 22 | +void printVector(const Eigen::Ref<VecType> & vec) |
| 23 | +{ |
| 24 | + EIGEN_STATIC_ASSERT_VECTOR_ONLY(VecType); |
| 25 | + printMatrix(vec); |
| 26 | +} |
| 27 | + |
| 28 | +template<typename MatType> |
| 29 | +void setOnes(Eigen::Ref<MatType> mat) |
| 30 | +{ |
| 31 | + printMatrix(mat); |
| 32 | + mat.setOnes(); |
| 33 | + printMatrix(mat); |
| 34 | +} |
| 35 | + |
| 36 | +BOOST_PYTHON_MODULE(eigen_ref) |
| 37 | +{ |
| 38 | + namespace bp = boost::python; |
| 39 | + eigenpy::enableEigenPy(); |
| 40 | + |
| 41 | + bp::def("printMatrix", printMatrix<Vector3d>); |
| 42 | + bp::def("printMatrix", printMatrix<VectorXd>); |
| 43 | + bp::def("printMatrix", printMatrix<MatrixXd>); |
| 44 | + |
| 45 | + bp::def("printVector", printVector<VectorXd>); |
| 46 | + bp::def("printRowVector", printVector<RowVectorXd>); |
| 47 | + |
| 48 | + bp::def("setOnes", setOnes<Vector3d>); |
| 49 | + bp::def("setOnes", setOnes<VectorXd>); |
| 50 | + bp::def("setOnes", setOnes<MatrixXd>); |
| 51 | +} |
0 commit comments