55 template<
typename dtype>
58 return mean(inArray, inAxis);
72 template<
typename dtype>
88 weightedArray.
begin(), std::multiplies<double>());
90 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
98 if (inWeights.
size() != arrayShape.
cols)
103 double weightSum = inWeights.template astype<double>().
sum().item();
105 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
109 weightedArray.
begin(), std::multiplies<double>());
111 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
112 returnArray(0, row) =
sum / weightSum;
126 const Shape transShape = transposedArray.
shape();
127 double weightSum = inWeights.template astype<double>().
sum().item();
129 for (
uint32 row = 0; row < transShape.
rows; ++row)
133 weightedArray.
begin(), std::multiplies<double>());
135 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.0);
136 returnArray(0, row) =
sum / weightSum;
160 template<
typename dtype>
166 const auto multiplies = [](
const std::complex<dtype>& lhs, dtype rhs) -> std::complex<double>
168 return complex_cast<double>(lhs) *
static_cast<double>(rhs);
175 if (inWeights.
shape() != inArray.shape())
182 weightedArray.
begin(), multiplies);
184 std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.0));
191 const Shape arrayShape = inArray.shape();
192 if (inWeights.
size() != arrayShape.
cols)
197 double weightSum = inWeights.template astype<double>().
sum().item();
199 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
203 weightedArray.
begin(), multiplies);
205 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
206 std::complex<double>(0.0));
207 returnArray(0, row) =
sum / weightSum;
214 if (inWeights.
size() != inArray.shape().rows)
221 const Shape transShape = transposedArray.
shape();
222 double weightSum = inWeights.template astype<double>().
sum().item();
224 for (
uint32 row = 0; row < transShape.
rows; ++row)
228 weightedArray.
begin(), multiplies);
230 const std::complex<double>
sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(),
231 std::complex<double>(0.0));
232 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:4296
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1216
iterator end() noexcept
Definition: NdArrayCore.hpp:1474
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
NdArray< dtype > sum(Axis inAxis=Axis::NONE) const
Definition: NdArrayCore.hpp:4392
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4629
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
iterator begin() noexcept
Definition: NdArrayCore.hpp:1166
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:56
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:46
NdArray< double > mean(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: mean.hpp:52
std::uint32_t uint32
Definition: Types.hpp:40