TypeTraits.h
Go to the documentation of this file.
1 // Copyright (C) 2018-2019 Yixuan Qiu <yixuan.qiu@cos.name>
2 //
3 // This Source Code Form is subject to the terms of the Mozilla
4 // Public License v. 2.0. If a copy of the MPL was not distributed
5 // with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
6 
7 #ifndef TYPE_TRAITS_H
8 #define TYPE_TRAITS_H
9 
10 #include <Eigen/Core>
11 #include <limits>
12 
14 
15 namespace Spectra {
16 
17 // For a real value type "Scalar", we want to know its smallest
18 // positive value, i.e., std::numeric_limits<Scalar>::min().
19 // However, we must take non-standard value types into account,
20 // so we rely on Eigen::NumTraits.
21 //
22 // Eigen::NumTraits has defined epsilon() and lowest(), but
23 // lowest() means negative highest(), which is a very small
24 // negative value.
25 //
26 // Therefore, we manually define this limit, and use eplison()^3
27 // to mimic it for non-standard types.
28 
29 // Generic definition
30 template <typename Scalar>
31 struct TypeTraits
32 {
33  static inline Scalar min()
34  {
36  }
37 };
38 
39 // Full specialization
40 template <>
41 struct TypeTraits<float>
42 {
43  static inline float min()
44  {
46  }
47 };
48 
49 template <>
50 struct TypeTraits<double>
51 {
52  static inline double min()
53  {
55  }
56 };
57 
58 template <>
59 struct TypeTraits<long double>
60 {
61  static inline long double min()
62  {
64  }
65 };
66 
67 } // namespace Spectra
68 
70 
71 #endif // TYPE_TRAITS_H
SCALAR Scalar
Definition: bench_gemm.cpp:46
#define min(a, b)
Definition: datatypes.h:19
Holds information about the various numeric (i.e. scalar) types allowed by Eigen. ...
Definition: NumTraits.h:232
EIGEN_DEVICE_FUNC internal::pow_impl< ScalarX, ScalarY >::result_type pow(const ScalarX &x, const ScalarY &y)


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:40:39