54 template<
typename dtype>
63 const auto inShape = inArray.
shape();
71 for (
uint32 col = 0; col < inShape.cols; ++col)
73 returnArray(0, col) =
static_cast<double>(inArray(1, col)) -
static_cast<double>(inArray(0, col));
74 returnArray(-1, col) =
75 static_cast<double>(inArray(-1, col)) -
static_cast<double>(inArray(-2, col));
79 for (
uint32 col = 0; col < inShape.cols; ++col)
81 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
83 returnArray(row, col) =
84 (
static_cast<double>(inArray(row + 1, col)) -
static_cast<double>(inArray(row - 1, col))) /
93 const auto inShape = inArray.
shape();
101 for (
uint32 row = 0; row < inShape.rows; ++row)
103 returnArray(row, 0) =
static_cast<double>(inArray(row, 1)) -
static_cast<double>(inArray(row, 0));
104 returnArray(row, -1) =
105 static_cast<double>(inArray(row, -1)) -
static_cast<double>(inArray(row, -2));
109 for (
uint32 row = 0; row < inShape.rows; ++row)
111 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
113 returnArray(row, col) =
114 (
static_cast<double>(inArray(row, col + 1)) -
static_cast<double>(inArray(row, col - 1))) /
124 if (inArray.
size() < 2)
130 returnArray[0] =
static_cast<double>(inArray[1]) -
static_cast<double>(inArray[0]);
131 returnArray[-1] =
static_cast<double>(inArray[-1]) -
static_cast<double>(inArray[-2]);
136 returnArray.begin() + 1,
137 [](dtype value1, dtype value2) ->
double
138 { return (static_cast<double>(value1) - static_cast<double>(value2)) / 2.; });
156 template<
typename dtype>
165 const auto inShape = inArray.shape();
166 if (inShape.rows < 2)
173 for (
uint32 col = 0; col < inShape.cols; ++col)
175 returnArray(0, col) = complex_cast<double>(inArray(1, col)) - complex_cast<double>(inArray(0, col));
176 returnArray(-1, col) =
177 complex_cast<double>(inArray(-1, col)) - complex_cast<double>(inArray(-2, col));
181 for (
uint32 col = 0; col < inShape.cols; ++col)
183 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
185 returnArray(row, col) = (complex_cast<double>(inArray(row + 1, col)) -
186 complex_cast<double>(inArray(row - 1, col))) /
195 const auto inShape = inArray.shape();
196 if (inShape.cols < 2)
203 for (
uint32 row = 0; row < inShape.rows; ++row)
205 returnArray(row, 0) = complex_cast<double>(inArray(row, 1)) - complex_cast<double>(inArray(row, 0));
206 returnArray(row, -1) =
207 complex_cast<double>(inArray(row, -1)) - complex_cast<double>(inArray(row, -2));
211 for (
uint32 row = 0; row < inShape.rows; ++row)
213 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
215 returnArray(row, col) = (complex_cast<double>(inArray(row, col + 1)) -
216 complex_cast<double>(inArray(row, col - 1))) /
226 if (inArray.size() < 2)
232 returnArray[0] = complex_cast<double>(inArray[1]) - complex_cast<double>(inArray[0]);
233 returnArray[-1] = complex_cast<double>(inArray[-1]) - complex_cast<double>(inArray[-2]);
236 inArray.cbegin() + 2,
239 returnArray.
begin() + 1,
240 [](
const std::complex<dtype>& value1,
const std::complex<dtype>& value2) -> std::complex<double>
241 { return (complex_cast<double>(value1) - complex_cast<double>(value2)) / 2.; });
#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
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1365
const Shape & shape() const noexcept
Definition: NdArrayCore.hpp:4511
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1673
iterator begin() noexcept
Definition: NdArrayCore.hpp:1315
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:775
Definition: Cartesian.hpp:40
Axis
Enum To describe an axis.
Definition: Enums.hpp:36
NdArray< double > gradient(const NdArray< dtype > &inArray, Axis inAxis=Axis::ROW)
Definition: gradient.hpp:55
std::uint32_t uint32
Definition: Types.hpp:40