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)
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>
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)
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:4604
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1365
iterator end() noexcept
Definition NdArrayCore.hpp:1623
self_type transpose() const
Definition NdArrayCore.hpp:4963
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4591
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1673
iterator begin() noexcept
Definition NdArrayCore.hpp:1315
value_type item() const
Definition NdArrayCore.hpp:3102
self_type sum(Axis inAxis=Axis::NONE) const
Definition NdArrayCore.hpp:4698
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: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
@ 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:112
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< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:45
std::uint32_t uint32
Definition Types.hpp:40