19 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
20 struct isApprox_selector
22 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
25 typename internal::nested<Derived,2>::type nested(x);
26 typename internal::nested<OtherDerived,2>::type otherNested(y);
27 return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * (min)(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
31 template<
typename Derived,
typename OtherDerived>
32 struct isApprox_selector<Derived, OtherDerived, true>
34 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar&)
36 return x.matrix() == y.matrix();
40 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
41 struct isMuchSmallerThan_object_selector
43 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
45 return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
49 template<
typename Derived,
typename OtherDerived>
50 struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
52 static bool run(
const Derived& x,
const OtherDerived&,
const typename Derived::RealScalar&)
54 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
58 template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
59 struct isMuchSmallerThan_scalar_selector
61 static bool run(
const Derived& x,
const typename Derived::RealScalar& y,
const typename Derived::RealScalar& prec)
63 return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
67 template<
typename Derived>
68 struct isMuchSmallerThan_scalar_selector<Derived, true>
70 static bool run(
const Derived& x,
const typename Derived::RealScalar&,
const typename Derived::RealScalar&)
72 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
96 template<
typename Derived>
97 template<
typename OtherDerived>
100 const RealScalar& prec
103 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
119 template<
typename Derived>
122 const RealScalar& prec
125 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
138 template<
typename Derived>
139 template<
typename OtherDerived>
142 const RealScalar& prec
145 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
150 #endif // EIGEN_FUZZY_H
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:98
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41