15#include "./InternalHeaderCheck.h"
21template <typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
22struct isApprox_selector {
23 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec) {
24 typename internal::nested_eval<Derived, 2>::type nested(x);
25 typename internal::nested_eval<OtherDerived, 2>::type otherNested(y);
26 return (nested.matrix() - otherNested.matrix()).cwiseAbs2().sum() <=
27 prec * prec * numext::mini(nested.cwiseAbs2().sum(), otherNested.cwiseAbs2().sum());
31template <
typename Derived,
typename OtherDerived>
32struct isApprox_selector<Derived, OtherDerived, true> {
33 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar&) {
34 return x.matrix() == y.matrix();
38template <typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
39struct isMuchSmallerThan_object_selector {
40 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const OtherDerived& y,
const typename Derived::RealScalar& prec) {
41 return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
45template <
typename Derived,
typename OtherDerived>
46struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true> {
47 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const OtherDerived&,
const typename Derived::RealScalar&) {
48 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
52template <typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
53struct isMuchSmallerThan_scalar_selector {
54 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const typename Derived::RealScalar& y,
55 const typename Derived::RealScalar& prec) {
56 return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
60template <
typename Derived>
61struct isMuchSmallerThan_scalar_selector<Derived, true> {
62 EIGEN_DEVICE_FUNC
static bool run(
const Derived& x,
const typename Derived::RealScalar&,
63 const typename Derived::RealScalar&) {
64 return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
87template <
typename Derived>
88template <
typename OtherDerived>
90 const RealScalar& prec)
const {
91 return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
107template <
typename Derived>
109 const RealScalar& prec)
const {
110 return internal::isMuchSmallerThan_scalar_selector<Derived>::run(derived(), other, prec);
123template <
typename Derived>
124template <
typename OtherDerived>
126 const RealScalar& prec)
const {
127 return internal::isMuchSmallerThan_object_selector<Derived, OtherDerived>::run(derived(), other.
derived(), prec);
Base class for all dense matrices, vectors, and arrays.
Definition DenseBase.h:44
Derived & derived()
Definition EigenBase.h:49
Namespace containing all symbols from the Eigen library.
Definition Core:137