53 template<
typename dtype>
62 auto sum =
static_cast<double>(std::accumulate(inArray.
cbegin(), inArray.
cend(), 0.0,
63 [](dtype inValue1, dtype inValue2) -> dtype
65 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
68 const auto numberNonNan =
static_cast<double>(std::accumulate(inArray.
cbegin(), inArray.
cend(), 0.0,
69 [](dtype inValue1, dtype inValue2) -> dtype
71 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
82 for (
uint32 row = 0; row < inShape.
rows; ++row)
84 auto sum =
static_cast<double>(std::accumulate(inArray.
cbegin(row), inArray.
cend(row), 0.0,
85 [](dtype inValue1, dtype inValue2) -> dtype
87 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
90 auto numberNonNan =
static_cast<double>(std::accumulate(inArray.
cbegin(row), inArray.
cend(row), 0.0,
91 [](dtype inValue1, dtype inValue2) -> dtype
93 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
96 returnArray(0, row) =
sum / numberNonNan;
104 const Shape transShape = transposedArray.
shape();
106 for (
uint32 row = 0; row < transShape.
rows; ++row)
108 auto sum =
static_cast<double>(std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), 0.0,
109 [](dtype inValue1, dtype inValue2) -> dtype
111 return std::isnan(inValue2) ? inValue1 : inValue1 + inValue2;
114 auto numberNonNan =
static_cast<double>(std::accumulate(transposedArray.
cbegin(row), transposedArray.
cend(row), 0.0,
115 [](dtype inValue1, dtype inValue2) -> dtype
117 return std::isnan(inValue2) ? inValue1 : inValue1 + 1;
120 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:1216
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4629
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
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:46
NdArray< double > nanmean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: nanmean.hpp:54
std::uint32_t uint32
Definition: Types.hpp:40