19template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
20struct isApprox_selector
22 static bool run(
const Derived& x,
const OtherDerived& y,
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());
31template<
typename Derived,
typename OtherDerived>
32struct isApprox_selector<Derived, OtherDerived, true>
34 static bool run(
const Derived& x,
const OtherDerived& y,
typename Derived::RealScalar)
36 return x.matrix() == y.matrix();
40template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
41struct isMuchSmallerThan_object_selector
43 static bool run(
const Derived& x,
const OtherDerived& y,
typename Derived::RealScalar prec)
45 return x.cwiseAbs2().sum() <= abs2(prec) * y.cwiseAbs2().sum();
49template<
typename Derived,
typename OtherDerived>
50struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
52 static bool run(
const Derived& x,
const OtherDerived&,
typename Derived::RealScalar)
54 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
58template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
59struct isMuchSmallerThan_scalar_selector
61 static bool run(
const Derived& x,
const typename Derived::RealScalar& y,
typename Derived::RealScalar prec)
63 return x.cwiseAbs2().sum() <= abs2(prec * y);
67template<
typename Derived>
68struct isMuchSmallerThan_scalar_selector<Derived, true>
70 static bool run(
const Derived& x,
const typename Derived::RealScalar&,
typename Derived::RealScalar)
72 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
96template<
typename Derived>
97template<
typename OtherDerived>
103 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
119template<
typename Derived>
120bool DenseBase<Derived>::isMuchSmallerThan(
121 const typename NumTraits<Scalar>::Real& other,
125 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
138template<
typename Derived>
139template<
typename OtherDerived>
140bool DenseBase<Derived>::isMuchSmallerThan(
145 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
bool isApprox(const DenseBase< OtherDerived > &other, RealScalar prec=NumTraits< Scalar >::dummy_precision()) const
Definition Fuzzy.h:98
DenseBase()
Definition DenseBase.h:513