NumCpp
2.4.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
30
#include "
NumCpp/Core/Internal/StaticAsserts.hpp
"
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
{
50
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
(dtype);
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
StaticAsserts.hpp
nc::uint8
std::uint8_t uint8
Definition:
Types.hpp:42
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition:
StaticAsserts.hpp:50
nc
Definition:
Coordinate.hpp:44
nc::utils::power
dtype power(dtype inValue, uint8 inPower) noexcept
Definition:
Utils/power.hpp:48
Types.hpp
include
NumCpp
Utils
power.hpp
Generated by
1.8.17