|
1 | 1 | /* |
2 | 2 | * Copyright 2014-2019, CNRS |
3 | | - * Copyright 2018-2023, INRIA |
| 3 | + * Copyright 2018-2024, INRIA |
4 | 4 | */ |
5 | 5 |
|
6 | 6 | #include <boost/python/scope.hpp> |
|
17 | 17 |
|
18 | 18 | using namespace eigenpy; |
19 | 19 |
|
| 20 | +template <typename Scalar> |
| 21 | +void exposeIsApprox() { |
| 22 | + enum { Options = 0 }; |
| 23 | + EIGENPY_MAKE_TYPEDEFS(Scalar, Options, s, Eigen::Dynamic, X); |
| 24 | + EIGENPY_UNUSED_TYPE(VectorXs); |
| 25 | + EIGENPY_UNUSED_TYPE(RowVectorXs); |
| 26 | + typedef Eigen::SparseMatrix<Scalar, Options> SparseMatrixXs; |
| 27 | + typedef typename MatrixXs::RealScalar RealScalar; |
| 28 | + |
| 29 | + using namespace Eigen; |
| 30 | + const RealScalar dummy_precision = |
| 31 | + Eigen::NumTraits<RealScalar>::dummy_precision(); |
| 32 | + |
| 33 | + bp::def("is_approx", |
| 34 | + (bool (*)(const Eigen::MatrixBase<MatrixXs> &, |
| 35 | + const Eigen::MatrixBase<MatrixXs> &, const RealScalar &)) & |
| 36 | + is_approx, |
| 37 | + (bp::arg("A"), bp::arg("B"), bp::arg("prec") = dummy_precision), |
| 38 | + "Returns True if A is approximately equal to B, within the " |
| 39 | + "precision determined by prec."); |
| 40 | + |
| 41 | + bp::def("is_approx", |
| 42 | + (bool (*)(const Eigen::SparseMatrixBase<SparseMatrixXs> &, |
| 43 | + const Eigen::SparseMatrixBase<SparseMatrixXs> &, |
| 44 | + const RealScalar &)) & |
| 45 | + is_approx, |
| 46 | + (bp::arg("A"), bp::arg("B"), bp::arg("prec") = dummy_precision), |
| 47 | + "Returns True if A is approximately equal to B, within the " |
| 48 | + "precision determined by prec."); |
| 49 | +} |
| 50 | + |
20 | 51 | BOOST_PYTHON_MODULE(eigenpy_pywrap) { |
21 | 52 | enableEigenPy(); |
22 | 53 |
|
@@ -46,17 +77,8 @@ BOOST_PYTHON_MODULE(eigenpy_pywrap) { |
46 | 77 | register_symbolic_link_to_registered_type<Eigen::ComputationInfo>(); |
47 | 78 | } |
48 | 79 |
|
49 | | - { |
50 | | - using namespace Eigen; |
51 | | - |
52 | | - bp::def("is_approx", |
53 | | - (bool (*)(const Eigen::MatrixBase<MatrixXd> &, |
54 | | - const Eigen::MatrixBase<MatrixXd> &, const double &)) & |
55 | | - is_approx<MatrixXd, MatrixXd>, |
56 | | - (bp::arg("A"), bp::arg("B"), bp::arg("prec") = 1e-12), |
57 | | - "Returns True if A is approximately equal to B, within the " |
58 | | - "precision determined by prec."); |
59 | | - } |
| 80 | + exposeIsApprox<double>(); |
| 81 | + exposeIsApprox<std::complex<double> >(); |
60 | 82 |
|
61 | 83 | exposeDecompositions(); |
62 | 84 | } |
0 commit comments