Skip to content

Commit 5a6f480

Browse files
committed
test: test registration of a new type
1 parent cec1bd8 commit 5a6f480

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

unittest/matrix.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,22 @@ MatrixDerived base(const Eigen::MatrixBase<MatrixDerived> & m)
8181
return m.derived();
8282
}
8383

84+
template<typename Scalar>
85+
Eigen::Matrix<Scalar,6,6> matrix6(const Scalar & value)
86+
{
87+
typedef Eigen::Matrix<Scalar,6,6> ReturnType;
88+
return ReturnType::Constant(value);
89+
}
90+
8491
BOOST_PYTHON_MODULE(matrix)
8592
{
8693
using namespace Eigen;
8794
namespace bp = boost::python;
8895
eigenpy::enableEigenPy();
8996

97+
typedef Eigen::Matrix<double,6,6> Matrix6;
98+
eigenpy::enableEigenPySpecific<Matrix6>();
99+
90100
Eigen::MatrixXd (*naturalsXX)(int,int,bool) = naturals;
91101
Eigen::VectorXd (*naturalsX)(int,bool) = naturals;
92102
Eigen::Matrix3d (*naturals33)(bool) = naturals;
@@ -108,4 +118,6 @@ BOOST_PYTHON_MODULE(matrix)
108118

109119
bp::def("base", base<VectorXd>);
110120
bp::def("base", base<MatrixXd>);
121+
122+
bp::def("matrix6", matrix6<double>);
111123
}

unittest/python/test_matrix.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,7 @@
126126
vec1x1 = eigenpy.vector1x1(value)
127127
assert(vec1x1.size == 1)
128128
assert(vec1x1[0] == value)
129+
130+
# test registration of matrix6
131+
mat6 = eigenpy.matrix6(0.)
132+
assert(mat6.size == 36)

0 commit comments

Comments
 (0)