55 template<
typename dtype>
58 return mean(inArray, inAxis);
72 template<
typename dtype>
90 weightedArray.
begin(),
91 std::multiplies<double>());
93 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.);
101 if (inWeights.
size() != arrayShape.
cols)
106 double weightSum = inWeights.template astype<double>().
sum().
item();
108 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
114 weightedArray.
begin(),
115 std::multiplies<double>());
117 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.);
118 returnArray(0, row) =
sum / weightSum;
146 template<
typename dtype>
147 NdArray<std::complex<double>>
152 const auto multiplies = [](
const std::complex<dtype>& lhs, dtype rhs) -> std::complex<double>
153 {
return complex_cast<double>(lhs) *
static_cast<double>(rhs); };
159 if (inWeights.
shape() != inArray.shape())
168 weightedArray.
begin(),
171 std::complex<double>
sum =
172 std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.));
179 const Shape arrayShape = inArray.shape();
180 if (inWeights.
size() != arrayShape.
cols)
185 double weightSum = inWeights.template astype<double>().
sum().
item();
187 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
193 weightedArray.
begin(),
196 const std::complex<double>
sum =
197 std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.));
198 returnArray(0, row) =
sum / weightSum;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:139
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
iterator end() noexcept
Definition: NdArrayCore.hpp:1623
self_type transpose() const
Definition: NdArrayCore.hpp:4882
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
value_type item() const
Definition: NdArrayCore.hpp:3022
self_type sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4618
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
Definition: Cartesian.hpp:40
NdArray< double > mean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: mean.hpp:52
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
auto average(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: average.hpp:56
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:46
std::uint32_t uint32
Definition: Types.hpp:40