52 template<
typename dtype>
63 for (
uint32 i = 0; i < inArray.
size() - 1; ++i)
65 sum +=
static_cast<double>(inArray[i + 1] - inArray[i]) / 2. +
static_cast<double>(inArray[i]);
74 for (
uint32 row = 0; row < inShape.
rows; ++row)
77 for (
uint32 col = 0; col < inShape.
cols - 1; ++col)
79 sum +=
static_cast<double>(inArray(row, col + 1) - inArray(row, col)) / 2. +
80 static_cast<double>(inArray(row, col));
83 returnArray[row] =
sum * dx;
112 template<
typename dtype>
118 if (inShapeY != inShapeX)
128 for (
uint32 i = 0; i < inArrayY.
size() - 1; ++i)
130 const auto dx =
static_cast<double>(inArrayX[i + 1] - inArrayX[i]);
132 (
static_cast<double>(inArrayY[i + 1] - inArrayY[i]) / 2. +
static_cast<double>(inArrayY[i]));
141 for (
uint32 row = 0; row < inShapeY.
rows; ++row)
144 for (
uint32 col = 0; col < inShapeY.
cols - 1; ++col)
146 const auto dx =
static_cast<double>(inArrayX(row, col + 1) - inArrayX(row, col));
147 sum += dx * (
static_cast<double>(inArrayY(row, col + 1) - inArrayY(row, col)) / 2. +
148 static_cast<double>(inArrayY(row, col)));
151 returnArray[row] =
sum;
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:37
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:39
size_type size() const noexcept
Definition: NdArrayCore.hpp:4524
self_type transpose() const
Definition: NdArrayCore.hpp:4882
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
A Shape Class for NdArrays.
Definition: Core/Shape.hpp:41
uint32 rows
Definition: Core/Shape.hpp:44
uint32 cols
Definition: Core/Shape.hpp:45
Definition: Cartesian.hpp:40
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:46
NdArray< double > trapz(const NdArray< dtype > &inArray, double dx=1., Axis inAxis=Axis::NONE)
Definition: trapz.hpp:53
std::uint32_t uint32
Definition: Types.hpp:40