NumTraits.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-2010 Benoit Jacob <jacob.benoit.1@gmail.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_NUMTRAITS_H
11 #define EIGEN_NUMTRAITS_H
12 
13 namespace Eigen {
14 
51 template<typename T> struct GenericNumTraits
52 {
53  enum {
54  IsInteger = std::numeric_limits<T>::is_integer,
55  IsSigned = std::numeric_limits<T>::is_signed,
56  IsComplex = 0,
58  ReadCost = 1,
59  AddCost = 1,
60  MulCost = 1
61  };
62 
63  typedef T Real;
64  typedef typename internal::conditional<
65  IsInteger,
67  T
68  >::type NonInteger;
69  typedef T Nested;
70 
71  static inline Real epsilon() { return std::numeric_limits<T>::epsilon(); }
72  static inline Real dummy_precision()
73  {
74  // make sure to override this for floating-point types
75  return Real(0);
76  }
77  static inline T highest() { return (std::numeric_limits<T>::max)(); }
78  static inline T lowest() { return IsInteger ? (std::numeric_limits<T>::min)() : (-(std::numeric_limits<T>::max)()); }
79 
80 #ifdef EIGEN2_SUPPORT
81  enum {
82  HasFloatingPoint = !IsInteger
83  };
84  typedef NonInteger FloatingPoint;
85 #endif
86 };
87 
88 template<typename T> struct NumTraits : GenericNumTraits<T>
89 {};
90 
91 template<> struct NumTraits<float>
92  : GenericNumTraits<float>
93 {
94  static inline float dummy_precision() { return 1e-5f; }
95 };
96 
97 template<> struct NumTraits<double> : GenericNumTraits<double>
98 {
99  static inline double dummy_precision() { return 1e-12; }
100 };
101 
102 template<> struct NumTraits<long double>
103  : GenericNumTraits<long double>
104 {
105  static inline long double dummy_precision() { return 1e-15l; }
106 };
107 
108 template<typename _Real> struct NumTraits<std::complex<_Real> >
109  : GenericNumTraits<std::complex<_Real> >
110 {
111  typedef _Real Real;
112  enum {
118  };
119 
120  static inline Real epsilon() { return NumTraits<Real>::epsilon(); }
121  static inline Real dummy_precision() { return NumTraits<Real>::dummy_precision(); }
122 };
123 
124 template<typename Scalar, int Rows, int Cols, int Options, int MaxRows, int MaxCols>
125 struct NumTraits<Array<Scalar, Rows, Cols, Options, MaxRows, MaxCols> >
126 {
132  typedef ArrayType & Nested;
133 
134  enum {
139  ReadCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::ReadCost,
140  AddCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::AddCost,
141  MulCost = ArrayType::SizeAtCompileTime==Dynamic ? Dynamic : ArrayType::SizeAtCompileTime * NumTraits<Scalar>::MulCost
142  };
143 
144  static inline RealScalar epsilon() { return NumTraits<RealScalar>::epsilon(); }
145  static inline RealScalar dummy_precision() { return NumTraits<RealScalar>::dummy_precision(); }
146 };
147 
148 } // end namespace Eigen
149 
150 #endif // EIGEN_NUMTRAITS_H
static double dummy_precision()
Definition: NumTraits.h:99
double epsilon
f
Definition: LDLT.h:16
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:88
static float dummy_precision()
Definition: NumTraits.h:94
Array< Scalar, Rows, Cols, Options, MaxRows, MaxCols > ArrayType
Definition: NumTraits.h:127
static long double dummy_precision()
Definition: NumTraits.h:105
General-purpose arrays with easy API for coefficient-wise operations.
Definition: Array.h:42
Array< NonIntegerScalar, Rows, Cols, Options, MaxRows, MaxCols > NonInteger
Definition: NumTraits.h:131
Array< RealScalar, Rows, Cols, Options, MaxRows, MaxCols > Real
Definition: NumTraits.h:129
const int Dynamic
Definition: Constants.h:21


tuw_aruco
Author(s): Lukas Pfeifhofer
autogenerated on Mon Jun 10 2019 15:40:54