NumCpp  2.18.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
Loading...
Searching...
No Matches
Functions/powerf.hpp
Go to the documentation of this file.
1
28#pragma once
29
32#include "NumCpp/NdArray.hpp"
34
35namespace nc
36{
37 //============================================================================
38 // Method Description:
47 template<typename dtype1, typename dtype2>
48 auto powerf(dtype1 inValue, dtype2 inExponent) noexcept
49 {
50 return utils::powerf(inValue, inExponent);
51 }
52
53 //============================================================================
54 // Method Description:
63 template<typename dtype1, typename dtype2>
64 auto powerf(const NdArray<dtype1>& inArray, dtype2 inExponent)
65 {
66 NdArray<decltype(powerf(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArray.shape());
68 inArray.cend(),
69 returnArray.begin(),
70 [inExponent](dtype1 inValue) noexcept -> auto
71 { return nc::powerf(inValue, inExponent); });
72
73 return returnArray;
74 }
75
76 //============================================================================
77 // Method Description:
86 template<typename dtype1, typename dtype2>
87 auto powerf(const NdArray<dtype1>& inArray, const NdArray<dtype2>& inExponents)
88 {
89 if (inArray.shape() != inExponents.shape())
90 {
91 THROW_INVALID_ARGUMENT_ERROR("input array shapes are not consistant.");
92 }
93
94 NdArray<decltype(powerf(dtype1{ 0 }, dtype2{ 0 }))> returnArray(inArray.shape());
96 inArray.cend(),
97 inExponents.cbegin(),
98 returnArray.begin(),
99 [](dtype1 inValue, dtype2 inExponent) noexcept -> auto
100 { return nc::powerf(inValue, inExponent); });
101
102 return returnArray;
103 }
104} // namespace nc
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:135
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776
auto powerf(dtype1 inValue, const dtype2 inPower) noexcept
Definition Utils/powerf.hpp:45
Definition Cartesian.hpp:39
auto powerf(dtype1 inValue, dtype2 inExponent) noexcept
Definition Functions/powerf.hpp:48