53 template<
typename dtype>
64 for (
uint32 row = 0; row < inShape.
rows; ++row)
67 for (
uint32 col = 0; col < inShape.
cols - 1; ++col)
69 sum +=
static_cast<double>(inArray(row, col + 1) - inArray(row, col)) / 2.0 +
70 static_cast<double>(inArray(row, col));
73 returnArray[row] =
sum * dx;
81 const Shape transShape = arrayTranspose.
shape();
83 for (
uint32 row = 0; row < transShape.
rows; ++row)
86 for (
uint32 col = 0; col < transShape.
cols - 1; ++col)
88 sum +=
static_cast<double>(arrayTranspose(row, col + 1) - arrayTranspose(row, col)) / 2.0 +
89 static_cast<double>(arrayTranspose(row, col));
92 returnArray[row] =
sum * dx;
100 for (
uint32 i = 0; i < inArray.
size() - 1; ++i)
102 sum +=
static_cast<double>(inArray[i + 1] - inArray[i]) / 2.0 +
static_cast<double>(inArray[i]);
129 template<
typename dtype>
135 if (inShapeY != inShapeX)
145 for (
uint32 row = 0; row < inShapeY.
rows; ++row)
148 for (
uint32 col = 0; col < inShapeY.
cols - 1; ++col)
150 const auto dx =
static_cast<double>(inArrayX(row, col + 1) - inArrayX(row, col));
151 sum += dx * (
static_cast<double>(inArrayY(row, col + 1) - inArrayY(row, col)) / 2.0 +
152 static_cast<double>(inArrayY(row, col)));
155 returnArray[row] =
sum;
164 const Shape transShape = arrayYTranspose.
shape();
166 for (
uint32 row = 0; row < transShape.
rows; ++row)
169 for (
uint32 col = 0; col < transShape.
cols - 1; ++col)
171 const auto dx =
static_cast<double>(arrayXTranspose(row, col + 1) - arrayXTranspose(row, col));
172 sum += dx * (
static_cast<double>(arrayYTranspose(row, col + 1) - arrayYTranspose(row, col)) / 2.0 +
173 static_cast<double>(arrayYTranspose(row, col)));
176 returnArray[row] =
sum;
184 for (
uint32 i = 0; i < inArrayY.
size() - 1; ++i)
186 const auto dx =
static_cast<double>(inArrayX[i + 1] - inArrayX[i]);
187 sum += dx * (
static_cast<double>(inArrayY[i + 1] - inArrayY[i]) / 2.0 +
static_cast<double>(inArrayY[i]));
#define THROW_INVALID_ARGUMENT_ERROR(msg)
Definition: Error.hpp:36
#define STATIC_ASSERT_ARITHMETIC(dtype)
Definition: StaticAsserts.hpp:37
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition: NdArrayCore.hpp:72
size_type size() const noexcept
Definition: NdArrayCore.hpp:4497
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4483
NdArray< dtype > transpose() const
Definition: NdArrayCore.hpp:4841
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:46
NdArray< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition: sum.hpp:47
NdArray< double > trapz(const NdArray< dtype > &inArray, double dx=1.0, Axis inAxis=Axis::NONE)
Definition: trapz.hpp:54
std::uint32_t uint32
Definition: Types.hpp:40