Fuzzy.h
Go to the documentation of this file.
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2006-2008 Benoit Jacob <jacob.benoit.1@gmail.com>
5 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
6 //
7 // This Source Code Form is subject to the terms of the Mozilla
8 // Public License v. 2.0. If a copy of the MPL was not distributed
9 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 
11 #ifndef EIGEN_FUZZY_H
12 #define EIGEN_FUZZY_H
13 
14 namespace Eigen {
15 
16 namespace internal
17 {
18 
19 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
21 {
23  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)
24  {
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());
28  }
29 };
30 
31 template<typename Derived, typename OtherDerived>
32 struct isApprox_selector<Derived, OtherDerived, true>
33 {
35  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar&)
36  {
37  return x.matrix() == y.matrix();
38  }
39 };
40 
41 template<typename Derived, typename OtherDerived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
43 {
45  static bool run(const Derived& x, const OtherDerived& y, const typename Derived::RealScalar& prec)
46  {
47  return x.cwiseAbs2().sum() <= numext::abs2(prec) * y.cwiseAbs2().sum();
48  }
49 };
50 
51 template<typename Derived, typename OtherDerived>
52 struct isMuchSmallerThan_object_selector<Derived, OtherDerived, true>
53 {
55  static bool run(const Derived& x, const OtherDerived&, const typename Derived::RealScalar&)
56  {
57  return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
58  }
59 };
60 
61 template<typename Derived, bool is_integer = NumTraits<typename Derived::Scalar>::IsInteger>
63 {
65  static bool run(const Derived& x, const typename Derived::RealScalar& y, const typename Derived::RealScalar& prec)
66  {
67  return x.cwiseAbs2().sum() <= numext::abs2(prec * y);
68  }
69 };
70 
71 template<typename Derived>
72 struct isMuchSmallerThan_scalar_selector<Derived, true>
73 {
75  static bool run(const Derived& x, const typename Derived::RealScalar&, const typename Derived::RealScalar&)
76  {
77  return x.matrix() == Derived::Zero(x.rows(), x.cols()).matrix();
78  }
79 };
80 
81 } // end namespace internal
82 
83 
101 template<typename Derived>
102 template<typename OtherDerived>
105  const RealScalar& prec
106 ) const
107 {
108  return internal::isApprox_selector<Derived, OtherDerived>::run(derived(), other.derived(), prec);
109 }
110 
124 template<typename Derived>
126  const typename NumTraits<Scalar>::Real& other,
127  const RealScalar& prec
128 ) const
129 {
131 }
132 
143 template<typename Derived>
144 template<typename OtherDerived>
147  const RealScalar& prec
148 ) const
149 {
151 }
152 
153 } // end namespace Eigen
154 
155 #endif // EIGEN_FUZZY_H
EIGEN_DEVICE_FUNC
#define EIGEN_DEVICE_FUNC
Definition: Macros.h:976
Eigen
Namespace containing all symbols from the Eigen library.
Definition: jet.h:637
Eigen::internal::isMuchSmallerThan_object_selector
Definition: Fuzzy.h:42
Eigen::internal::isMuchSmallerThan_object_selector::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const OtherDerived &y, const typename Derived::RealScalar &prec)
Definition: Fuzzy.h:45
Eigen::internal::nested
Definition: TensorTraits.h:174
x
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition: gnuplot_common_settings.hh:12
Eigen::internal::isMuchSmallerThan_object_selector< Derived, OtherDerived, true >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const OtherDerived &, const typename Derived::RealScalar &)
Definition: Fuzzy.h:55
Eigen::internal::isMuchSmallerThan_scalar_selector< Derived, true >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const typename Derived::RealScalar &, const typename Derived::RealScalar &)
Definition: Fuzzy.h:75
Eigen::internal::true_type
Definition: Meta.h:96
Eigen::DenseBase< Solve< Decomposition, RhsType > >::RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: DenseBase.h:73
Eigen::internal::isApprox_selector::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const OtherDerived &y, const typename Derived::RealScalar &prec)
Definition: Fuzzy.h:23
Eigen::numext::mini
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T mini(const T &x, const T &y)
Definition: Eigen/src/Core/MathFunctions.h:1085
Eigen::internal::isMuchSmallerThan_scalar_selector::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const typename Derived::RealScalar &y, const typename Derived::RealScalar &prec)
Definition: Fuzzy.h:65
Eigen::internal::isMuchSmallerThan_scalar_selector
Definition: Fuzzy.h:62
RealScalar
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:47
Eigen::numext::abs2
EIGEN_DEVICE_FUNC bool abs2(bool x)
Definition: Eigen/src/Core/MathFunctions.h:1294
Eigen::DenseBase
Base class for all dense matrices, vectors, and arrays.
Definition: DenseBase.h:41
Eigen::DenseBase::isApprox
EIGEN_DEVICE_FUNC bool isApprox(const DenseBase< OtherDerived > &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const
Definition: Fuzzy.h:103
Eigen::internal::y
const Scalar & y
Definition: Eigen/src/Core/MathFunctions.h:821
Eigen::internal::isApprox_selector
Definition: Fuzzy.h:20
internal
Definition: BandTriangularSolver.h:13
Eigen::internal::isApprox_selector< Derived, OtherDerived, true >::run
static EIGEN_DEVICE_FUNC bool run(const Derived &x, const OtherDerived &y, const typename Derived::RealScalar &)
Definition: Fuzzy.h:35
Eigen::NumTraits
Holds information about the various numeric (i.e. scalar) types allowed by Eigen.
Definition: NumTraits.h:232
pybind_wrapper_test_script.other
other
Definition: pybind_wrapper_test_script.py:42
Eigen::DenseBase::isMuchSmallerThan
EIGEN_DEVICE_FUNC bool isMuchSmallerThan(const RealScalar &other, const RealScalar &prec=NumTraits< Scalar >::dummy_precision()) const


gtsam
Author(s):
autogenerated on Thu Dec 19 2024 04:01:08