diff --git a/include/eigenpy/utils/is-approx.hpp b/include/eigenpy/utils/is-approx.hpp index 2c1d24f24c2cb5c36f975491faf6a81a6ed92cb3..7f82ffde1144abe694c414ecda119baff4a7fc9c 100644 --- a/include/eigenpy/utils/is-approx.hpp +++ b/include/eigenpy/utils/is-approx.hpp @@ -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()); } } diff --git a/python/main.cpp b/python/main.cpp index be7237392cdc48df9ce97f5c96eb4e427909cd96..925d9cff88ef03738582bcc3b1920056ecdace1b 100644 --- a/python/main.cpp +++ b/python/main.cpp @@ -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();