GridSurface Class

Abstract base class for grid-based interpolation surfaces on rectilinear N-dimensional grids.

Definition

Namespace: Numerics.NET.Curves.Surfaces
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.1.0
C#
public abstract class GridSurface : Surface
Inheritance
Object  →  Surface  →  GridSurface
Derived

Remarks

The GridSurface class performs interpolation on rectilinear grids where each axis has its own coordinate vector. Grid points are defined by the Cartesian product of these axis coordinates, and function values are stored in row-major order.

A rectilinear grid (also called a product grid) consists of independent coordinate vectors for each dimension. Unlike regular grids, rectilinear grids allow non-uniform spacing along each axis while maintaining axis-aligned structure.

Interpolation methods:

  • Nearest-neighbor (CreateNearest): Returns the value at the closest grid point. Fast but discontinuous.
  • Linear (multilinear) (CreateLinear): Performs bilinear (2D), trilinear (3D), or multilinear (N-D) interpolation within each grid cell. Continuous but with discontinuous first derivatives at cell boundaries.
  • Cubic spline (CreateCubic): Uses specialized 2D/3D cubic surfaces based on CubicSpline with full CubicSplineKind options. Available only for 2D and 3D grids.
  • Tensor-product splines (CreateCubicTensorSpline, CreateTensorSpline): Uses N-dimensional tensor-product interpolation with pluggable 1D spline kernels (ISplineKernel1D). Works for any dimension and supports custom kernels via SplineKernels.

Array dimension order: Values are stored in row-major (C-style) order where the last dimension varies fastest. For 2D grids: values[i, j] = f(xAxis[i], yAxis[j]). For 3D grids: values[i, j, k] = f(xAxis[i], yAxis[j], zAxis[k]).

Boundary conditions and extrapolation: The class distinguishes between construction-time GridBoundaryCondition (which affects how tensor-product splines handle out-of-range samples during stencil assembly) and evaluation-time ExtrapolationMode (which controls behavior for query points outside the grid domain). Each surface has a DefaultExtrapolationMode, and evaluation methods support per-call extrapolation mode overrides.

Creating instances: Do not instantiate concrete subclasses directly. Instead, use the static factory methods on GridSurface: CreateNearest(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, ExtrapolationMode), CreateLinear(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, ExtrapolationMode), CreateCubic(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, ExtrapolationMode), CreateCubicTensorSpline(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, GridBoundaryCondition, ExtrapolationMode), and CreateTensorSpline(IReadOnlyList<IReadOnlyList<Double>>, IReadOnlyList<Double>, ISplineKernel1D, GridBoundaryCondition, ExtrapolationMode).

Properties

Dimension Gets the number of dimensions of the input space.
(Inherited from Surface)
Values Gets a read-only span containing the values of at the data points.

Methods

CreateCubic Creates a specialized cubic spline grid surface for 2D or 3D interpolation.
CreateCubicTensorSpline Creates a grid surface for N-dimensional interpolation using tensor-product cubic splines.
CreateLinear Creates a linear (multilinear) grid surface for N-dimensional interpolation.
CreateNearest Creates a nearest-neighbor grid surface for N-dimensional interpolation.
CreateTensorSpline Creates a grid surface for N-dimensional interpolation using tensor-product splines with a custom 1D spline kernel.
EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Evaluate(Double[]) Evaluates the surface at the specified point.
(Inherited from Surface)
Evaluate(IReadOnlyList<Double>) Evaluates the surface at the specified point.
(Inherited from Surface)
Evaluate(ReadOnlySpan<Double>) Evaluates the surface at the specified point.
(Overrides Surface.Evaluate(ReadOnlySpan<Double>))
Evaluate(IReadOnlyList<Vector<Double>>, Span<Double>) Evaluates the surface at multiple points specified by a list of vectors.
(Inherited from Surface)
Evaluate(ReadOnlySpan<Double>, ExtrapolationMode) Evaluates the surface at the specified point.
Evaluate(ReadOnlySpan<Vector<Double>>, Span<Double>) Evaluates the surface at multiple points specified by a read-only span of vectors.
(Inherited from Surface)
Evaluate(Int32, ReadOnlySpan2D<Double>, Span<Double>) Evaluates the surface at multiple points stored in column-major layout.
(Inherited from Surface)
EvaluateCore Evaluates the surface at the specified point.
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Gradient(Vector<Double>) Computes the gradient of the surface at the specified point.
(Inherited from Surface)
Gradient(Double, Double) Computes the gradient of a 2D surface at the specified point.
(Inherited from Surface)
Gradient(ReadOnlySpan<Double>, Span<Double>) Computes the gradient of the scalar field at the specified point.
(Overrides Surface.Gradient(ReadOnlySpan<Double>, Span<Double>))
Gradient(Vector<Double>, Vector<Double>) Computes the gradient of the surface at the specified point.
(Inherited from Surface)
Gradient(ReadOnlySpan<Double>, ExtrapolationMode, Span<Double>) 
GradientCore 
Gradients(Matrix<Double>) Computes the gradients of the surface at multiple points.
(Inherited from Surface)
Gradients(Matrix<Double>, Matrix<Double>) Computes the gradients of the surface at multiple points.
(Inherited from Surface)
Hessian Computes the Hessian matrix of the surface at the specified point.
(Inherited from Surface)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also