NumCpp  2.4.0
A Templatized Header Only C++ Implementation of the Python NumPy Library
nancumprod.hpp
Go to the documentation of this file.
1 #pragma once
29 
32 #include "NumCpp/Core/Types.hpp"
34 #include "NumCpp/NdArray.hpp"
35 
36 #include <cmath>
37 
38 namespace nc
39 {
40  //============================================================================
41  // Method Description:
51  template<typename dtype>
53  {
54  STATIC_ASSERT_FLOAT(dtype);
55 
56  NdArray<dtype> arrayCopy(inArray);
57  stl_algorithms::for_each(arrayCopy.begin(), arrayCopy.end(),
58  [](dtype& value) noexcept -> void
59  {
60  if (std::isnan(value)) { value = dtype{ 1 }; };
61  });
62 
63  return cumprod(arrayCopy, inAxis);
64  }
65 } // namespace nc
StaticAsserts.hpp
nc::Axis::NONE
@ NONE
nc::NdArray< dtype >
nc::stl_algorithms::for_each
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:213
NdArray.hpp
STATIC_ASSERT_FLOAT
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:43
nc::NdArray::end
iterator end() noexcept
Definition: NdArrayCore.hpp:1431
nc::Axis
Axis
Enum To describe an axis.
Definition: Types.hpp:46
nc
Definition: Coordinate.hpp:44
nc::cumprod
NdArray< dtype > cumprod(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: cumprod.hpp:47
cumprod.hpp
StlAlgorithms.hpp
nc::nancumprod
NdArray< dtype > nancumprod(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nancumprod.hpp:52
Types.hpp
nc::NdArray::begin
iterator begin() noexcept
Definition: NdArrayCore.hpp:1087