Surface.Gradient Method

Definition

Namespace: Numerics.NET.Curves.Surfaces
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0

Overload List

Gradient(Vector<Double>) Computes the gradient of the surface at the specified point.
Gradient(Double, Double) Computes the gradient of a 2D surface at the specified point.
Gradient(ReadOnlySpan<Double>, Span<Double>) Computes the gradient of the surface at the specified point.
Gradient(Vector<Double>, Vector<Double>) Computes the gradient of the surface at the specified point.

Gradient(Vector<Double>)

Computes the gradient of the surface at the specified point.
C#
public Vector<double> Gradient(
	Vector<double> point
)

Parameters

point  Vector<Double>
A vector representing the coordinates of the point.

Return Value

Vector<Double>
A new vector containing the gradient at the point.

Remarks

This is a convenience method that allocates a new vector for the result.

The length of point must equal Dimension.

Exceptions

ArgumentNullExceptionpoint is null.
ArgumentException The length of point does not equal Dimension.
NotSupportedException This surface type does not support gradient computation.

Gradient(Double, Double)

Computes the gradient of a 2D surface at the specified point.
C#
public virtual (double dx, double dy) Gradient(
	double x,
	double y
)

Parameters

x  Double
The x-coordinate.
y  Double
The y-coordinate.

Return Value

ValueTuple<Double, Double>
A tuple containing the partial derivatives (∂f/∂x, ∂f/∂y).

Remarks

This is a convenience method for 2D surfaces. It internally calls Gradient(ReadOnlySpan<Double>, Span<Double>).

This method is only applicable when Dimension equals 2.

Exceptions

InvalidOperationException The surface dimension is not 2.
NotSupportedException This surface type does not support gradient computation.

Gradient(ReadOnlySpan<Double>, Span<Double>)

Computes the gradient of the surface at the specified point.
C#
public virtual void Gradient(
	ReadOnlySpan<double> point,
	Span<double> result
)

Parameters

point  ReadOnlySpan<Double>
A read-only span representing the coordinates of the point.
result  Span<Double>
A span to receive the gradient vector.

Remarks

The gradient is a vector of partial derivatives with respect to each coordinate dimension.

The length of point must equal Dimension. The length of result must also equal Dimension.

Not all surface types support gradient computation. The default implementation throws NotSupportedException. Override this method in derived classes to provide gradient computation.

For surfaces with extrapolation modes, the gradient respects the same extrapolation behavior as Evaluate(ReadOnlySpan<Double>).

Exceptions

ArgumentException

The length of point does not equal Dimension.

-or-

The length of result does not equal Dimension.

NotSupportedException This surface type does not support gradient computation.

Gradient(Vector<Double>, Vector<Double>)

Computes the gradient of the surface at the specified point.
C#
public Vector<double> Gradient(
	Vector<double> point,
	Vector<double>? result
)

Parameters

point  Vector<Double>
A vector representing the coordinates of the point.
result  Vector<Double>
An optional vector to receive the gradient. If null, a new vector is allocated.

Return Value

Vector<Double>
A vector containing the gradient at the point.

Remarks

The length of point must equal Dimension.

If result is non-null, its length must also equal Dimension.

Exceptions

ArgumentNullExceptionpoint is null.
ArgumentException

The length of point does not equal Dimension.

-or-

result is non-null and its length does not equal Dimension.

NotSupportedException This surface type does not support gradient computation.

See Also