54 template<
typename dtype>
63 auto sum =
static_cast<double>(std::accumulate(inArray.
cbegin(), inArray.
cend(), 0.0,
64 [](dtype inValue1, dtype inValue2) -> dtype
66 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
69 const auto numberNonNan =
static_cast<double>(std::accumulate(inArray.
cbegin(), inArray.
cend(), 0.0,
70 [](dtype inValue1, dtype inValue2) -> dtype
72 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
83 for (
uint32 row = 0; row < inShape.
rows; ++row)
85 auto sum =
static_cast<double>(std::accumulate(inArray.
cbegin(row), inArray.
cend(row), 0.0,
86 [](dtype inValue1, dtype inValue2) -> dtype
88 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
91 auto numberNonNan =
static_cast<double>(std::accumulate(inArray.
cbegin(row), inArray.
cend(row), 0.0,
92 [](dtype inValue1, dtype inValue2) -> dtype
94 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
97 returnArray(0, row) =
sum / numberNonNan;
105 const Shape transShape = transposedArray.
shape();
107 for (
uint32 row = 0; row < transShape.
rows; ++row)
109 auto sum =
static_cast<double>(std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), 0.0,
110 [](dtype inValue1, dtype inValue2) -> dtype
112 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
115 auto numberNonNan =
static_cast<double>(std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), 0.0,
116 [](dtype inValue1, dtype inValue2) -> dtype
118 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
121 returnArray(0, row) =
sum / numberNonNan;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_FLOAT(dtype)
Definition: StaticAsserts.hpp:43
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1270
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4483
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4830
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1614
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
Definition: Coordinate.hpp:45
Axis
Enum To describe an axis.
Definition: Types.hpp:46
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:47
NdArray< double > nanmean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nanmean.hpp:55
std::uint32_t uint32
Definition: Types.hpp:40