14 #include "./InternalHeaderCheck.h"
21 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
22 struct isApprox_selector
25 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
27 typename internal::nested_eval<Derived,2>::type nested(x);
28 typename internal::nested_eval<OtherDerived,2>::type otherNested(y);
29 return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
33 template<
typename Derived,
typename OtherDerived>
34 struct isApprox_selector<Derived, OtherDerived, true>
37 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar&)
39 return x.matrix() == y.matrix();
43 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
44 struct isMuchSmallerThan_object_selector
47 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
49 return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
53 template<
typename Derived,
typename OtherDerived>
54 struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
57 static bool run(
const Derived& x,
const OtherDerived&,
const typename Derived::RealScalar&)
59 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
63 template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
64 struct isMuchSmallerThan_scalar_selector
67 static bool run(
const Derived& x,
const typename Derived::RealScalar& y,
const typename Derived::RealScalar& prec)
69 return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
73 template<
typename Derived>
74 struct isMuchSmallerThan_scalar_selector<Derived, true>
77 static bool run(
const Derived& x,
const typename Derived::RealScalar&,
const typename Derived::RealScalar&)
79 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
103 template<
typename Derived>
104 template<
typename OtherDerived>
107 const RealScalar& prec
110 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
126 template<
typename Derived>
129 const RealScalar& prec
132 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
145 template<
typename Derived>
146 template<
typename OtherDerived>
149 const RealScalar& prec
152 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:42
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:105
Derived & derived()
Definition: EigenBase.h:48
Namespace containing all symbols from the Eigen library.
Definition: Core:139
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:231