52 template<
typename dtype>
63 for (
uint32 row = 0; row < inShape.
rows; ++row)
66 for (
uint32 col = 0; col < inShape.
cols - 1; ++col)
68 sum +=
static_cast<double>(inArray(row, col + 1) - inArray(row, col)) / 2.0 +
69 static_cast<double>(inArray(row, col));
72 returnArray[row] =
sum * dx;
80 const Shape transShape = arrayTranspose.
shape();
82 for (
uint32 row = 0; row < transShape.
rows; ++row)
85 for (
uint32 col = 0; col < transShape.
cols - 1; ++col)
87 sum +=
static_cast<double>(arrayTranspose(row, col + 1) - arrayTranspose(row, col)) / 2.0 +
88 static_cast<double>(arrayTranspose(row, col));
91 returnArray[row] =
sum * dx;
99 for (
uint32 i = 0; i < inArray.
size() - 1; ++i)
101 sum +=
static_cast<double>(inArray[i + 1] - inArray[i]) / 2.0 +
static_cast<double>(inArray[i]);
127 template<
typename dtype>
133 if (inShapeY != inShapeX)
143 for (
uint32 row = 0; row < inShapeY.
rows; ++row)
146 for (
uint32 col = 0; col < inShapeY.
cols - 1; ++col)
148 const auto dx =
static_cast<double>(inArrayX(row, col + 1) - inArrayX(row, col));
149 sum += dx * (
static_cast<double>(inArrayY(row, col + 1) - inArrayY(row, col)) / 2.0 +
150 static_cast<double>(inArrayY(row, col)));
153 returnArray[row] =
sum;
162 const Shape transShape = arrayYTranspose.
shape();
164 for (
uint32 row = 0; row < transShape.
rows; ++row)
167 for (
uint32 col = 0; col < transShape.
cols - 1; ++col)
169 const auto dx =
static_cast<double>(arrayXTranspose(row, col + 1) - arrayXTranspose(row, col));
171 dx * (
static_cast<double>(arrayYTranspose(row, col + 1) - arrayYTranspose(row, col)) / 2.0 +
172 static_cast<double>(arrayYTranspose(row, col)));
175 returnArray[row] =
sum;
183 for (
uint32 i = 0; i < inArrayY.
size() - 1; ++i)
185 const auto dx =
static_cast<double>(inArrayX[i + 1] - inArrayX[i]);
186 sum += dx * (
static_cast<double>(inArrayY[i + 1] - inArrayY[i]) / 2.0 +
187 static_cast<double>(inArrayY[i]));
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
size_type size() const noexcept
Definition: NdArrayCore.hpp:4289
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4276
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4650
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: Coordinate.hpp:45
Axis
Enum To describe an axis.
Definition: Types.hpp:47
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.0, Axis inAxis=Axis::NONE)
Definition: trapz.hpp:53
std::uint32_t uint32
Definition: Types.hpp:40