19 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
20 struct isApprox_selector
23 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
25 typename internal::nested_eval<Derived,2>::type nested(x);
26 typename internal::nested_eval<OtherDerived,2>::type otherNested(y);
27 return (nested - otherNested).cwiseAbs2().sum() <= prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
31 template<
typename Derived,
typename OtherDerived>
32 struct isApprox_selector<Derived, OtherDerived, true>
35 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar&)
37 return x.matrix() == y.matrix();
41 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
42 struct isMuchSmallerThan_object_selector
45 static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec)
47 return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
51 template<
typename Derived,
typename OtherDerived>
52 struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
55 static bool run(
const Derived& x,
const OtherDerived&,
const typename Derived::RealScalar&)
57 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
61 template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
62 struct isMuchSmallerThan_scalar_selector
65 static bool run(
const Derived& x,
const typename Derived::RealScalar& y,
const typename Derived::RealScalar& prec)
67 return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
71 template<
typename Derived>
72 struct isMuchSmallerThan_scalar_selector<Derived, true>
75 static bool run(
const Derived& x,
const typename Derived::RealScalar&,
const typename Derived::RealScalar&)
77 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
101 template<
typename Derived>
102 template<
typename OtherDerived>
105 const RealScalar& prec
108 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
124 template<
typename Derived>
127 const RealScalar& prec
130 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
143 template<
typename Derived>
144 template<
typename OtherDerived>
147 const RealScalar& prec
150 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:47
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103
Derived & derived()
Definition: EigenBase.h:46
Namespace containing all symbols from the Eigen library.
Definition: Core:134
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:213