NumCpp  2.7.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Utils/power.hpp
Go to the documentation of this file.
1 #pragma once
29 
31 #include "NumCpp/Core/Types.hpp"
32 
33 #include<complex>
34 
35 namespace nc
36 {
37  namespace utils
38  {
39  //============================================================================
47  template<typename dtype>
48  dtype power(dtype inValue, uint8 inPower) noexcept
49  {
51 
52  if (inPower == 0)
53  {
54  return static_cast<dtype>(1);
55  }
56 
57  dtype returnVal = inValue;
58  for (uint8 exponent = 1; exponent < inPower; ++exponent)
59  {
60  returnVal *= inValue;
61  }
62  return returnVal;
63  }
64  } // namespace utils
65 } // namespace nc
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition: StaticAsserts.hpp:50
dtype power(dtype inValue, uint8 inPower) noexcept
Definition: Utils/power.hpp:48
Definition: Coordinate.hpp:45
std::uint8_t uint8
Definition: Types.hpp:42