NumCpp  2.1.0
A C++ implementation of the Python Numpy library
DtypeInfo.hpp
Go to the documentation of this file.
1 #pragma once
30 
32 
33 #include <complex>
34 #include <limits>
35 
36 namespace nc
37 {
38  //================================================================================
40  template<typename dtype>
41  class DtypeInfo
42  {
43  public:
44  //============================================================================
50  static constexpr int bits() noexcept
51  {
53 
54  return std::numeric_limits<dtype>::digits;
55  }
56 
57  //============================================================================
63  static constexpr dtype epsilon() noexcept
64  {
66 
67  return std::numeric_limits<dtype>::epsilon();
68  }
69 
70  //============================================================================
75  static constexpr bool isInteger() noexcept
76  {
78 
79  return std::numeric_limits<dtype>::is_integer;
80  }
81 
82  //============================================================================
87  static constexpr bool isSigned() noexcept
88  {
90 
91  return std::numeric_limits<dtype>::is_signed;
92  }
93 
94  //============================================================================
99  static constexpr dtype min() noexcept
100  {
102 
104  }
105 
106  //============================================================================
111  static constexpr dtype max() noexcept
112  {
114 
116  }
117  };
118 
119  //================================================================================
121  template<typename dtype>
122  class DtypeInfo<std::complex<dtype>>
123  {
124  public:
125  //============================================================================
131  static constexpr int bits() noexcept
132  {
134 
135  return std::numeric_limits<dtype>::digits;
136  }
137 
138  //============================================================================
144  static constexpr std::complex<dtype> epsilon() noexcept
145  {
147 
149  }
150 
151  //============================================================================
156  static constexpr bool isInteger() noexcept
157  {
159 
160  return std::numeric_limits<dtype>::is_integer;
161  }
162 
163  //============================================================================
168  static constexpr bool isSigned() noexcept
169  {
171 
172  return std::numeric_limits<dtype>::is_signed;
173  }
174 
175  //============================================================================
180  static constexpr std::complex<dtype> min() noexcept
181  {
183 
185  }
186 
187  //============================================================================
192  static constexpr std::complex<dtype> max() noexcept
193  {
195 
197  }
198  };
199 } // namespace nc
StaticAsserts.hpp
nc::complex
auto complex(dtype inReal)
Definition: complex.hpp:49
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:38
nc::DtypeInfo< std::complex< dtype > >::min
static constexpr std::complex< dtype > min() noexcept
Definition: DtypeInfo.hpp:180
nc::DtypeInfo::bits
static constexpr int bits() noexcept
Definition: DtypeInfo.hpp:50
nc::DtypeInfo< std::complex< dtype > >::isInteger
static constexpr bool isInteger() noexcept
Definition: DtypeInfo.hpp:156
nc::DtypeInfo::min
static constexpr dtype min() noexcept
Definition: DtypeInfo.hpp:99
nc::DtypeInfo< std::complex< dtype > >::epsilon
static constexpr std::complex< dtype > epsilon() noexcept
Definition: DtypeInfo.hpp:144
nc::DtypeInfo< std::complex< dtype > >::isSigned
static constexpr bool isSigned() noexcept
Definition: DtypeInfo.hpp:168
nc
Definition: Coordinate.hpp:45
nc::DtypeInfo< std::complex< dtype > >::max
static constexpr std::complex< dtype > max() noexcept
Definition: DtypeInfo.hpp:192
nc::DtypeInfo
Holds info about the dtype.
Definition: DtypeInfo.hpp:41
nc::max
NdArray< dtype > max(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: max.hpp:46
nc::DtypeInfo::epsilon
static constexpr dtype epsilon() noexcept
Definition: DtypeInfo.hpp:63
nc::DtypeInfo::isInteger
static constexpr bool isInteger() noexcept
Definition: DtypeInfo.hpp:75
nc::DtypeInfo::isSigned
static constexpr bool isSigned() noexcept
Definition: DtypeInfo.hpp:87
nc::DtypeInfo< std::complex< dtype > >::bits
static constexpr int bits() noexcept
Definition: DtypeInfo.hpp:131
nc::DtypeInfo::max
static constexpr dtype max() noexcept
Definition: DtypeInfo.hpp:111
nc::min
NdArray< dtype > min(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: min.hpp:46