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) =
static_cast<double>(inArray(-1, col)) -
static_cast<double>(inArray(-2, col));
78 for (
uint32 col = 0; col < inShape.cols; ++col)
80 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
82 returnArray(row, col) = (
static_cast<double>(inArray(row + 1, col)) -
static_cast<double>(inArray(row - 1, col))) / 2.0;
90 const auto inShape = inArray.
shape();
98 for (
uint32 row = 0; row < inShape.rows; ++row)
100 returnArray(row, 0) =
static_cast<double>(inArray(row, 1)) -
static_cast<double>(inArray(row, 0));
101 returnArray(row, -1) =
static_cast<double>(inArray(row, -1)) -
static_cast<double>(inArray(row, -2));
105 for (
uint32 row = 0; row < inShape.rows; ++row)
107 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
109 returnArray(row, col) = (
static_cast<double>(inArray(row, col + 1)) -
static_cast<double>(inArray(row, col - 1))) / 2.0;
118 if (inArray.
size() < 2)
124 returnArray[0] =
static_cast<double>(inArray[1]) -
static_cast<double>(inArray[0]);
125 returnArray[-1] =
static_cast<double>(inArray[-1]) -
static_cast<double>(inArray[-2]);
128 [](dtype value1, dtype value2) ->
double
130 return (static_cast<double>(value1) - static_cast<double>(value2)) / 2.0;
149 template<
typename dtype>
158 const auto inShape = inArray.shape();
159 if (inShape.rows < 2)
166 for (
uint32 col = 0; col < inShape.cols; ++col)
168 returnArray(0, col) = complex_cast<double>(inArray(1, col)) - complex_cast<double>(inArray(0, col));
169 returnArray(-1, col) = complex_cast<double>(inArray(-1, col)) - complex_cast<double>(inArray(-2, col));
173 for (
uint32 col = 0; col < inShape.cols; ++col)
175 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
177 returnArray(row, col) = (complex_cast<double>(inArray(row + 1, col)) -
178 complex_cast<double>(inArray(row - 1, col))) / 2.0;
186 const auto inShape = inArray.shape();
187 if (inShape.cols < 2)
194 for (
uint32 row = 0; row < inShape.rows; ++row)
196 returnArray(row, 0) = complex_cast<double>(inArray(row, 1)) - complex_cast<double>(inArray(row, 0));
197 returnArray(row, -1) = complex_cast<double>(inArray(row, -1)) - complex_cast<double>(inArray(row, -2));
201 for (
uint32 row = 0; row < inShape.rows; ++row)
203 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
205 returnArray(row, col) = (complex_cast<double>(inArray(row, col + 1)) -
206 complex_cast<double>(inArray(row, col - 1))) / 2.0;
215 if (inArray.size() < 2)
221 returnArray[0] = complex_cast<double>(inArray[1]) - complex_cast<double>(inArray[0]);
222 returnArray[-1] = complex_cast<double>(inArray[-1]) - complex_cast<double>(inArray[-2]);
225 [](
const std::complex<dtype>& value1,
const std::complex<dtype>& value2) -> std::complex<double>
227 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:4296
const_iterator cbegin() const noexcept
Definition: NdArrayCore.hpp:1216
Shape shape() const noexcept
Definition: NdArrayCore.hpp:4283
const_iterator cend() const noexcept
Definition: NdArrayCore.hpp:1524
iterator begin() noexcept
Definition: NdArrayCore.hpp:1166
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition: StlAlgorithms.hpp:702
Definition: Coordinate.hpp:45
Axis
Enum To describe an axis.
Definition: Types.hpp:46
NdArray< double > gradient(const NdArray< dtype > &inArray, Axis inAxis=Axis::ROW)
Definition: gradient.hpp:55
std::uint32_t uint32
Definition: Types.hpp:40