51 template<
typename dtypeIn1,
typename dtypeIn2,
typename Function,
typename... AdditionalFunctionArgs>
54 const Function& function,
55 const AdditionalFunctionArgs&&... additionalFunctionArgs)
64 [&function, &additionalFunctionArgs...](
const auto& inValue1,
const auto& inValue2) -> dtypeIn1 {
65 return function(inValue1,
67 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
72 const auto value = inArray2.
item();
77 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeIn1
78 { return function(inValue, value, std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...); });
80 else if (inArray2.
isflat())
86 const auto value = inArray2[row];
91 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeIn1 {
92 return function(inValue,
94 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
102 const auto value = inArray2[col];
107 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeIn1 {
108 return function(inValue,
110 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
138 template<
typename dtypeOut,
142 typename... AdditionalFunctionArgs>
145 const Function& function,
146 const AdditionalFunctionArgs&&... additionalFunctionArgs)
150 return [&inArray1, &inArray2, &function, &additionalFunctionArgs...]
158 [&function, &additionalFunctionArgs...](
const auto& inValue1,
const auto& inValue2) -> dtypeOut {
159 return function(inValue1,
161 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
169 const auto value = inArray1.
item();
170 return [&inArray2, &value, &function, &additionalFunctionArgs...]
177 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeOut {
178 return function(inValue,
180 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
187 const auto value = inArray2.
item();
188 return [&inArray1, &value, &function, &additionalFunctionArgs...]
195 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeOut {
196 return function(inValue,
198 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
205 return [&inArray1, &inArray2, &function, &additionalFunctionArgs...]
214 for (
uint32 col = 0; col < inArray2.numCols(); ++col)
216 returnArray(row, col) =
217 function(inArray1[row],
219 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
225 for (
uint32 row = 0; row < inArray2.numRows(); ++row)
229 returnArray(row, col) =
230 function(inArray1[col],
232 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
239 else if (inArray1.
isflat())
241 return broadcaster<dtypeOut>(inArray2,
244 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
246 else if (inArray2.
isflat())
250 return [&inArray1, &inArray2, &function, &additionalFunctionArgs...]
255 const auto value = inArray2[row];
259 returnArray.
begin(row),
260 [&value, &function, &additionalFunctionArgs...](
const auto& inValue) -> dtypeOut {
261 return function(inValue,
263 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...);
271 return broadcaster<dtypeOut>(inArray1.
transpose(),
274 std::forward<AdditionalFunctionArgs>(additionalFunctionArgs)...)
#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:139
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
const_column_iterator ccolbegin() const noexcept
Definition: NdArrayCore.hpp:1442
self_type transpose() const
Definition: NdArrayCore.hpp:4882
bool isflat() const noexcept
Definition: NdArrayCore.hpp:2945
size_type numCols() const noexcept
Definition: NdArrayCore.hpp:3465
column_iterator colbegin() noexcept
Definition: NdArrayCore.hpp:1392
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
size_type numRows() const noexcept
Definition: NdArrayCore.hpp:3477
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
bool isscalar() const noexcept
Definition: NdArrayCore.hpp:2956
value_type item() const
Definition: NdArrayCore.hpp:3022
const_column_iterator ccolend() const noexcept
Definition: NdArrayCore.hpp:1827
Definition: NdArrayBroadcast.hpp:39
NdArray< dtypeIn1 > & broadcaster(NdArray< dtypeIn1 > &inArray1, const NdArray< dtypeIn2 > &inArray2, const Function &function, const AdditionalFunctionArgs &&... additionalFunctionArgs)
Definition: NdArrayBroadcast.hpp:52
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
std::uint32_t uint32
Definition: Types.hpp:40
NdArray< dtype > max(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: max.hpp:44