57 template<
typename dtype>
60 return mean(inArray, inAxis);
75 template<
typename dtype>
91 weightedArray.
begin(), std::multiplies<double>());
93 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.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)
112 weightedArray.
begin(), std::multiplies<double>());
114 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
115 returnArray(0, row) =
sum / weightSum;
129 const Shape transShape = transposedArray.
shape();
130 double weightSum = inWeights.template astype<double>().
sum().
item();
132 for (
uint32 row = 0; row < transShape.
rows; ++row)
136 weightedArray.
begin(), std::multiplies<double>());
138 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
139 returnArray(0, row) =
sum / weightSum;
165 template<
typename dtype>
171 const auto multiplies = [](
const std::complex<dtype>& lhs, dtype rhs) -> std::complex<double>
173 return complex_cast<double>(lhs) *
static_cast<double>(rhs);
180 if (inWeights.
shape() != inArray.shape())
187 weightedArray.
begin(), multiplies);
189 std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.0));
196 const Shape arrayShape = inArray.shape();
197 if (inWeights.
size() != arrayShape.
cols)
202 double weightSum = inWeights.template astype<double>().
sum().
item();
204 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
208 weightedArray.
begin(), multiplies);
210 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
211 std::complex<double>(0.0));
212 returnArray(0, row) =
sum / weightSum;
219 if (inWeights.
size() != inArray.shape().rows)
226 const Shape transShape = transposedArray.
shape();
227 double weightSum = inWeights.template astype<double>().
sum().
item();
229 for (
uint32 row = 0; row < transShape.
rows; ++row)
233 weightedArray.
begin(), multiplies);
235 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
236 std::complex<double>(0.0));
237 returnArray(0, row) =
sum / weightSum;