@@ -542,6 +542,63 @@ namespace pinocchio
542542 internal::arrayMinAlgo<M, Res>::run (x, min, res);
543543 }
544544
545+ namespace internal
546+ {
547+ template <
548+ typename MatrixLike1,
549+ typename MatrixLike2,
550+ bool value = is_floating_point<typename MatrixLike1::Scalar>::value
551+ && is_floating_point<typename MatrixLike2::Scalar>::value>
552+ struct isApproxAlgo
553+ {
554+ typedef typename MatrixLike1::RealScalar RealScalar;
555+
556+ static bool run (
557+ const Eigen::MatrixBase<MatrixLike1> & m1,
558+ const Eigen::MatrixBase<MatrixLike2> & m2,
559+ const RealScalar & prec = Eigen::NumTraits<RealScalar>::dummy_precision())
560+ {
561+ return m1.isApprox (m2, prec);
562+ }
563+ };
564+
565+ template <typename MatrixLike1, typename MatrixLike2>
566+ struct isApproxAlgo <MatrixLike1, MatrixLike2, false >
567+ {
568+ typedef typename MatrixLike1::RealScalar RealScalar;
569+
570+ static bool run (
571+ const Eigen::MatrixBase<MatrixLike1> & m1,
572+ const Eigen::MatrixBase<MatrixLike2> & m2,
573+ const RealScalar & prec = Eigen::NumTraits<RealScalar>::dummy_precision())
574+ {
575+ PINOCCHIO_UNUSED_VARIABLE (m1);
576+ PINOCCHIO_UNUSED_VARIABLE (m2);
577+ PINOCCHIO_UNUSED_VARIABLE (prec);
578+ return true ;
579+ }
580+ };
581+ } // namespace internal
582+
583+ // /
584+ // / \brief Check whether two matrix are approximately the same
585+ // /
586+ // / \param[in] m1 Input matrix
587+ // / \param[in] m2 Input matrix
588+ // / \param[in] prec Required precision
589+ // /
590+ // / \returns true if m1 and m2 are approximately the same given precision prec.
591+ // /
592+ template <typename MatrixLike1, typename MatrixLike2>
593+ inline bool isApprox (
594+ const Eigen::MatrixBase<MatrixLike1> & m1,
595+ const Eigen::MatrixBase<MatrixLike2> & m2,
596+ const typename MatrixLike1::RealScalar & prec =
597+ Eigen::NumTraits<typename MatrixLike1::Scalar>::dummy_precision())
598+ {
599+ return internal::isApproxAlgo<MatrixLike1, MatrixLike2>::run (m1, m2, prec);
600+ }
601+
545602 template <typename XprType, typename DestType>
546603 inline void evalTo (const XprType & xpr, DestType & dest)
547604 {
0 commit comments