From 8b03257bdbfa224ecbc35318f2252100d2922e3c Mon Sep 17 00:00:00 2001 From: Justin Carpentier <justin.carpentier@inria.fr> Date: Mon, 24 Aug 2020 19:38:57 +0200 Subject: [PATCH] test: add test of PlainObjectBase feature --- unittest/matrix.cpp | 9 +++++++++ unittest/python/test_matrix.py | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/unittest/matrix.cpp b/unittest/matrix.cpp index ce8a1c19..fd4ebae0 100644 --- a/unittest/matrix.cpp +++ b/unittest/matrix.cpp @@ -81,6 +81,12 @@ MatrixDerived base(const Eigen::MatrixBase<MatrixDerived> & m) return m.derived(); } +template<typename MatrixDerived> +MatrixDerived plain(const Eigen::PlainObjectBase<MatrixDerived> & m) +{ + return m.derived(); +} + template<typename Scalar> Eigen::Matrix<Scalar,6,6> matrix6(const Scalar & value) { @@ -123,6 +129,9 @@ BOOST_PYTHON_MODULE(matrix) bp::def("base", base<VectorXd>); bp::def("base", base<MatrixXd>); + + bp::def("plain", plain<VectorXd>); + bp::def("plain", plain<MatrixXd>); bp::def("matrix6", matrix6<double>); } diff --git a/unittest/python/test_matrix.py b/unittest/python/test_matrix.py index 5734eb92..1b1ea6e7 100644 --- a/unittest/python/test_matrix.py +++ b/unittest/python/test_matrix.py @@ -36,6 +36,10 @@ Mref = np.reshape(np.array(range(64),np.double),[8,8]) Mref_from_base = eigenpy.base(Mref) assert( np.array_equal(Mref,Mref_from_base) ); +# Test plain function +Mref_from_plain = eigenpy.plain(Mref) +assert( np.array_equal(Mref,Mref_from_plain) ); + if verbose: print("===> Matrix 8x8") M = Mref assert( np.array_equal(M,eigenpy.reflex(M,verbose)) ); -- GitLab