NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
DtypeInfo.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 
32 #include <complex>
33 #include <limits>
34 
35 namespace nc
36 {
37  //================================================================================
39  template<typename dtype>
40  class DtypeInfo
41  {
42  public:
43  //============================================================================
49  static constexpr int bits() noexcept
50  {
52 
53  return std::numeric_limits<dtype>::digits;
54  }
55 
56  //============================================================================
62  static constexpr dtype epsilon() noexcept
63  {
65 
66  return std::numeric_limits<dtype>::epsilon();
67  }
68 
69  //============================================================================
74  static constexpr bool isInteger() noexcept
75  {
77 
78  return std::numeric_limits<dtype>::is_integer;
79  }
80 
81  //============================================================================
86  static constexpr bool isSigned() noexcept
87  {
89 
90  return std::numeric_limits<dtype>::is_signed;
91  }
92 
93  //============================================================================
98  static constexpr dtype min() noexcept
99  {
101 
103  }
104 
105  //============================================================================
110  static constexpr dtype max() noexcept
111  {
113 
115  }
116  };
117 
118  //================================================================================
120  template<typename dtype>
121  class DtypeInfo<std::complex<dtype>>
122  {
123  public:
124  //============================================================================
130  static constexpr int bits() noexcept
131  {
133 
134  return std::numeric_limits<dtype>::digits;
135  }
136 
137  //============================================================================
143  static constexpr std::complex<dtype> epsilon() noexcept
144  {
146 
148  }
149 
150  //============================================================================
155  static constexpr bool isInteger() noexcept
156  {
158 
159  return std::numeric_limits<dtype>::is_integer;
160  }
161 
162  //============================================================================
167  static constexpr bool isSigned() noexcept
168  {
170 
171  return std::numeric_limits<dtype>::is_signed;
172  }
173 
174  //============================================================================
179  static constexpr std::complex<dtype> min() noexcept
180  {
182 
184  }
185 
186  //============================================================================
191  static constexpr std::complex<dtype> max() noexcept
192  {
194 
196  }
197  };
198 } // namespace nc
StaticAsserts.hpp
nc::complex
auto complex(dtype inReal)
Definition: complex.hpp:48
STATIC_ASSERT_ARITHMETIC
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
nc::DtypeInfo< std::complex< dtype > >::min
static constexpr std::complex< dtype > min() noexcept
Definition: DtypeInfo.hpp:179
nc::DtypeInfo::bits
static constexpr int bits() noexcept
Definition: DtypeInfo.hpp:49
nc::DtypeInfo< std::complex< dtype > >::isInteger
static constexpr bool isInteger() noexcept
Definition: DtypeInfo.hpp:155
nc::DtypeInfo::min
static constexpr dtype min() noexcept
Definition: DtypeInfo.hpp:98
nc::DtypeInfo< std::complex< dtype > >::epsilon
static constexpr std::complex< dtype > epsilon() noexcept
Definition: DtypeInfo.hpp:143
nc::DtypeInfo< std::complex< dtype > >::isSigned
static constexpr bool isSigned() noexcept
Definition: DtypeInfo.hpp:167
nc
Definition: Coordinate.hpp:44
nc::DtypeInfo< std::complex< dtype > >::max
static constexpr std::complex< dtype > max() noexcept
Definition: DtypeInfo.hpp:191
nc::DtypeInfo
Holds info about the dtype.
Definition: DtypeInfo.hpp:40
nc::max
NdArray< dtype > max(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: max.hpp:45
nc::DtypeInfo::epsilon
static constexpr dtype epsilon() noexcept
Definition: DtypeInfo.hpp:62
nc::DtypeInfo::isInteger
static constexpr bool isInteger() noexcept
Definition: DtypeInfo.hpp:74
nc::DtypeInfo::isSigned
static constexpr bool isSigned() noexcept
Definition: DtypeInfo.hpp:86
nc::DtypeInfo< std::complex< dtype > >::bits
static constexpr int bits() noexcept
Definition: DtypeInfo.hpp:130
nc::DtypeInfo::max
static constexpr dtype max() noexcept
Definition: DtypeInfo.hpp:110
nc::min
NdArray< dtype > min(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: min.hpp:45