All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Limits.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_UTIL_LIMITS_H_
23 #define _BLAZE_UTIL_LIMITS_H_
24 
25 
26 //*************************************************************************************************
27 // Includes
28 //*************************************************************************************************
29 
30 #include <limits>
31 #include <blaze/util/Types.h>
32 
33 
34 namespace blaze {
35 
36 //=================================================================================================
37 //
38 // CLASS DEFINITION
39 //
40 //=================================================================================================
41 
42 //*************************************************************************************************
92 template< typename Type >
93 struct Limits
94 {};
95 //*************************************************************************************************
96 
97 
98 
99 
100 //=================================================================================================
101 //
102 // SPECIALIZATIONS
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
111 template<>
112 struct Limits<unsigned char>
113 {
116  static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); }
117 };
119 //*************************************************************************************************
120 
121 
122 //*************************************************************************************************
127 template<>
128 struct Limits<char>
129 {
132  static inline char inf () { return std::numeric_limits<char>::max(); }
133 
136  static inline char ninf() { return std::numeric_limits<char>::min(); }
137 };
139 //*************************************************************************************************
140 
141 
142 //*************************************************************************************************
147 template<>
148 struct Limits<signed char>
149 {
152  static inline signed char inf () { return std::numeric_limits<signed char>::max(); }
153 
156  static inline signed char ninf() { return std::numeric_limits<signed char>::min(); }
157 };
159 //*************************************************************************************************
160 
161 
162 //*************************************************************************************************
167 template<>
168 struct Limits<wchar_t>
169 {
172  static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); }
173 
176  static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); }
177 };
179 //*************************************************************************************************
180 
181 
182 //*************************************************************************************************
187 template<>
188 struct Limits<unsigned short>
189 {
192  static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); }
193 };
195 //*************************************************************************************************
196 
197 
198 //*************************************************************************************************
203 template<>
204 struct Limits<short>
205 {
208  static inline short inf () { return std::numeric_limits<short>::max(); }
209 
212  static inline short ninf() { return std::numeric_limits<short>::min(); }
213 };
215 //*************************************************************************************************
216 
217 
218 //*************************************************************************************************
223 template<>
224 struct Limits<unsigned int>
225 {
228  static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); }
229 };
231 //*************************************************************************************************
232 
233 
234 //*************************************************************************************************
239 template<>
240 struct Limits<int>
241 {
244  static inline int inf () { return std::numeric_limits<int>::max(); }
245 
248  static inline int ninf() { return std::numeric_limits<int>::min(); }
249 };
251 //*************************************************************************************************
252 
253 
254 //*************************************************************************************************
259 template<>
260 struct Limits<unsigned long>
261 {
264  static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); }
265 };
267 //*************************************************************************************************
268 
269 
270 //*************************************************************************************************
275 template<>
276 struct Limits<long>
277 {
280  static inline long inf () { return std::numeric_limits<long>::max(); }
281 
284  static inline long ninf() { return std::numeric_limits<long>::min(); }
285 };
287 //*************************************************************************************************
288 
289 
290 //*************************************************************************************************
291 #if defined(_WIN64)
292 
296 template<>
297 struct Limits<std::size_t>
298 {
301  static inline size_t inf() { return std::numeric_limits<size_t>::max(); }
302 };
304 #endif
305 //*************************************************************************************************
306 
307 
308 //*************************************************************************************************
309 #if defined(_WIN64)
310 
314 template<>
315 struct Limits<ptrdiff_t>
316 {
319  static inline ptrdiff_t inf () { return std::numeric_limits<ptrdiff_t>::max(); }
320 
323  static inline ptrdiff_t ninf() { return std::numeric_limits<ptrdiff_t>::min(); }
324 };
326 #endif
327 //*************************************************************************************************
328 
329 
330 //*************************************************************************************************
335 template<>
336 struct Limits<float>
337 {
340  static inline float inf () { return std::numeric_limits<float>::max(); }
341 
344  static inline float ninf() { return -std::numeric_limits<float>::max(); }
345 
348  static inline float epsilon() { return std::numeric_limits<float>::epsilon(); }
349 
352  static inline float accuracy() { return 1E-6F; }
353 
356  static inline float fpuAccuracy() { return 1E-12F; }
357 };
359 //*************************************************************************************************
360 
361 
362 //*************************************************************************************************
367 template<>
368 struct Limits<double>
369 {
372  static inline double inf () { return std::numeric_limits<double>::max(); }
373 
376  static inline double ninf() { return -std::numeric_limits<double>::max(); }
377 
380  static inline double epsilon() { return std::numeric_limits<double>::epsilon(); }
381 
384  static inline double accuracy() { return 1E-8; }
385 
388  static inline double fpuAccuracy() { return 1E-15; }
389 };
391 //*************************************************************************************************
392 
393 
394 //*************************************************************************************************
399 template<>
400 struct Limits<long double>
401 {
404  static inline long double inf () { return std::numeric_limits<long double>::max(); }
405 
408  static inline long double ninf() { return -std::numeric_limits<long double>::max(); }
409 
412  static inline long double epsilon() { return std::numeric_limits<long double>::epsilon(); }
413 
416  static inline long double accuracy() { return 1E-10L; }
417 
420  static inline long double fpuAccuracy() { return 1E-15L; }
421 };
423 //*************************************************************************************************
424 
425 } // namespace blaze
426 
427 #endif