Struct np.GradientResult
- Namespace
- NumSharp
- Assembly
- NumSharp.dll
The result of gradient(NDArray, object, int?, int): NumPy returns a
single ndarray when the gradient is taken along ONE axis and a tuple of ndarrays
(one per axis) otherwise. C# cannot pick a return type from a runtime count, so this
value stands in for both — it converts implicitly to NDArray (valid only
for the single-axis result), to NDArray[] (always),
Deconstructs (var (gy, gx) = np.gradient(a);) and indexes ([k]).
public readonly struct np.GradientResult : INDArrayCarrier
- Implements
- Inherited Members
Properties
IsSingle
True when the gradient was taken along a single axis — NumPy returns a bare ndarray then (convertible via the implicit NDArray cast), and a tuple otherwise.
public bool IsSingle { get; }
Property Value
this[int]
The gradient component along the k-th requested axis.
public NDArray this[int index] { get; }
Parameters
indexint
Property Value
Length
Number of gradient components (one per requested axis).
public int Length { get; }
Property Value
Methods
Deconstruct(out NDArray, out NDArray)
Deconstructs a two-component result: var (gy, gx) = np.gradient(a);
public void Deconstruct(out NDArray item1, out NDArray item2)
Parameters
Deconstruct(out NDArray, out NDArray, out NDArray)
Deconstructs a three-component result.
public void Deconstruct(out NDArray item1, out NDArray item2, out NDArray item3)
Parameters
ToArray()
Returns the gradient components as an NDArray[].
public NDArray[] ToArray()
Returns
- NDArray[]
Operators
implicit operator NDArray(GradientResult)
The single-axis gradient. Matches NumPy's bare-ndarray return, valid only when exactly one axis was requested; otherwise throws (use the array conversion).
public static implicit operator NDArray(np.GradientResult result)
Parameters
resultnp.GradientResult
Returns
implicit operator NDArray[](GradientResult)
Exposes all gradient components — the tuple NumPy's gradient returns.
public static implicit operator NDArray[](np.GradientResult result)
Parameters
resultnp.GradientResult
Returns
- NDArray[]