Skip to content

Commit 4b84fb7

Browse files
committed
test/matrix: add test for matrix1x1
1 parent ed34f01 commit 4b84fb7

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

unittest/matrix.cpp

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
/*
22
* Copyright 2014-2019, CNRS
3-
* Copyright 2018-2019, INRIA
3+
* Copyright 2018-2020, INRIA
44
*/
55

66
#include "eigenpy/eigenpy.hpp"
77
#include <iostream>
88

9+
template<typename Scalar>
10+
Eigen::Matrix<Scalar,Eigen::Dynamic,1> vector1x1(const Scalar & value)
11+
{
12+
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,1> ReturnType;
13+
return ReturnType::Constant(1,value);
14+
}
15+
16+
template<typename Scalar>
17+
Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> matrix1x1(const Scalar & value)
18+
{
19+
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,Eigen::Dynamic> ReturnType;
20+
return ReturnType::Constant(1,1,value);
21+
}
22+
923
Eigen::VectorXd emptyVector()
1024
{
1125
Eigen::VectorXd vec;
@@ -77,6 +91,9 @@ BOOST_PYTHON_MODULE(matrix)
7791
Eigen::VectorXd (*naturalsX)(int,bool) = naturals;
7892
Eigen::Matrix3d (*naturals33)(bool) = naturals;
7993

94+
bp::def("vector1x1", vector1x1<double>);
95+
bp::def("matrix1x1", matrix1x1<double>);
96+
8097
bp::def("naturals", naturalsXX);
8198
bp::def("naturalsX", naturalsX);
8299
bp::def("naturals33", naturals33);

unittest/python/test_matrix.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,12 @@
117117
# TODO
118118
# M = Mref[0:3,1:2]
119119
# assert( np.array_equal(M,eigenpy.reflex3(M,verbose)) );
120+
121+
value = 2.
122+
mat1x1 = eigenpy.matrix1x1(value)
123+
assert(mat1x1.size == 1)
124+
assert(mat1x1[0,0] == value)
125+
126+
vec1x1 = eigenpy.vector1x1(value)
127+
assert(vec1x1.size == 1)
128+
assert(vec1x1[0,0] == value)

0 commit comments

Comments
 (0)