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/system/Platform.h>
45 #include <blaze/util/Types.h>
46 
47 
48 namespace blaze {
49 
50 //=================================================================================================
51 //
52 // CLASS DEFINITION
53 //
54 //=================================================================================================
55 
56 //*************************************************************************************************
106 template< typename Type >
107 struct Limits
108 {};
109 //*************************************************************************************************
110 
111 
112 
113 
114 //=================================================================================================
115 //
116 // SPECIALIZATIONS
117 //
118 //=================================================================================================
119 
120 //*************************************************************************************************
125 template<>
126 struct Limits<unsigned char>
127 {
130  static inline constexpr unsigned char inf() { return std::numeric_limits<unsigned char>::max(); }
131 };
133 //*************************************************************************************************
134 
135 
136 //*************************************************************************************************
141 template<>
142 struct Limits<char>
143 {
146  static inline constexpr char inf () { return std::numeric_limits<char>::max(); }
147 
150  static inline constexpr char ninf() { return std::numeric_limits<char>::min(); }
151 };
153 //*************************************************************************************************
154 
155 
156 //*************************************************************************************************
161 template<>
162 struct Limits<signed char>
163 {
166  static inline constexpr signed char inf () { return std::numeric_limits<signed char>::max(); }
167 
170  static inline constexpr signed char ninf() { return std::numeric_limits<signed char>::min(); }
171 };
173 //*************************************************************************************************
174 
175 
176 //*************************************************************************************************
181 template<>
182 struct Limits<wchar_t>
183 {
186  static inline constexpr wchar_t inf () { return std::numeric_limits<wchar_t>::max(); }
187 
190  static inline constexpr wchar_t ninf() { return std::numeric_limits<wchar_t>::min(); }
191 };
193 //*************************************************************************************************
194 
195 
196 //*************************************************************************************************
201 template<>
202 struct Limits<unsigned short>
203 {
206  static inline constexpr unsigned short inf() { return std::numeric_limits<unsigned short>::max(); }
207 };
209 //*************************************************************************************************
210 
211 
212 //*************************************************************************************************
217 template<>
218 struct Limits<short>
219 {
222  static inline constexpr short inf () { return std::numeric_limits<short>::max(); }
223 
226  static inline constexpr short ninf() { return std::numeric_limits<short>::min(); }
227 };
229 //*************************************************************************************************
230 
231 
232 //*************************************************************************************************
237 template<>
238 struct Limits<unsigned int>
239 {
242  static inline constexpr unsigned int inf() { return std::numeric_limits<unsigned int>::max(); }
243 };
245 //*************************************************************************************************
246 
247 
248 //*************************************************************************************************
253 template<>
254 struct Limits<int>
255 {
258  static inline constexpr int inf () { return std::numeric_limits<int>::max(); }
259 
262  static inline constexpr int ninf() { return std::numeric_limits<int>::min(); }
263 };
265 //*************************************************************************************************
266 
267 
268 //*************************************************************************************************
273 template<>
274 struct Limits<unsigned long>
275 {
278  static inline constexpr unsigned long inf() { return std::numeric_limits<unsigned long>::max(); }
279 };
281 //*************************************************************************************************
282 
283 
284 //*************************************************************************************************
289 template<>
290 struct Limits<long>
291 {
294  static inline constexpr long inf () { return std::numeric_limits<long>::max(); }
295 
298  static inline constexpr long ninf() { return std::numeric_limits<long>::min(); }
299 };
301 //*************************************************************************************************
302 
303 
304 //*************************************************************************************************
305 #if BLAZE_WIN64_PLATFORM
306 
310 template<>
311 struct Limits<size_t>
312 {
315  static inline constexpr size_t inf() { return std::numeric_limits<size_t>::max(); }
316 };
318 #endif
319 //*************************************************************************************************
320 
321 
322 //*************************************************************************************************
323 #if BLAZE_WIN64_PLATFORM
324 
328 template<>
329 struct Limits<ptrdiff_t>
330 {
333  static inline constexpr ptrdiff_t inf () { return std::numeric_limits<ptrdiff_t>::max(); }
334 
337  static inline constexpr ptrdiff_t ninf() { return std::numeric_limits<ptrdiff_t>::min(); }
338 };
340 #endif
341 //*************************************************************************************************
342 
343 
344 //*************************************************************************************************
349 template<>
350 struct Limits<float>
351 {
354  static inline constexpr float inf () { return std::numeric_limits<float>::max(); }
355 
358  static inline constexpr float ninf() { return -std::numeric_limits<float>::max(); }
359 
362  static inline constexpr float epsilon() { return std::numeric_limits<float>::epsilon(); }
363 
366  static inline constexpr float accuracy() { return 1E-6F; }
367 
370  static inline constexpr float fpuAccuracy() { return 1E-12F; }
371 };
373 //*************************************************************************************************
374 
375 
376 //*************************************************************************************************
381 template<>
382 struct Limits<double>
383 {
386  static inline constexpr double inf () { return std::numeric_limits<double>::max(); }
387 
390  static inline constexpr double ninf() { return -std::numeric_limits<double>::max(); }
391 
394  static inline constexpr double epsilon() { return std::numeric_limits<double>::epsilon(); }
395 
398  static inline constexpr double accuracy() { return 1E-8; }
399 
402  static inline constexpr double fpuAccuracy() { return 1E-15; }
403 };
405 //*************************************************************************************************
406 
407 
408 //*************************************************************************************************
413 template<>
414 struct Limits<long double>
415 {
418  static inline constexpr long double inf () { return std::numeric_limits<long double>::max(); }
419 
422  static inline constexpr long double ninf() { return -std::numeric_limits<long double>::max(); }
423 
426  static inline constexpr long double epsilon() { return std::numeric_limits<long double>::epsilon(); }
427 
430  static inline constexpr long double accuracy() { return 1E-10L; }
431 
434  static inline constexpr long double fpuAccuracy() { return 1E-15L; }
435 };
437 //*************************************************************************************************
438 
439 } // namespace blaze
440 
441 #endif
Header file for basic type definitions.
constexpr Epsilon epsilon
Global Epsilon instance.The blaze::epsilon instance can be used wherever a floating point data type i...
Definition: Epsilon.h:906
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1147
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
Numerical limits of built-in data types.The Limits class provides numerical limits for the following ...
Definition: Limits.h:107
constexpr Infinity inf
Global Infinity instance.The blaze::inf instance can be used wherever a built-in data type is expecte...
Definition: Infinity.h:1080
constexpr Accuracy accuracy
Global Accuracy instance.The blaze::accuracy instance can be used wherever a floating point data type...
Definition: Accuracy.h:907
Platform-specific system settings.