Verified Commit 4b84fb76 authored by Justin Carpentier's avatar Justin Carpentier
Browse files

test/matrix: add test for matrix1x1

parent ed34f015
/*
* Copyright 2014-2019, CNRS
* Copyright 2018-2019, INRIA
* Copyright 2018-2020, INRIA
*/
#include "eigenpy/eigenpy.hpp"
#include <iostream>
template<typename Scalar>
Eigen::Matrix<Scalar,Eigen::Dynamic,1> vector1x1(const Scalar & value)
{
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1> ReturnType;
return ReturnType::Constant(1,value);
}
template<typename Scalar>
Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> matrix1x1(const Scalar & value)
{
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> ReturnType;
return ReturnType::Constant(1,1,value);
}
Eigen::VectorXd emptyVector()
{
Eigen::VectorXd vec;
......@@ -77,6 +91,9 @@ BOOST_PYTHON_MODULE(matrix)
Eigen::VectorXd (*naturalsX)(int,bool) = naturals;
Eigen::Matrix3d (*naturals33)(bool) = naturals;
bp::def("vector1x1", vector1x1<double>);
bp::def("matrix1x1", matrix1x1<double>);
bp::def("naturals", naturalsXX);
bp::def("naturalsX", naturalsX);
bp::def("naturals33", naturals33);
......
......@@ -117,3 +117,12 @@ if verbose: print("===> From Py to Eigen::Vector3d")
# TODO
# M = Mref[0:3,1:2]
# assert( np.array_equal(M,eigenpy.reflex3(M,verbose)) );
value = 2.
mat1x1 = eigenpy.matrix1x1(value)
assert(mat1x1.size == 1)
assert(mat1x1[0,0] == value)
vec1x1 = eigenpy.vector1x1(value)
assert(vec1x1.size == 1)
assert(vec1x1[0,0] == value)
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