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)
176 returnArray(-1, col) =
181 for (
uint32 col = 0; col < inShape.cols; ++col)
183 for (
uint32 row = 1; row < inShape.rows - 1; ++row)
195 const auto inShape = inArray.shape();
196 if (inShape.cols < 2)
203 for (
uint32 row = 0; row < inShape.rows; ++row)
206 returnArray(row, -1) =
211 for (
uint32 row = 0; row < inShape.rows; ++row)
213 for (
uint32 col = 1; col < inShape.cols - 1; ++col)
226 if (inArray.size() < 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
Holds 1D and 2D arrays, the main work horse of the NumCpp library.
Definition NdArrayCore.hpp:139
size_type size() const noexcept
Definition NdArrayCore.hpp:4604
const_iterator cbegin() const noexcept
Definition NdArrayCore.hpp:1365
const Shape & shape() const noexcept
Definition NdArrayCore.hpp:4591
const_iterator cend() const noexcept
Definition NdArrayCore.hpp:1673
OutputIt transform(InputIt first, InputIt last, OutputIt destination, UnaryOperation unaryFunction)
Definition StlAlgorithms.hpp:776
Definition Cartesian.hpp:40
Axis
Enum To describe an axis.
Definition Enums.hpp:36
@ ROW
Definition Enums.hpp:38
@ COL
Definition Enums.hpp:39
std::complex< Out > complex_cast(const std::complex< In > &value) noexcept
Definition StdComplexOperators.hpp:112
NdArray< double > gradient(const NdArray< dtype > &inArray, Axis inAxis=Axis::ROW)
Definition gradient.hpp:55
std::uint32_t uint32
Definition Types.hpp:40