54 template<
typename dtype>
57 return mean(inArray, inAxis);
71 template<
typename dtype>
89 weightedArray.
begin(),
90 std::multiplies<double>());
92 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.);
100 if (inWeights.
size() != arrayShape.
cols)
107 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
113 weightedArray.
begin(),
114 std::multiplies<double>());
116 double sum = std::accumulate(weightedArray.
begin(), weightedArray.
end(), 0.);
117 returnArray(0, row) =
sum / weightSum;
145 template<
typename dtype>
146 NdArray<std::complex<double>>
151 const auto multiplies = [](
const std::complex<dtype>& lhs, dtype rhs) -> std::complex<double>
158 if (inWeights.
shape() != inArray.shape())
167 weightedArray.
begin(),
170 std::complex<double>
sum =
171 std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.));
178 const Shape arrayShape = inArray.shape();
179 if (inWeights.
size() != arrayShape.
cols)
186 for (
uint32 row = 0; row < arrayShape.
rows; ++row)
192 weightedArray.
begin(),
195 const std::complex<double>
sum =
196 std::accumulate(weightedArray.
begin(), weightedArray.
end(), std::complex<double>(0.));
197 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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1361
iterator end() noexcept
Definition NdArrayCore.hpp:1619
self_type transpose() const
Definition NdArrayCore.hpp:4959
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1669
iterator begin() noexcept
Definition NdArrayCore.hpp:1311
value_type item() const
Definition NdArrayCore.hpp:3098
self_type sum(Axis inAxis=Axis::NONE) const
Definition NdArrayCore.hpp:4694
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:776
Definition Cartesian.hpp:39
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
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
@ NONE
Definition Enums.hpp:37
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition StdComplexOperators.hpp:111
auto average(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition average.hpp:55
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition sum.hpp:45
NdArray< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:43
std::uint32_t uint32
Definition Types.hpp:40