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