Skip to content
Snippets Groups Projects
Commit b77b9aa1 authored by jcarpent's avatar jcarpent
Browse files

[Test] Add unit test for Ref

parent 02e96c2d
No related branches found
No related tags found
No related merge requests found
# #
# Copyright (c) 2016 CNRS # Copyright (c) 2016-2018 CNRS
# #
# This file is part of eigenpy # This file is part of eigenpy
# eigenpy is free software: you can redistribute it # eigenpy is free software: you can redistribute it
...@@ -40,4 +40,5 @@ ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND}) ...@@ -40,4 +40,5 @@ ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
ADD_LIB_UNIT_TEST(matrix "eigen3") ADD_LIB_UNIT_TEST(matrix "eigen3")
ADD_LIB_UNIT_TEST(geometry "eigen3") ADD_LIB_UNIT_TEST(geometry "eigen3")
ADD_LIB_UNIT_TEST(ref "eigen3")
/*
* Copyright 2018, Justin Carpentier <jcarpent@laas.fr>, LAAS-CNRS
*
* This file is part of eigenpy.
* eigenpy is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
* eigenpy is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. You should
* have received a copy of the GNU Lesser General Public License along
* with eigenpy. If not, see <http://www.gnu.org/licenses/>.
*/
#include "eigenpy/eigenpy.hpp"
#include <iostream>
using namespace Eigen;
using namespace eigenpy;
template<typename MatType>
void printMatrix(const eigenpy::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 MatType>
void printVector(const eigenpy::Ref<MatType> & mat)
{
EIGEN_STATIC_ASSERT_VECTOR_ONLY(MatType);
printMatrix(mat);
}
template<typename MatType>
void setOnes(eigenpy::Ref<MatType> mat)
{
mat.setOnes();
}
BOOST_PYTHON_MODULE(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("setOnes", setOnes<Vector3d>);
bp::def("setOnes", setOnes<VectorXd>);
bp::def("setOnes", setOnes<MatrixXd>);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment