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.0;
157 template<
typename dtype>
166 const auto inShape = inArray.shape();
167 if (inShape.rows < 2)
174 for (
uint32 col = 0; col < inShape.cols; ++col)
176 returnArray(0, col) = complex_cast<double>(inArray(1, col)) - complex_cast<double>(inArray(0, col));
177 returnArray(-1, col) =
178 complex_cast<double>(inArray(-1, col)) - complex_cast<double>(inArray(-2, col));
182 for (
uint32 col = 0; col < inShape.cols; ++col)
184 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
186 returnArray(row, col) = (complex_cast<double>(inArray(row + 1, col)) -
187 complex_cast<double>(inArray(row - 1, col))) /
196 const auto inShape = inArray.shape();
197 if (inShape.cols < 2)
204 for (
uint32 row = 0; row < inShape.rows; ++row)
206 returnArray(row, 0) = complex_cast<double>(inArray(row, 1)) - complex_cast<double>(inArray(row, 0));
207 returnArray(row, -1) =
208 complex_cast<double>(inArray(row, -1)) - complex_cast<double>(inArray(row, -2));
212 for (
uint32 row = 0; row < inShape.rows; ++row)
214 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
216 returnArray(row, col) = (complex_cast<double>(inArray(row, col + 1)) -
217 complex_cast<double>(inArray(row, col - 1))) /
227 if (inArray.size() < 2)
233 returnArray[0] = complex_cast<double>(inArray[1]) - complex_cast<double>(inArray[0]);
234 returnArray[-1] = complex_cast<double>(inArray[-1]) - complex_cast<double>(inArray[-2]);
237 inArray.cbegin() + 2,
240 returnArray.
begin() + 1,
241 [](
const std::complex<dtype>& value1,
const std::complex<dtype>& value2) -> std::complex<double>
242 { return (complex_cast<double>(value1) - complex_cast<double>(value2)) / 2.0; });
#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
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1221
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4276
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1529
iterator begin() noexcept
Definition: NdArrayCore.hpp:1171
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:784
Definition: Coordinate.hpp:45
Axis
Enum To describe an axis.
Definition: Types.hpp:47
NdArray< double > gradient(const NdArray< dtype > &inArray, Axis inAxis=Axis::ROW)
Definition: gradient.hpp:55
std::uint32_t uint32
Definition: Types.hpp:40