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