46 template<
typename dtype>
58 double rowCenter = 0.;
59 double colCenter = 0.;
65 const auto pixelValue =
static_cast<double>(inArray(row, col));
68 rowCenter += pixelValue *
static_cast<double>(row);
69 colCenter += pixelValue *
static_cast<double>(col);
76 return { rowCenter, colCenter };
85 for (
uint32 colIdx = 0; colIdx <
shape.cols; ++colIdx)
87 for (
uint32 rowIdx = 0; rowIdx <
shape.rows; ++rowIdx)
89 returnArray(0, colIdx) +=
90 static_cast<double>(inArray(rowIdx, colIdx)) *
static_cast<double>(rowIdx);
93 returnArray(0, colIdx) /= inten[colIdx];
105 for (
uint32 rowIdx = 0; rowIdx <
shape.rows; ++rowIdx)
107 for (
uint32 colIdx = 0; colIdx <
shape.cols; ++colIdx)
109 returnArray(0, rowIdx) +=
110 static_cast<double>(inArray(rowIdx, colIdx)) *
static_cast<double>(colIdx);
113 returnArray(0, rowIdx) /= inten[rowIdx];
#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
self_type & zeros() noexcept
Definition NdArrayCore.hpp:4981
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4591
self_type sum(Axis inAxis=Axis::NONE) const
Definition NdArrayCore.hpp:4698
A Shape Class for NdArrays.
Definition Core/shape.hpp:41
Definition Cartesian.hpp:40
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
NdArray< double > centerOfMass(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition centerOfMass.hpp:47
Shape shape(const NdArray< dtype > &inArray) noexcept
Definition Functions/shape.hpp:42
NdArray< dtypeOut > astype(const NdArray< dtype > inArray)
Definition astype.hpp:45
std::uint32_t uint32
Definition Types.hpp:40