NumCpp  2.11.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 
30 #include <cmath>
31 
34 #include "NumCpp/Core/Types.hpp"
36 #include "NumCpp/NdArray.hpp"
37 
38 namespace nc
39 {
40  //============================================================================
41  // Method Description:
50  template<typename dtype>
52  {
53  STATIC_ASSERT_FLOAT(dtype);
54 
55  NdArray<dtype> arrayCopy(inArray);
56  stl_algorithms::for_each(arrayCopy.begin(),
57  arrayCopy.end(),
58  [](dtype& value) noexcept -> void
59  {
60  if (std::isnan(value))
61  {
62  value = dtype{ 1 };
63  };
64  });
65 
66  return cumprod(arrayCopy, inAxis);
67  }
68 } // namespace nc
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:50
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:138
iterator end() noexcept
Definition: NdArrayCore.hpp:1576
iterator begin() noexcept
Definition: NdArrayCore.hpp:1268
void for_each(InputIt first, InputIt last, UnaryFunction f)
Definition: StlAlgorithms.hpp:225
Definition: Cartesian.hpp:40
Axis
Enum To describe an axis.
Definition: Types.hpp:47
NdArray< dtype > cumprod(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: cumprod.hpp:46
NdArray< dtype > nancumprod(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nancumprod.hpp:51