Limits.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_UTIL_LIMITS_H_
36 #define _BLAZE_UTIL_LIMITS_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <limits>
44 #include <blaze/util/Types.h>
45 
46 
47 namespace blaze {
48 
49 //=================================================================================================
50 //
51 // CLASS DEFINITION
52 //
53 //=================================================================================================
54 
55 //*************************************************************************************************
105 template< typename Type >
106 struct Limits
107 {};
108 //*************************************************************************************************
109 
110 
111 
112 
113 //=================================================================================================
114 //
115 // SPECIALIZATIONS
116 //
117 //=================================================================================================
118 
119 //*************************************************************************************************
124 template<>
125 struct Limits<unsigned char>
126 {
129  static inline unsigned char inf() { return std::numeric_limits<unsigned char>::max(); }
130 };
132 //*************************************************************************************************
133 
134 
135 //*************************************************************************************************
140 template<>
141 struct Limits<char>
142 {
145  static inline char inf () { return std::numeric_limits<char>::max(); }
146 
149  static inline char ninf() { return std::numeric_limits<char>::min(); }
150 };
152 //*************************************************************************************************
153 
154 
155 //*************************************************************************************************
160 template<>
161 struct Limits<signed char>
162 {
165  static inline signed char inf () { return std::numeric_limits<signed char>::max(); }
166 
169  static inline signed char ninf() { return std::numeric_limits<signed char>::min(); }
170 };
172 //*************************************************************************************************
173 
174 
175 //*************************************************************************************************
180 template<>
181 struct Limits<wchar_t>
182 {
185  static inline wchar_t inf () { return std::numeric_limits<wchar_t>::max(); }
186 
189  static inline wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); }
190 };
192 //*************************************************************************************************
193 
194 
195 //*************************************************************************************************
200 template<>
201 struct Limits<unsigned short>
202 {
205  static inline unsigned short inf() { return std::numeric_limits<unsigned short>::max(); }
206 };
208 //*************************************************************************************************
209 
210 
211 //*************************************************************************************************
216 template<>
217 struct Limits<short>
218 {
221  static inline short inf () { return std::numeric_limits<short>::max(); }
222 
225  static inline short ninf() { return std::numeric_limits<short>::min(); }
226 };
228 //*************************************************************************************************
229 
230 
231 //*************************************************************************************************
236 template<>
237 struct Limits<unsigned int>
238 {
241  static inline unsigned int inf() { return std::numeric_limits<unsigned int>::max(); }
242 };
244 //*************************************************************************************************
245 
246 
247 //*************************************************************************************************
252 template<>
253 struct Limits<int>
254 {
257  static inline int inf () { return std::numeric_limits<int>::max(); }
258 
261  static inline int ninf() { return std::numeric_limits<int>::min(); }
262 };
264 //*************************************************************************************************
265 
266 
267 //*************************************************************************************************
272 template<>
273 struct Limits<unsigned long>
274 {
277  static inline unsigned long inf() { return std::numeric_limits<unsigned long>::max(); }
278 };
280 //*************************************************************************************************
281 
282 
283 //*************************************************************************************************
288 template<>
289 struct Limits<long>
290 {
293  static inline long inf () { return std::numeric_limits<long>::max(); }
294 
297  static inline long ninf() { return std::numeric_limits<long>::min(); }
298 };
300 //*************************************************************************************************
301 
302 
303 //*************************************************************************************************
304 #if defined(_WIN64)
305 
309 template<>
310 struct Limits<std::size_t>
311 {
314  static inline size_t inf() { return std::numeric_limits<size_t>::max(); }
315 };
317 #endif
318 //*************************************************************************************************
319 
320 
321 //*************************************************************************************************
322 #if defined(_WIN64)
323 
327 template<>
328 struct Limits<ptrdiff_t>
329 {
332  static inline ptrdiff_t inf () { return std::numeric_limits<ptrdiff_t>::max(); }
333 
336  static inline ptrdiff_t ninf() { return std::numeric_limits<ptrdiff_t>::min(); }
337 };
339 #endif
340 //*************************************************************************************************
341 
342 
343 //*************************************************************************************************
348 template<>
349 struct Limits<float>
350 {
353  static inline float inf () { return std::numeric_limits<float>::max(); }
354 
357  static inline float ninf() { return -std::numeric_limits<float>::max(); }
358 
361  static inline float epsilon() { return std::numeric_limits<float>::epsilon(); }
362 
365  static inline float accuracy() { return 1E-6F; }
366 
369  static inline float fpuAccuracy() { return 1E-12F; }
370 };
372 //*************************************************************************************************
373 
374 
375 //*************************************************************************************************
380 template<>
381 struct Limits<double>
382 {
385  static inline double inf () { return std::numeric_limits<double>::max(); }
386 
389  static inline double ninf() { return -std::numeric_limits<double>::max(); }
390 
393  static inline double epsilon() { return std::numeric_limits<double>::epsilon(); }
394 
397  static inline double accuracy() { return 1E-8; }
398 
401  static inline double fpuAccuracy() { return 1E-15; }
402 };
404 //*************************************************************************************************
405 
406 
407 //*************************************************************************************************
412 template<>
413 struct Limits<long double>
414 {
417  static inline long double inf () { return std::numeric_limits<long double>::max(); }
418 
421  static inline long double ninf() { return -std::numeric_limits<long double>::max(); }
422 
425  static inline long double epsilon() { return std::numeric_limits<long double>::epsilon(); }
426 
429  static inline long double accuracy() { return 1E-10L; }
430 
433  static inline long double fpuAccuracy() { return 1E-15L; }
434 };
436 //*************************************************************************************************
437 
438 } // namespace blaze
439 
440 #endif
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
Header file for basic type definitions.
STL namespace.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:1682
Numerical limits of built-in data types.The Limits class provides numerical limits for the following ...
Definition: Limits.h:106
const Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1098
const Accuracy accuracy
Global Accuracy instance.The blaze::accuracy instance can be used wherever a floating point data type...
Definition: Accuracy.h:901
const Epsilon epsilon
Global Epsilon instance.The blaze::epsilon instance can be used wherever a floating point data type i...
Definition: Epsilon.h:901