NumCpp
2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
Utils/power.hpp
Go to the documentation of this file.
1
28
#pragma once
29
30
#include "
NumCpp/Core/Internal/StaticAsserts.hpp
"
31
#include "
NumCpp/Core/Types.hpp
"
32
33
namespace
nc::utils
34
{
35
//============================================================================
43
template
<
typename
dtype>
44
dtype
power
(dtype inValue,
uint8
inPower)
noexcept
45
{
46
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
(dtype);
47
48
if
(inPower == 0)
49
{
50
return
static_cast<
dtype
>
(1);
51
}
52
53
dtype returnVal = inValue;
54
for
(
uint8
exponent = 1; exponent < inPower; ++exponent)
55
{
56
returnVal *= inValue;
57
}
58
return
returnVal;
59
}
60
}
// namespace nc::utils
StaticAsserts.hpp
STATIC_ASSERT_ARITHMETIC_OR_COMPLEX
#define STATIC_ASSERT_ARITHMETIC_OR_COMPLEX(dtype)
Definition
StaticAsserts.hpp:56
Types.hpp
nc::utils
Definition
Utils/cube.hpp:33
nc::utils::power
dtype power(dtype inValue, uint8 inPower) noexcept
Definition
Utils/power.hpp:44
nc::uint8
std::uint8_t uint8
Definition
Types.hpp:42
include
NumCpp
Utils
power.hpp
Generated by
1.15.0