50 template<
typename dtype>
59 auto sum =
static_cast<double>(
60 std::accumulate(inArray.
cbegin(),
63 [](dtype inValue1, dtype inValue2) -> dtype
64 { return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2; }));
66 const auto numberNonNan =
67 static_cast<double>(std::accumulate(inArray.
cbegin(),
70 [](dtype inValue1, dtype inValue2) -> dtype
71 { return std::isnan(inValue2) ? inValue1 : inValue1 + 1; }));
81 for (
uint32 row = 0; row < inShape.
rows; ++row)
83 auto sum =
static_cast<double>(
84 std::accumulate(inArray.
cbegin(row),
87 [](dtype inValue1, dtype inValue2) -> dtype
88 { return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2; }));
90 auto numberNonNan =
static_cast<double>(
91 std::accumulate(inArray.
cbegin(row),
94 [](dtype inValue1, dtype inValue2) -> dtype
95 { return std::isnan(inValue2) ? inValue1 : inValue1 + 1; }));
97 returnArray(0, row) =
sum / numberNonNan;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition Error.hpp:37
#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:135
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
self_type transpose() const
Definition NdArrayCore.hpp:4959
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
uint32 rows
Definition Core/shape.hpp:44
Definition Cartesian.hpp:39
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition sum.hpp:45
NdArray< double > nanmean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition nanmean.hpp:51
std::uint32_t uint32
Definition Types.hpp:40