Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JLimits.hh
Go to the documentation of this file.
1#ifndef __JMATH__JLIMITS__
2#define __JMATH__JLIMITS__
3
4#include <limits>
5
6/**
7 * \file
8 *
9 * Definition of minimum and maximum values for any class.
10 * \author mdejong
11 */
12namespace JMATH {}
13namespace JPP { using namespace JMATH; }
14
15namespace JMATH {
16
17 /**
18 * Auxiliary class for minimum and maximum values for any class.
19 */
20 template<class T, bool __is_specialized__ = std::numeric_limits<T>::is_specialized>
21 struct JLimits;
22
23
24 /**
25 * Template spacialisation of JMATH::JLimits for numerical values.
26 */
27 template<class T>
28 struct JLimits<T, true> {
29 /**
30 * Get minimum possible value.
31 *
32 * \return minimum possible value
33 */
34 static T min()
35 {
36 return std::numeric_limits<T>::min();
37 }
38
39
40 /**
41 * Get maximum possible value.
42 *
43 * \return maximum possible value
44 */
45 static T max()
46 {
47 return std::numeric_limits<T>::max();
48 }
49
50 static const bool is_specialized = true;
51 };
52
53
54 /**
55 * Template spacialisation of JMATH::JRandom for other data types.
56 *
57 * The given template class should provide for the methods:
58 * <pre>
59 * static T %min();
60 * static T %max();
61 * </pre>
62 */
63 template<class T>
64 struct JLimits<T, false> {
65 /**
66 * Get minimum possible value.
67 *
68 * \return minimum possible value
69 */
70 static T min()
71 {
72 return T::min();
73 }
74
75
76 /**
77 * Get maximum possible value.
78 *
79 * \return maximum possible value
80 */
81 static T max()
82 {
83 return T::max();
84 }
85
86 static const bool is_specialized = false;
87 };
88
89
90 /**
91 * Get minimum possible value.
92 *
93 * \return minimum possible value
94 */
95 template<>
97 {
98 return std::numeric_limits<float>::lowest();
99 }
100
101
102 /**
103 * Get minimum possible value.
104 *
105 * \return minimum possible value
106 */
107 template<>
109 {
110 return std::numeric_limits<double>::lowest();
111 }
112
113
114 /**
115 * Get minimum possible value.
116 *
117 * \return minimum possible value
118 */
119 template<>
121 {
122 return std::numeric_limits<long double>::lowest();
123 }
124}
125
126#endif
Auxiliary classes and methods for mathematical operations.
Definition JEigen3D.hh:88
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
static T min()
Get minimum possible value.
Definition JLimits.hh:70
static T max()
Get maximum possible value.
Definition JLimits.hh:81
static T min()
Get minimum possible value.
Definition JLimits.hh:34
static T max()
Get maximum possible value.
Definition JLimits.hh:45
Auxiliary class for minimum and maximum values for any class.
Definition JLimits.hh:21
float min()
Get minimum possible value.
Definition JLimits.hh:96