Verified Commit 9872bfb9 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

test: add library for eigen_ref

parent 60c96874
......@@ -34,6 +34,7 @@ ADD_LIB_UNIT_TEST(geometry "eigen3")
ADD_LIB_UNIT_TEST(complex "eigen3")
ADD_LIB_UNIT_TEST(return_by_ref "eigen3")
IF(NOT ${EIGEN3_VERSION} VERSION_LESS "3.2.0")
ADD_LIB_UNIT_TEST(eigen_ref "eigen3")
ADD_LIB_UNIT_TEST(eigenpy_ref "eigen3")
ENDIF()
......
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2020, INRIA
*/
#include "eigenpy/eigenpy.hpp"
#include <iostream>
using namespace Eigen;
using namespace eigenpy;
template<typename MatType>
void printMatrix(const Eigen::Ref<MatType> & mat)
{
if(MatType::IsVectorAtCompileTime)
std::cout << "isVector" << std::endl;
std::cout << "size: cols " << mat.cols() << " rows " << mat.rows() << std::endl;
std::cout << mat << std::endl;
}
template<typename VecType>
void printVector(const Eigen::Ref<VecType> & vec)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(VecType);
printMatrix(vec);
}
template<typename MatType>
void setOnes(Eigen::Ref<MatType> mat)
{
printMatrix(mat);
mat.setOnes();
printMatrix(mat);
}
BOOST_PYTHON_MODULE(eigen_ref)
{
namespace bp = boost::python;
eigenpy::enableEigenPy();
bp::def("printMatrix", printMatrix<Vector3d>);
bp::def("printMatrix", printMatrix<VectorXd>);
bp::def("printMatrix", printMatrix<MatrixXd>);
bp::def("printVector", printVector<VectorXd>);
bp::def("printRowVector", printVector<RowVectorXd>);
bp::def("setOnes", setOnes<Vector3d>);
bp::def("setOnes", setOnes<VectorXd>);
bp::def("setOnes", setOnes<MatrixXd>);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment