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.matrix() - otherNested.matrix()).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)
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>
110 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
126 template<
typename Derived>
132 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
145 template<
typename Derived>
146 template<
typename OtherDerived>
152 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
#define EIGEN_DEVICE_FUNC
Base class for all dense matrices, vectors, and arrays.
NumTraits< Scalar >::Real RealScalar
bool isMuchSmallerThan(const RealScalar &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.