Skip to content
Snippets Groups Projects
Verified Commit 4119d80e authored by Justin Carpentier's avatar Justin Carpentier
Browse files

python: fix issue when calling is_approx

There is a shift in memory that I cannot understand in release mode
parent fb2badc5
No related branches found
No related tags found
No related merge requests found
......@@ -10,11 +10,17 @@
namespace eigenpy
{
template<typename MatrixType1, typename MatrixType2>
inline bool is_approx(const Eigen::MatrixBase<MatrixType1> & mat1,
const Eigen::MatrixBase<MatrixType2> & mat2,
const typename MatrixType1::Scalar & prec = Eigen::NumTraits<typename MatrixType1::Scalar>::dummy_precision())
inline EIGEN_DONT_INLINE bool is_approx(const MatrixType1 & mat1,
const MatrixType2 & mat2,
const typename MatrixType1::Scalar & prec)
{
return mat1.isApprox(mat2,prec);
return mat1.derived().isApprox(mat2.derived(),prec);
}
template<typename MatrixType1, typename MatrixType2>
inline bool is_approx(const MatrixType1 & mat1, const MatrixType2 & mat2)
{
return is_approx(mat1,mat2,Eigen::NumTraits<typename MatrixType1::Scalar>::dummy_precision());
}
}
......
......@@ -17,24 +17,8 @@
#include <boost/python/scope.hpp>
#define DEFINE_IS_APPROX(MatType) \
BOOST_PYTHON_FUNCTION_OVERLOADS(is_approx_overload##MatType,eigenpy::is_approx,2,3)
#define EXPOSE_IS_APPROX(MatType) \
bp::def("is_approx", \
(bool (*)(const Eigen::MatrixBase<MatType> &, \
const Eigen::MatrixBase<MatType> &, \
const MatType::Scalar &))eigenpy::is_approx<MatType,MatType>, \
is_approx_overload##MatType(bp::args("A","B","prec"), \
"Returns True if A is approximately equal to B, within the precision determined by prec."))
using namespace eigenpy;
DEFINE_IS_APPROX(MatrixXd)
DEFINE_IS_APPROX(MatrixXf)
BOOST_PYTHON_MODULE(eigenpy)
{
namespace bp = boost::python;
......@@ -62,8 +46,15 @@ BOOST_PYTHON_MODULE(eigenpy)
{
using namespace Eigen;
EXPOSE_IS_APPROX(MatrixXd);
EXPOSE_IS_APPROX(MatrixXf);
bp::def("is_approx",(bool (*)(const MatrixXd &, const MatrixXd &, const double &))&is_approx<MatrixXd,MatrixXd>,
bp::args("A","B","prec"),
"Returns True if A is approximately equal to B, within the precision determined by prec.");
bp::def("is_approx",(bool (*)(const MatrixXd &, const MatrixXd &))&is_approx<MatrixXd,MatrixXd>,
bp::args("A","B"),
"Returns True if A is approximately equal to B..");
// EXPOSE_IS_APPROX(MatrixXd);
// EXPOSE_IS_APPROX(MatrixXf);
}
exposeDecompositions();
......
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