rgpycrumbs.surfaces._kernels

Kernel functions for Gaussian process surface fitting.

Provides element-wise and matrix kernel functions for Matern 5/2, inverse multiquadric (IMQ), squared exponential (SE), rational quadratic (RQ), and thin-plate spline (TPS) kernels. Each kernel family includes a full_covariance_* function that builds the gradient-enhanced covariance block [[k, dk/dx2], [dk/dx1, d2k/dx1dx2]] via JAX automatic differentiation.

Added in version 1.0.0.

Attributes

Functions

_tps_kernel_matrix(x)

Compute the thin-plate spline kernel matrix.

_matern_kernel_matrix(x, length_scale)

Compute the Matern 5/2 kernel matrix.

matern_kernel_elem(x1, x2[, length_scale])

Evaluate the Matern 5/2 kernel for a single pair of points.

full_covariance_matern(x1, x2, length_scale)

Build the gradient-enhanced covariance block for the Matern 5/2 kernel.

_imq_kernel_matrix(x, epsilon)

Compute the inverse multiquadric (IMQ) kernel matrix.

imq_kernel_elem(x1, x2[, epsilon])

Evaluate the IMQ kernel for a single pair of points.

full_covariance_imq(x1, x2, epsilon)

Build the gradient-enhanced covariance block for the IMQ kernel.

se_kernel_elem(x1, x2[, length_scale])

Evaluate the squared exponential (SE) kernel for a single pair of points.

full_covariance_se(x1, x2, length_scale)

Build the gradient-enhanced covariance block for the SE kernel.

rq_kernel_base(x1, x2, length_scale, alpha)

Evaluate the rational quadratic (RQ) base kernel.

rq_kernel_elem(x1, x2, params)

Evaluate the RQ kernel with mirror symmetry for a single pair.

full_covariance_rq(x1, x2, params)

Build the gradient-enhanced covariance block for the RQ kernel.

Module Contents

rgpycrumbs.surfaces._kernels._tps_kernel_matrix(x)[source]

Compute the thin-plate spline kernel matrix.

Evaluates K_{ij} = r_{ij}^2 * log(r_{ij}) where r_{ij} is the Euclidean distance between points x_i and x_j.

Args:

x: Input points, shape (N, D).

Returns:

Kernel matrix, shape (N, N).

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels._matern_kernel_matrix(x, length_scale)[source]

Compute the Matern 5/2 kernel matrix.

Evaluates k(r) = (1 + sqrt(5)*r/l + 5*r^2/(3*l^2)) * exp(-sqrt(5)*r/l).

Args:

x: Input points, shape (N, D). length_scale: Kernel length scale parameter.

Returns:

Kernel matrix, shape (N, N).

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels.matern_kernel_elem(x1, x2, length_scale=1.0)[source]

Evaluate the Matern 5/2 kernel for a single pair of points.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). length_scale: Kernel length scale parameter.

Returns:

Scalar kernel value.

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels.full_covariance_matern(x1, x2, length_scale)[source]

Build the gradient-enhanced covariance block for the Matern 5/2 kernel.

Constructs a (D+1, D+1) matrix containing the energy-energy, energy-gradient, gradient-energy, and gradient-gradient covariance entries using JAX automatic differentiation.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). length_scale: Kernel length scale parameter.

Returns:

Covariance block, shape (D+1, D+1).

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.k_matrix_matern_grad_map[source]
rgpycrumbs.surfaces._kernels._imq_kernel_matrix(x, epsilon)[source]

Compute the inverse multiquadric (IMQ) kernel matrix.

Evaluates k(r) = 1 / sqrt(r^2 + epsilon^2).

Args:

x: Input points, shape (N, D). epsilon: Shape parameter controlling kernel width.

Returns:

Kernel matrix, shape (N, N).

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels.imq_kernel_elem(x1, x2, epsilon=1.0)[source]

Evaluate the IMQ kernel for a single pair of points.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). epsilon: Shape parameter controlling kernel width.

Returns:

Scalar kernel value.

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels.full_covariance_imq(x1, x2, epsilon)[source]

Build the gradient-enhanced covariance block for the IMQ kernel.

Constructs a (D+1, D+1) matrix containing energy-energy, energy-gradient, gradient-energy, and gradient-gradient covariance entries.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). epsilon: Shape parameter controlling kernel width.

Returns:

Covariance block, shape (D+1, D+1).

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.k_matrix_imq_grad_map[source]
rgpycrumbs.surfaces._kernels.se_kernel_elem(x1, x2, length_scale=1.0)[source]

Evaluate the squared exponential (SE) kernel for a single pair of points.

Computes k(r) = exp(-r^2 / (2 * l^2)).

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). length_scale: Kernel length scale parameter.

Returns:

Scalar kernel value.

Added in version 1.0.0.

rgpycrumbs.surfaces._kernels.full_covariance_se(x1, x2, length_scale)[source]

Build the gradient-enhanced covariance block for the SE kernel.

Constructs a (D+1, D+1) matrix containing energy-energy, energy-gradient, gradient-energy, and gradient-gradient covariance entries.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). length_scale: Kernel length scale parameter.

Returns:

Covariance block, shape (D+1, D+1).

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.k_matrix_se_grad_map[source]
rgpycrumbs.surfaces._kernels.rq_kernel_base(x1, x2, length_scale, alpha)[source]

Evaluate the rational quadratic (RQ) base kernel.

Computes k(r) = (1 + r^2 / (2 * alpha * l^2))^(-alpha).

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). length_scale: Kernel length scale parameter. alpha: Shape parameter controlling the mixture of length scales.

Returns:

Scalar kernel value.

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.rq_kernel_elem(x1, x2, params)[source]

Evaluate the RQ kernel with mirror symmetry for a single pair.

Computes k(x1, x2) + k(flip(x1), x2) to enforce symmetry under coordinate reversal.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). params: Array of [length_scale, alpha].

Returns:

Scalar kernel value (sum of direct and mirrored terms).

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.full_covariance_rq(x1, x2, params)[source]

Build the gradient-enhanced covariance block for the RQ kernel.

Constructs a (D+1, D+1) matrix containing energy-energy, energy-gradient, gradient-energy, and gradient-gradient covariance entries.

Args:

x1: First point, shape (D,). x2: Second point, shape (D,). params: Array of [length_scale, alpha].

Returns:

Covariance block, shape (D+1, D+1).

Added in version 1.1.0.

rgpycrumbs.surfaces._kernels.k_matrix_rq_grad_map[source]