50 template<
typename dtype>
61 for (
uint32 i = 0; i < inArray.
size() - 1; ++i)
63 sum +=
static_cast<double>(inArray[i + 1] - inArray[i]) / 2. +
static_cast<double>(inArray[i]);
72 for (
uint32 row = 0; row < inShape.
rows; ++row)
75 for (
uint32 col = 0; col < inShape.
cols - 1; ++col)
77 sum +=
static_cast<double>(inArray(row, col + 1) - inArray(row, col)) / 2. +
78 static_cast<double>(inArray(row, col));
81 returnArray[row] =
sum * dx;
110 template<
typename dtype>
116 if (inShapeY != inShapeX)
126 for (
uint32 i = 0; i < inArrayY.
size() - 1; ++i)
128 const auto dx =
static_cast<double>(inArrayX[i + 1] - inArrayX[i]);
130 (
static_cast<double>(inArrayY[i + 1] - inArrayY[i]) / 2. +
static_cast<double>(inArrayY[i]));
139 for (
uint32 row = 0; row < inShapeY.
rows; ++row)
142 for (
uint32 col = 0; col < inShapeY.
cols - 1; ++col)
144 const auto dx =
static_cast<double>(inArrayX(row, col + 1) - inArrayX(row, col));
145 sum += dx * (
static_cast<double>(inArrayY(row, col + 1) - inArrayY(row, col)) / 2. +
146 static_cast<double>(inArrayY(row, col)));
149 returnArray[row] =
sum;
#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:135
size_type size() const noexcept
Definition NdArrayCore.hpp:4600
self_type transpose() const
Definition NdArrayCore.hpp:4959
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4587
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:39
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< dtype > sum(const NdArray< dtype > &inArray, Axis inAxis=Axis::NONE)
Definition sum.hpp:45
NdArray< double > trapz(const NdArray< dtype > &inArray, double dx=1., Axis inAxis=Axis::NONE)
Definition trapz.hpp:51
std::uint32_t uint32
Definition Types.hpp:40