|
| 1 | +/* |
| 2 | + * Copyright 2018, Justin Carpentier <[email protected]>, LAAS-CNRS |
| 3 | + * |
| 4 | + * This file is part of eigenpy. |
| 5 | + * eigenpy is free software: you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU Lesser General Public License |
| 7 | + * as published by the Free Software Foundation, either version 3 of |
| 8 | + * the License, or (at your option) any later version. |
| 9 | + * eigenpy is distributed in the hope that it will be |
| 10 | + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty |
| 11 | + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | + * GNU Lesser General Public License for more details. You should |
| 13 | + * have received a copy of the GNU Lesser General Public License along |
| 14 | + * with eigenpy. If not, see <http://www.gnu.org/licenses/>. |
| 15 | + */ |
| 16 | + |
| 17 | +#include "eigenpy/eigenpy.hpp" |
| 18 | +#include <iostream> |
| 19 | + |
| 20 | +using namespace Eigen; |
| 21 | +using namespace eigenpy; |
| 22 | + |
| 23 | +template<typename MatType> |
| 24 | +void printMatrix(const eigenpy::Ref<MatType> & mat) |
| 25 | +{ |
| 26 | + if(MatType::IsVectorAtCompileTime) |
| 27 | + std::cout << "isVector" << std::endl; |
| 28 | + std::cout << "size: cols " << mat.cols() << " rows " << mat.rows() << std::endl; |
| 29 | + std::cout << mat << std::endl; |
| 30 | +} |
| 31 | + |
| 32 | +template<typename MatType> |
| 33 | +void printVector(const eigenpy::Ref<MatType> & mat) |
| 34 | +{ |
| 35 | + EIGEN_STATIC_ASSERT_VECTOR_ONLY(MatType); |
| 36 | + printMatrix(mat); |
| 37 | +} |
| 38 | + |
| 39 | +template<typename MatType> |
| 40 | +void setOnes(eigenpy::Ref<MatType> mat) |
| 41 | +{ |
| 42 | + mat.setOnes(); |
| 43 | +} |
| 44 | + |
| 45 | +BOOST_PYTHON_MODULE(ref) |
| 46 | +{ |
| 47 | + namespace bp = boost::python; |
| 48 | + eigenpy::enableEigenPy(); |
| 49 | + |
| 50 | + bp::def("printMatrix", printMatrix<Vector3d>); |
| 51 | + bp::def("printMatrix", printMatrix<VectorXd>); |
| 52 | + bp::def("printMatrix", printMatrix<MatrixXd>); |
| 53 | + |
| 54 | + bp::def("printVector", printVector<VectorXd>); |
| 55 | + |
| 56 | + bp::def("setOnes", setOnes<Vector3d>); |
| 57 | + bp::def("setOnes", setOnes<VectorXd>); |
| 58 | + bp::def("setOnes", setOnes<MatrixXd>); |
| 59 | +} |
0 commit comments