56 template<
typename dtype>
59 return mean(inArray, inAxis);
74 template<
typename dtype>
90 weightedArray.
begin(), std::multiplies<double>());
92 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
100 if (inWeights.
size() != arrayShape.
cols)
105 double weightSum = inWeights.template astype<double>().
sum().item();
107 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
111 weightedArray.
begin(), std::multiplies<double>());
113 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
114 returnArray(0, row) =
sum / weightSum;
128 const Shape transShape = transposedArray.
shape();
129 double weightSum = inWeights.template astype<double>().
sum().item();
131 for (
uint32 row = 0; row < transShape.
rows; ++row)
135 weightedArray.
begin(), std::multiplies<double>());
137 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
138 returnArray(0, row) =
sum / weightSum;
163 template<
typename dtype>
169 const auto multiplies = [](
const std::complex<dtype>& lhs, dtype rhs) -> std::complex<double>
171 return complex_cast<double>(lhs) *
static_cast<double>(rhs);
178 if (inWeights.
shape() != inArray.shape())
185 weightedArray.
begin(), multiplies);
187 std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.0));
194 const Shape arrayShape = inArray.shape();
195 if (inWeights.
size() != arrayShape.
cols)
200 double weightSum = inWeights.template astype<double>().
sum().item();
202 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
206 weightedArray.
begin(), multiplies);
208 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
209 std::complex<double>(0.0));
210 returnArray(0, row) =
sum / weightSum;
217 if (inWeights.
size() != inArray.shape().rows)
224 const Shape transShape = transposedArray.
shape();
225 double weightSum = inWeights.template astype<double>().
sum().item();
227 for (
uint32 row = 0; row < transShape.
rows; ++row)
231 weightedArray.
begin(), multiplies);
233 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
234 std::complex<double>(0.0));
235 returnArray(0, row) =
sum / weightSum;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
size_type size() const noexcept
Definition: NdArrayCore.hpp:4497
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1270
iterator end() noexcept
Definition: NdArrayCore.hpp:1558
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4483
NdArray< dtype > sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4598
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4830
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1614
iterator begin() noexcept
Definition: NdArrayCore.hpp:1214
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:702
Definition: Coordinate.hpp:45
Axis
Enum To describe an axis.
Definition: Types.hpp:46
auto average(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: average.hpp:57
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:47
NdArray< double > mean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: mean.hpp:53
std::uint32_t uint32
Definition: Types.hpp:40