Skip to content

Macros

RadialBasisFunctions.@operator Macro
julia
@operator expr

Create an operator from mathematical notation. Returns an AbstractOperator that can be called directly with data points to build a RadialBasisOperator.

Recognized symbols

  • ∇² / ΔLaplacian

  • ∂(dim) — first partial derivative in dimension dim

  • ∂²(dim) — second partial derivative in dimension dim

  • ∂(dim1, dim2) — mixed partial derivative ∂²f/(∂xᵢ ∂xⱼ)

  • ∇ ⋅ (κ * ∇) — anisotropic diffusion (scalar or vector κ)

  • c ⋅ ∇ — advection operator (vector c)

  • f / IIdentity operator

  • Everything else — scalar coefficient

Examples

julia
helm = (@operator ∇² + k^2 * f)(x)
aniso = (@operator κx * ∂²(1) + κy * ∂²(2))(x)
advdiff = (@operator ν * ∇² - c  ∇)(x)
diff = (@operator* ∇))(x)
source

Exported Functions

RadialBasisFunctions.PHS Method
julia
function PHS(n::T=3; poly_deg::T=2) where {T<:Int}

Convienience contructor for polyharmonic splines.

Arguments

  • n: Order of the spline (1, 3, 5, or 7). Higher = smoother.

  • poly_deg: Polynomial augmentation degree (default: 2 for quadratic).

See also: IMQ, Gaussian

source
RadialBasisFunctions.classify_stencil Method
julia
classify_stencil(is_boundary, boundary_conditions, eval_idx,
                neighbors, global_to_boundary)

Classify stencil type for dispatch in kernel execution.

source
RadialBasisFunctions.curl Method
julia
curl(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a curl operator and applies it to vector field x.

For repeated evaluations on the same points, prefer creating the operator once with curl(data) and calling it via functor syntax op(x).

source
RadialBasisFunctions.curl Method
julia
curl(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the curl (∇×u).

Only defined for 2D and 3D data.

  • 2D: Returns scalar field ∂u₂/∂x₁ − ∂u₁/∂x₂

  • 3D: Returns vector field with standard curl components

Arguments

  • data: Vector of data points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
# 2D curl (scalar output)
points = [SVector{2}(rand(2)) for _ in 1:1000]
curl_op = curl(points)
u = hcat(-getindex.(points, 2), getindex.(points, 1))  # u = (-y, x)
ω = curl_op(u)  # ≈ 2.0 everywhere

# 3D curl (vector output)
points3d = [SVector{3}(rand(3)) for _ in 1:1000]
curl_op3d = curl(points3d)
u3d = hcat(-getindex.(points3d, 2), getindex.(points3d, 1), zeros(1000))
ω3d = curl_op3d(u3d)  # ≈ [0, 0, 2] everywhere

See also: divergence, gradient, jacobian

source
RadialBasisFunctions.custom Method
julia
custom(data, ℒ::Function; rank=<auto>, basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)
custom(data, op::AbstractOperator; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator with a custom operator.

Arguments

  • data: Vector of data points

  • : Custom function that accepts a basis and returns a callable (x, xᵢ) -> value

  • op: An AbstractOperator (e.g. from @operator or operator algebra)

Keyword Arguments

  • rank::Int: Tensor rank added to the output (0 = rank-preserving, 1 = rank+1). Auto-inferred when omitted: from the type parameter for AbstractOperator, or by probing the closure for Function (tuple return → rank 1, scalar → rank 0).

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
# Using @operator macro — call the operator directly with data points
op = (@operator ∇² +* f)(data)

# Custom operator that returns the basis function itself (rank-preserving)
op = custom(data, basis -> (x, xᵢ) -> basis(x, xᵢ))

# Custom second partial derivative ∂²f/∂x₁² using the ∂² functor
op = custom(data, basis -> ∂²(basis, 1))
source
RadialBasisFunctions.directional Method
julia
directional(data, v; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the directional derivative (∇f⋅v).

Arguments

  • data: Vector of data points

  • v: Direction vector. Can be:

    • A single vector of length Dim (constant direction)

    • A vector of vectors matching length(data) (spatially-varying direction)

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
# Constant direction
∂_x = directional(data, [1.0, 0.0])

# Spatially-varying direction (e.g., radial)
normals = [normalize(p) for p in data]
∂_n = directional(data, normals)

See also: gradient, partial, laplacian

source
RadialBasisFunctions.divergence Method
julia
divergence(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a divergence operator and applies it to vector field x.

For repeated evaluations on the same points, prefer creating the operator once with divergence(data) and calling it via functor syntax op(x).

source
RadialBasisFunctions.divergence Method
julia
divergence(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the divergence (∇⋅u).

Arguments

  • data: Vector of data points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
div_op = divergence(points)

# Vector field as matrix (N × D)
u = hcat(sin.(getindex.(points, 1)), cos.(getindex.(points, 2)))
div_u = div_op(u)  # Vector (N,)

See also: curl, gradient, jacobian

source
RadialBasisFunctions.gradient Method
julia
gradient(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a gradient operator and applies it to scalar field x.

For repeated evaluations, prefer creating the operator once with gradient(data).

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
u = sin.(getindex.(points, 1))
∇u = gradient(points, u)  # One-shot gradient computation
source
RadialBasisFunctions.gradient Method
julia
gradient(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for computing gradients of scalar fields.

This is a convenience alias for jacobian. The gradient of a scalar field is mathematically the Jacobian (a 1×D row vector, returned as a length-D vector per point).

Arguments

  • data: Vector of points (e.g., Vector{SVector{2,Float64}})

Keyword Arguments

  • basis: RBF basis function (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
op = gradient(points)

u = sin.(getindex.(points, 1))
∇u = op(u)  # Matrix (1000 × 2)
∂u_∂x = ∇u[:, 1]
∂u_∂y = ∇u[:, 2]

See also: jacobian

source
RadialBasisFunctions.hessian Method
julia
hessian(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a Hessian operator and applies it to field x.

source
RadialBasisFunctions.hessian Method
julia
hessian(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for computing the full Hessian matrix.

Arguments

  • data: Vector of points (e.g., Vector{SVector{2,Float64}})

Keyword Arguments

  • basis: RBF basis function (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
op = hessian(points)

# Scalar field → Hessian tensor
u = sin.(getindex.(points, 1)) .* cos.(getindex.(points, 2))
H = op(u)  # Array (1000 × 2 × 2)
# H[:, 1, 1] = ∂²u/∂x², H[:, 1, 2] = ∂²u/∂x∂y, etc.

See also: jacobian, laplacian, mixed_partial

source
RadialBasisFunctions.jacobian Method
julia
jacobian(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a Jacobian operator and applies it to field x.

For repeated evaluations on the same points, prefer creating the operator once with jacobian(data) and calling it via functor syntax op(x).

Arguments

  • data: Vector of points

  • x: Field values to differentiate

Keyword Arguments

  • basis: RBF basis function (default: PHS(3; poly_deg=2))

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
u = sin.(getindex.(points, 1))
∇u = jacobian(points, u)  # One-shot gradient computation
source
RadialBasisFunctions.jacobian Method
julia
jacobian(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for computing Jacobians (or gradients for scalar fields).

The Jacobian is the fundamental differential operator. For a scalar field, it computes the gradient. For a vector field, it computes the full Jacobian matrix. The spatial dimension is automatically inferred from the data.

Arguments

  • data: Vector of points (e.g., Vector{SVector{2,Float64}})

Keyword Arguments

  • basis: RBF basis function (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
op = jacobian(points)

# Scalar field → gradient
u = sin.(getindex.(points, 1))
∇u = op(u)  # Matrix (1000 × 2)

# Vector field → Jacobian matrix
v = hcat(u, cos.(getindex.(points, 2)))
J = op(v)  # Array (1000 × 2 × 2)

See also: gradient

source
RadialBasisFunctions.laplacian Method
julia
laplacian(data, eval_points, basis, is_boundary, boundary_conditions, normals; k, adjl)

Build a Hermite-compatible RadialBasisOperator for the Laplacian. Maintains backward compatibility with the positional argument API.

source
RadialBasisFunctions.laplacian Method
julia
laplacian(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the Laplacian operator (∇²f).

Arguments

  • data: Vector of data points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
# Basic usage
op = laplacian(data)

# With custom basis
op = laplacian(data; basis=PHS(5; poly_deg=3))

# With different evaluation points
op = laplacian(data; eval_points=eval_pts)

See also: partial, gradient, directional

source
RadialBasisFunctions.mixed_partial Method
julia
mixed_partial(data, dim1, dim2, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a mixed partial operator and applies it to field x.

source
RadialBasisFunctions.mixed_partial Method
julia
mixed_partial(data, dim1, dim2; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the mixed partial derivative ∂²f/(∂xᵢ ∂xⱼ).

Arguments

  • data: Vector of data points

  • dim1: First dimension index

  • dim2: Second dimension index

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
∂²xy = mixed_partial(data, 1, 2)

See also: partial, hessian

source
RadialBasisFunctions.normal_derivative Method
julia
normal_derivative(data, normals, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a normal derivative operator and applies it to field x.

For repeated evaluations on the same points, prefer creating the operator once with normal_derivative(data, normals) and calling it via functor syntax op(x).

source
RadialBasisFunctions.normal_derivative Method
julia
normal_derivative(data, normals; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the normal derivative (∇f⋅n̂).

The input normals are automatically normalized to unit vectors. This is a convenience wrapper around directional.

Arguments

  • data: Vector of data points

  • normals: Normal vectors at each point (will be normalized)

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
normals = [normalize(p) for p in points]  # radial normals
∂ₙ = normal_derivative(points, normals)
result = ∂ₙ(sin.(getindex.(points, 1)))

See also: directional, gradient

source
RadialBasisFunctions.partial Method
julia
partial(data, order, dim; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for a partial derivative.

Arguments

  • data: Vector of data points

  • order: Derivative order (1 or 2)

  • dim: Dimension index to differentiate

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
# First derivative in x-direction
∂x = partial(data, 1, 1)

# Second derivative in y-direction
∂²y = partial(data, 2, 2; basis=PHS(5; poly_deg=4))

See also: laplacian, gradient, directional

source
RadialBasisFunctions.regrid Method
julia
regrid(data, eval_points; basis=PHS(3; poly_deg=2), k, adjl)

Build a RadialBasisOperator for interpolating from data points to eval_points.

Arguments

  • data: Source data points

  • eval_points: Target evaluation points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

Examples

julia
# Interpolate from coarse grid to fine grid
coarse = [SVector{2}(rand(2)) for _ in 1:100]
fine = [SVector{2}(rand(2)) for _ in 1:1000]
op = regrid(coarse, fine)

# Apply to field values
u_coarse = sin.(getindex.(coarse, 1))
u_fine = op(u_coarse)

See also: Interpolator

source
RadialBasisFunctions.rotation_rate Method
julia
rotation_rate(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a rotation rate operator and applies it to vector field x.

source
RadialBasisFunctions.rotation_rate Method
julia
rotation_rate(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the anti-symmetric rotation rate tensor ωᵢⱼ = ½(∂uᵢ/∂xⱼ − ∂uⱼ/∂xᵢ).

Arguments

  • data: Vector of data points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
ω_op = rotation_rate(points)

# Solid body rotation: u = (-y, x) → ω₁₂ = -1
u = hcat(-getindex.(points, 2), getindex.(points, 1))
ω = ω_op(u)  # Array (1000 × 2 × 2), ω₁₂ ≈ -1.0

See also: strain_rate, jacobian, curl

source
RadialBasisFunctions.strain_rate Method
julia
strain_rate(data, x; basis=PHS(3; poly_deg=2), k, adjl)

One-shot convenience function that creates a strain rate operator and applies it to vector field x.

source
RadialBasisFunctions.strain_rate Method
julia
strain_rate(data; basis=PHS(3; poly_deg=2), eval_points=data, k, adjl, hermite)

Build a RadialBasisOperator for the symmetric strain rate tensor εᵢⱼ = ½(∂uᵢ/∂xⱼ + ∂uⱼ/∂xᵢ).

Arguments

  • data: Vector of data points

Keyword Arguments

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • eval_points: Evaluation points (default: data)

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation

Examples

julia
points = [SVector{2}(rand(2)) for _ in 1:1000]
ε_op = strain_rate(points)

# Vector field as matrix (N × D)
u = hcat(getindex.(points, 2), getindex.(points, 1))  # u = (y, x)
ε = ε_op(u)  # Array (1000 × 2 × 2), ε₁₂ = ε₂₁ ≈ 1.0

See also: rotation_rate, jacobian, divergence

source
RadialBasisFunctions.update_hermite_stencil_data! Method
julia
update_hermite_stencil_data!(hermite_data, global_data, neighbors,
                             is_boundary, boundary_conditions, normals,
                             global_to_boundary)

Populate local Hermite stencil data from global arrays. Used within kernels to extract boundary info for specific neighborhoods.

source
RadialBasisFunctions.∂virtual Method
julia
function ∂virtual(data, eval_points, dim, Δ, basis; k=autoselect_k(data, basis))

Builds a virtual RadialBasisOperator whichi will be evaluated at eval_points where the operator is the partial derivative with respect to dim. Virtual operators interpolate the data to structured points at a distance Δ for which standard finite difference formulas can be applied.

source
RadialBasisFunctions.∂virtual Method
julia
function ∂virtual(data, dim, Δ, basis; k=autoselect_k(data, basis))

Builds a virtual RadialBasisOperator whichi will be evaluated at the input points (data) where the operator is the partial derivative with respect to dim. Virtual operators interpolate the data to structured points at a distance Δ for which standard finite difference formulas can be applied.

source
RadialBasisFunctions.AbstractBasis Type
julia
abstract type AbstractBasis end
source
RadialBasisFunctions.AbstractOperator Type
julia
AbstractOperator{N}

Abstract supertype for differential operators.

The parameter N is the tensor rank added to the output:

Subtypes must implement (op::MyOp)(basis::AbstractBasis) to return a callable applied to the basis.

All AbstractOperator subtypes are callable with data points to construct a RadialBasisOperator:

julia
op = Laplacian()(points)
op = (@operator ∇² +* f)(points; basis=PHS(5; poly_deg=3))
source
RadialBasisFunctions.AbstractPHS Type

abstract type AbstractPHS <: AbstractRadialBasis

Supertype of all Polyharmonic Splines.

source
RadialBasisFunctions.AbstractRadialBasis Type
julia
abstract type AbstractRadialBasis <: AbstractBasis end
source
RadialBasisFunctions.BoundaryCondition Type
julia
BoundaryCondition{T}

Unified boundary condition representation: Bu = α_u + β_∂ₙu

Special cases:

  • Dirichlet: α=1, β=0

  • Neumann: α=0, β=1

  • Robin: α≠0, β≠0

  • Internal: α=0, β=0 (sentinel for interior points)

source
RadialBasisFunctions.Curl Type
julia
Curl{Dim} <: AbstractOperator{0}

Operator for the curl of a vector field (∇×u).

  • 2D: Matrix (N×2) → Vector (N): ∂u₂/∂x₁ − ∂u₁/∂x₂

  • 3D: Matrix (N×3) → Matrix (N×3): standard curl vector

Only defined for Dim ∈ {2, 3}. Weights are stored as NTuple{Dim, SparseMatrixCSC}, reusing the Jacobian weight-building infrastructure.

source
RadialBasisFunctions.Custom Type
julia
Custom{N, F<:Function} <: AbstractOperator{N}

Custom operator that applies a user-defined function to basis functions. The function should accept a basis and return a callable (x, xᵢ) -> value.

N is the tensor rank added to the output: Custom{0}(ℒ) for rank-preserving or Custom{1}(ℒ) for rank+1.

source
RadialBasisFunctions.Directional Type
julia
Directional{Dim,T} <: AbstractOperator{0}

Operator for the directional derivative (∇f⋅v), the inner product of the gradient and a direction vector.

source
RadialBasisFunctions.Divergence Type
julia
Divergence{Dim} <: AbstractOperator{0}

Operator for the divergence of a vector field (∇⋅u = ∑ᵢ ∂uᵢ/∂xᵢ).

Takes a vector field (Matrix N×D) as input and produces a scalar field (Vector N). Weights are stored as NTuple{Dim, SparseMatrixCSC}, one partial derivative matrix per spatial dimension, reusing the Jacobian weight-building infrastructure.

source
RadialBasisFunctions.Gaussian Type
julia
Gaussian=1; poly_deg=2)

Gaussian radial basis function: ϕ(r) = exp(-(εr)²)

Arguments

  • ε: Shape parameter (must be > 0). Smaller values = wider basis.

  • poly_deg: Polynomial augmentation degree (default: 2).

See also: PHS, IMQ

source
RadialBasisFunctions.HermiteStencilData Type
julia
HermiteStencilData{T}

Local stencil data for Hermite interpolation with boundary conditions.

Fields:

  • data: Coordinates of k stencil points

  • is_boundary: Boolean flags for each point

  • boundary_conditions: BC for each point (use Internal() for interior)

  • normals: Normal vectors (zero for interior points)

  • poly_workspace: Pre-allocated buffer for polynomial operations (avoids allocations in hot path)

Note: For interior points (is_boundary[i] == false), boundary_conditions[i] and normals[i] contain sentinel values and should not be accessed.

source
RadialBasisFunctions.HermiteStencilData Method

Pre-allocation constructor for HermiteStencilData

source
RadialBasisFunctions.Hessian Type
julia
Hessian{Dim} <: AbstractOperator{2}

Operator for computing the full Hessian matrix ∂²f/(∂xᵢ ∂xⱼ) at each point.

The Hessian is a rank-2 operator: it adds two trailing dimensions of size D (the spatial dimension) to the output. Only D*(D+1)/2 unique weight matrices are stored (upper-triangular entries); symmetric entries are filled via copyto!.

Input/Output Shapes

  • Scalar field Vector{T} (N,) → Hessian Array{T,3} (N_eval × D × D)

  • Vector field Matrix{T} (N × D_in) → Array{T,4} (N_eval × D_in × D × D)

source
RadialBasisFunctions.IMQ Type
julia
IMQ=1; poly_deg=2)

Inverse Multiquadric radial basis function: ϕ(r) = 1/√((εr)² + 1)

Arguments

  • ε: Shape parameter (must be > 0). Smaller values = flatter basis.

  • poly_deg: Polynomial augmentation degree (default: 2).

See also: PHS, Gaussian

source
RadialBasisFunctions.Identity Type
julia
Identity <: AbstractOperator{0}

Identity operator — returns the basis function unchanged. Useful in operator algebra to represent the function itself (e.g., Laplacian() + k² * Identity() for Helmholtz).

source
RadialBasisFunctions.Interpolator Type
julia
struct Interpolator

Construct a radial basis interpolation.

source
RadialBasisFunctions.Interpolator Method
julia
function Interpolator(x, y, basis::B=PHS())

Construct a radial basis interpolator.

See also: regrid for local stencil-based interpolation between point sets.

source
RadialBasisFunctions.Jacobian Type
julia
Jacobian{Dim} <: AbstractOperator{1}

Operator type for computing Jacobians (and gradients as a special case).

The Jacobian is the fundamental differential operator that computes all partial derivatives. When applied to a scalar field, it produces the gradient. When applied to a vector field, it produces the full Jacobian matrix.

Differentiation increases tensor rank by 1. The output gains a trailing dimension of size D (the spatial dimension).

Input/Output Shapes

  • Scalar field Vector{T} (N,) → Gradient Matrix{T} (N_eval × D)

  • Vector field Matrix{T} (N × D) → Jacobian Array{T,3} (N_eval × D × D)

  • Matrix field Array{T,3} (N × D × D) → 3-tensor Array{T,4} (N_eval × D × D × D)

  • General: input shape (N, dims...) → output shape (N_eval, dims..., D)

source
RadialBasisFunctions.Laplacian Type
julia
Laplacian <: AbstractOperator{0}

Operator for the sum of the second derivatives w.r.t. each independent variable (∇²f).

source
RadialBasisFunctions.MixedPartial Type
julia
MixedPartial{T<:Int} <: AbstractOperator{0}

Operator for the mixed second partial derivative ∂²f/(∂xᵢ ∂xⱼ). When dim1 == dim2, delegates to Partial(2, dim).

source
RadialBasisFunctions.MonomialBasis Type
julia
struct MonomialBasis{Dim,Deg} <: AbstractBasis

Dim dimensional monomial basis of order Deg.

source
RadialBasisFunctions.PHS1 Type
julia
struct PHS1{T<:Int} <: AbstractPHS

Polyharmonic spline radial basis function: 

source
RadialBasisFunctions.PHS3 Type
julia
struct PHS3{T<:Int} <: AbstractPHS

Polyharmonic spline radial basis function: 

source
RadialBasisFunctions.PHS5 Type
julia
struct PHS5{T<:Int} <: AbstractPHS

Polyharmonic spline radial basis function: 

source
RadialBasisFunctions.PHS7 Type
julia
struct PHS7{T<:Int} <: AbstractPHS

Polyharmonic spline radial basis function: 

source
RadialBasisFunctions.Partial Type
julia
Partial{T<:Int} <: AbstractOperator{0}

Operator for a partial derivative of specified order with respect to a dimension.

source
RadialBasisFunctions.RadialBasisOperator Type
julia
struct RadialBasisOperator

Operator of data using a radial basis with potential monomial augmentation.

source
RadialBasisFunctions.RadialBasisOperator Method
julia
RadialBasisOperator(ℒ, data; eval_points, basis, k, adjl, hermite, device)

Unified constructor with keyword arguments.

Arguments

  • : The operator type (e.g., Laplacian(), Partial(1, 2))

  • data: Vector of data points

Keyword Arguments

  • eval_points: Evaluation points (default: data)

  • basis: RBF basis (default: PHS(3; poly_deg=2))

  • k: Stencil size (default: autoselect_k(data, basis))

  • adjl: Adjacency list (default: computed via find_neighbors)

  • hermite: Optional NamedTuple for Hermite interpolation with fields:

    • is_boundary::Vector{Bool}

    • bc::Vector{<:BoundaryCondition}

    • normals::Vector{<:AbstractVector}

  • device: KernelAbstractions backend for weight computation (default: auto-detected from data via get_backend)

Examples

julia
# Preferred: call operator directly with data points
op = Laplacian()(data)
op = Laplacian()(data; basis=PHS(5; poly_deg=3), k=40)
op = (@operator ∇² +* f)(data)

# Explicit constructor form
op = RadialBasisOperator(Laplacian(), data)

# With different evaluation points
op = Laplacian()(data; eval_points=eval_pts)

# With Hermite boundary conditions
op = RadialBasisOperator(Laplacian(), data;
    hermite=(is_boundary=is_bound, bc=boundary_conds, normals=normal_vecs))

# With explicit device
using KernelAbstractions
op = RadialBasisOperator(Laplacian(), data; device=CPU())
source
RadialBasisFunctions.RadialBasisOperator Method
julia
function (op::RadialBasisOperator)(y, x)

Evaluate the operator at x in-place and store the result in y.

source
RadialBasisFunctions.RadialBasisOperator Method
julia
function (op::RadialBasisOperator)(x)

Evaluate the operator at x.

source
RadialBasisFunctions.Regrid Type
julia
Regrid

Operator for interpolating from one set of points to another.

source
RadialBasisFunctions.RotationRate Type
julia
RotationRate{Dim} <: AbstractOperator{0}

Operator for the anti-symmetric rotation rate tensor ωᵢⱼ = ½(∂uᵢ/∂xⱼ − ∂uⱼ/∂xᵢ).

Takes a vector field (Matrix N×D) as input and produces an anti-symmetric tensor (Array N_eval×D×D). Diagonal entries are zero. Weights are stored as NTuple{Dim, SparseMatrixCSC}, reusing the Jacobian weight-building infrastructure.

source
RadialBasisFunctions.ScaledOperator Type
julia
ScaledOperator{N, T<:Number, O<:AbstractOperator{N}} <: AbstractOperator{N}

An operator multiplied by a scalar coefficient. Created via α * op or op * α.

source
RadialBasisFunctions.StrainRate Type
julia
StrainRate{Dim} <: AbstractOperator{0}

Operator for the symmetric strain rate tensor εᵢⱼ = ½(∂uᵢ/∂xⱼ + ∂uⱼ/∂xᵢ).

Takes a vector field (Matrix N×D) as input and produces a symmetric tensor (Array N_eval×D×D). Weights are stored as NTuple{Dim, SparseMatrixCSC}, reusing the Jacobian weight-building infrastructure.

source

Private

RadialBasisFunctions._backward_partial_poly_1d! Method

Backward pass for polynomial section in 1D.

source
RadialBasisFunctions._backward_partial_poly_2d! Method

Backward pass for polynomial section in 2D.

source
RadialBasisFunctions._backward_partial_poly_3d! Method

Backward pass for polynomial section in 3D.

source
RadialBasisFunctions._backward_partial_polynomial_section! Method
julia
_backward_partial_polynomial_section!(Δeval_point, Δb, k, nmon, dim, num_ops)

Backward pass through the polynomial section of the RHS for Partial operator.

For monomials in 2D with poly_deg=2 (1, x, y, xy, x², y²): ∂/∂x gives: 0, 1, 0, y, 2x, 0

The gradients of these w.r.t. eval_point are: ∂(0)/∂(x,y) = (0, 0) ∂(1)/∂(x,y) = (0, 0) ∂(0)/∂(x,y) = (0, 0) ∂(y)/∂(x,y) = (0, 1) -> b[4] contributes to Δeval_point[2] ∂(2x)/∂(x,y) = (2, 0) -> b[5] contributes 2 to Δeval_point[1] ∂(0)/∂(x,y) = (0, 0)

This is equivalent to computing the mixed second derivatives ∂²pⱼ/∂x[dim]∂x[d].

source
RadialBasisFunctions._build_collocation_matrix! Method
julia
_build_collocation_matrix!(A, data, basis, mon, k)

Build RBF collocation matrix. Works for both interior stencils (AbstractVector data) and Hermite stencils (HermiteStencilData) via dispatch helpers.

Matrix structure:

julia
┌─────────────────┬─────────┐
Φ(xᵢ, xⱼ)      │ P(xᵢ)   │  k×k RBF + k×nmon polynomial
├─────────────────┼─────────┤
P(xⱼ)ᵀ         │   0     │  nmon×k poly + nmon×nmon zero
└─────────────────┴─────────┘

For Hermite stencils with Neumann/Robin conditions, basis functions are modified via _rbf_entry and _poly_entry! dispatch to maintain matrix symmetry.

source
RadialBasisFunctions._build_rhs! Method
julia
_build_rhs!(b, ℒrbf::Tuple, ℒmon::Tuple, data, eval_point, basis, mon, k)

Build RHS vector for multiple operators. Works for both interior stencils (AbstractVector) and Hermite stencils (HermiteStencilData) via dispatch helpers.

source
RadialBasisFunctions._build_rhs! Method
julia
_build_rhs!(b, ℒrbf, ℒmon, data, eval_point, basis, mon, k)

Build RHS vector for single operator. Works for both interior stencils (AbstractVector) and Hermite stencils (HermiteStencilData) via dispatch helpers.

source
RadialBasisFunctions._build_stencil! Method
julia
_build_stencil!(A, b, ℒrbf, ℒmon, data, eval_point, basis, mon, k)

Assemble complete stencil: build collocation matrix, build RHS, solve for weights. Works for both interior stencils (AbstractVector) and Hermite stencils (HermiteStencilData) via dispatch helpers in _build_collocation_matrix! and _build_rhs!.

Returns: weights (first k rows of solution, size k×num_ops)

source
RadialBasisFunctions._build_stencil! Method
julia
_build_stencil!(λ, A, b, ℒrbf, ℒmon, data, eval_point, basis, mon, k)

In-place variant: writes solution into pre-allocated λ buffer, returns view of first k rows. Avoids allocating the solution vector and the slice on every call.

source
RadialBasisFunctions._build_weights Method
julia
_build_weights(ℒ, data, eval_points, adjl, basis)

Apply operator to basis functions and route to weight computation.

source
RadialBasisFunctions._build_weights Method
julia
_build_weights(data, eval_points, adjl, basis, ℒrbf, ℒmon, mon;
              batch_size=10, device=CPU())

Build weights for interior-only problems (no boundary conditions). Creates empty BoundaryData to indicate all interior points.

source
RadialBasisFunctions._build_weights Method
julia
_build_weights(ℒ, data, eval_points, adjl, basis,
              is_boundary, boundary_conditions, normals)

Generic Hermite dispatcher for operators. Applies operator to basis and routes to Hermite weight computation.

This eliminates repetitive _build_weights methods across operator files. Note: Type constraint removed to avoid circular dependency with operators.jl

source
RadialBasisFunctions._build_weights Method
julia
_build_weights(data, eval_points, adjl, basis, ℒrbf, ℒmon, mon,
              is_boundary, boundary_conditions, normals;
              batch_size=10, device=CPU())

Build weights for problems with boundary conditions using Hermite interpolation. Exact allocation: Dirichlet points get single entry, others get full stencil.

source
RadialBasisFunctions._build_weights Method
julia
_build_weights(ℒ, op)

Entry point from operator construction. Extracts configuration from operator and routes to appropriate implementation.

source
RadialBasisFunctions._construct_sparse Method
julia
_construct_sparse(I, J, V, N_eval, N_data, num_ops)

Construct sparse matrix/vector from COO arrays.

Future GPU support: convert to device-sparse format here (see #88)

source
RadialBasisFunctions._expand_div_grad Method
julia
_expand_div_grad::AbstractVector)

Expand ∇⋅(κ∇) with per-dimension diffusivity into ∑ κ[i] * ∂²(i).

source
RadialBasisFunctions._expand_div_grad Method
julia
_expand_div_grad::Number)

Expand ∇⋅(κ∇) with scalar diffusivity into κ * Laplacian().

source
RadialBasisFunctions._expand_dot_grad Method
julia
_expand_dot_grad(c::AbstractVector)

Expand c ⋅ ∇ into ∑ c[i] * ∂/∂xᵢ (advection operator).

source
RadialBasisFunctions._forward_with_cache Method
julia
_forward_with_cache(data, eval_points, adjl, basis, ℒrbf, ℒmon, mon, ℒType)

Forward pass that builds weights while caching intermediate results for backward pass.

Returns: (W, cache) where W is the sparse weight matrix and cache contains per-stencil factorizations and solutions needed for the pullback.

source
RadialBasisFunctions._get_grad_funcs Method
julia
_get_grad_funcs(OpType, basis, ℒ)

Get gradient functions for the given operator type and basis. Returns (grad_Lφ_x, grad_Lφ_xi) tuple.

source
RadialBasisFunctions._get_rhs_closures Method
julia
_get_rhs_closures(OpType, ℒ, basis)

Get operator-specific closures for backward_stencil_with_ε!. Returns (poly_backward!, ∂Lφ_∂ε_fn) keyword arguments.

  • Partial: polynomial section backward + partial ε derivative

  • Laplacian: no polynomial backward + laplacian ε derivative

source
RadialBasisFunctions._infer_rank Method
julia
_infer_rank(ℒ)

Infer the tensor rank of a custom operator function by probing it with a default basis. Returns 1 if ℒ(basis) produces a Tuple (one callable per dimension), 0 otherwise.

source
RadialBasisFunctions._interpolator_constructor_backward Method
julia
_interpolator_constructor_backward(Δrbf_weights, Δmon_weights, A, k)

Backward pass for the Interpolator constructor w.r.t. y (the data values).

Given cotangents of rbf_weights and monomial_weights, computes the cotangent of y using the implicit function theorem. Since w = A⁻¹ [y; 0] and A is constant w.r.t. y:

julia
Δy = (A⁻¹ [Δrbf_weights; Δmon_weights])[1:k]

Used by both Mooncake and potentially Enzyme extensions.

source
RadialBasisFunctions._interpolator_point_gradient! Method
julia
_interpolator_point_gradient!(Δx, interp::Interpolator, x, Δy)

Accumulate the gradient of interp(x) * Δy into Δx.

RBF contribution: Σᵢ wᵢ * Δy * ∇φ(x, xᵢ) Polynomial contribution: Σⱼ wⱼ * Δy * ∇pⱼ(x)

source
RadialBasisFunctions._optype Method
julia
_optype(ℒ)

Map operator instance to its abstract type for dispatch in AD rules.

source
RadialBasisFunctions.allocate_sparse_arrays Method
julia
allocate_sparse_arrays(TD, k, N_eval, num_ops, adjl, boundary_data)

Allocate sparse matrix arrays for COO format sparse matrix construction. Exactly counts non-zeros: interior points get k entries, Dirichlet points get 1 entry.

source
RadialBasisFunctions.autoselect_k Method
julia
autoselect_k(data::Vector, basis<:AbstractRadialBasis)

See Bayona, 2017 - https://doi.org/10.1016/j.jcp.2016.12.008

source
RadialBasisFunctions.backward_collocation! Method
julia
backward_collocation!(Δdata, ΔA, neighbors, data, basis, mon, k)

Chain rule through collocation matrix construction.

The collocation matrix has structure: A[i,j] = φ(xi, xj) for i,j ≤ k (RBF block) A[i,k+j] = pⱼ(xi) for i ≤ k (polynomial block)

For RBF block (using ∇φ from existing basis_rules): Δxi += ΔA[i,j] * ∇φ(xi, xj) Δxj -= ΔA[i,j] * ∇φ(xi, xj) (by symmetry of φ(x-y))

For polynomial block: Δxi += ΔA[i,k+j] * ∇pⱼ(xi)

Note: A is symmetric, so we need to handle both triangles.

source
RadialBasisFunctions.backward_collocation_ε! Method
julia
backward_collocation_ε!(Δε_acc, ΔA, neighbors, data, basis, k)

Compute gradient contribution to shape parameter ε from collocation matrix.

Uses implicit differentiation: Δε += Σᵢⱼ ΔA[i,j] * ∂A[i,j]/∂ε where A[i,j] = φ(xi, xj) for the RBF block.

source
RadialBasisFunctions.backward_linear_solve! Method
julia
backward_linear_solve!(ΔA, Δb, Δw, cache)

Compute cotangents of collocation matrix A and RHS vector b from cotangent of weights Δw.

Given: Aλ = b, w = λ[1:k] We have: Δλ = [Δw; 0] (padded with zeros for monomial part)

Using implicit function theorem: η = A⁻ᵀ Δλ ΔA = -η λᵀ Δb = η

source
RadialBasisFunctions.backward_rhs! Method
julia
backward_rhs!(Δdata, Δeval_point, Δb, neighbors, eval_point, data, basis, k, grad_Lφ_x, grad_Lφ_xi; poly_backward!=nothing)

Chain rule through RHS vector construction for any operator.

RBF section (shared by all operators): b[i] = ℒφ(eval_point, xi) → accumulate ∂/∂eval_point and ∂/∂xi

Polynomial section (Partial only — Laplacian gives constants, no gradient): b[k+j] = ℒpⱼ(eval_point) → passed as optional poly_backward! closure

source
RadialBasisFunctions.backward_rhs_ε! Method
julia
backward_rhs_ε!(Δε_acc, Δb, neighbors, eval_point, data, basis, k, ∂Lφ_∂ε_fn)

Compute gradient contribution to shape parameter ε from RHS.

∂Lφ_∂ε_fn(x, xi) returns ∂(ℒφ)/∂ε for the specific operator:

  • Laplacian: (x, xi) -> ∂Laplacian_φ_∂ε(basis, x, xi)

  • Partial: (x, xi) -> ∂Partial_φ_∂ε(basis, dim, x, xi)

source
RadialBasisFunctions.backward_stencil_with_ε! Method
julia
backward_stencil_with_ε!(Δdata, Δeval_point, Δε_acc, Δw, cache, neighbors, eval_point, data, basis, mon, k, grad_Lφ_x, grad_Lφ_xi; poly_backward!=nothing, ∂Lφ_∂ε_fn=nothing)

Complete backward pass for a single stencil including shape parameter gradient.

Combines:

  1. backward_linear_solve! → compute ΔA, Δb from Δw

  2. backward_collocation! → chain ΔA to Δdata

  3. backward_collocation_ε! → chain ΔA to Δε

  4. backward_rhs! → chain Δb to Δdata and Δeval_point

  5. backward_rhs_ε! → chain Δb to Δε

Optional closures:

  • poly_backward!: polynomial section gradient (Partial only)

  • ∂Lφ_∂ε_fn: shape parameter derivative function (IMQ/Gaussian only)

source
RadialBasisFunctions.build_weights_kernel Method
julia
build_weights_kernel(data, eval_points, adjl, basis, ℒrbf, ℒmon, mon,
                    boundary_data; batch_size, device)

Main orchestrator for weight computation. Currently CPU-only. GPU stencil solve is not yet supported — see GitHub issue #88.

source
RadialBasisFunctions.build_weights_pullback_loop! Method
julia
build_weights_pullback_loop!(Δdata, Δeval, Δε_acc, ΔW_extractor, cache, adjl,
    eval_points, data, basis, mon, ℒ, OpType, grad_Lφ_x, grad_Lφ_xi)

Shared stencil iteration loop for _build_weights pullback across all AD backends.

ΔW_extractor(eval_idx, neighbors, k) is a callable that returns the stencil cotangent matrix Δw given the eval index, neighbor list, and stencil size. This abstracts over the different ways each AD framework stores cotangents (dense matrix, nzval vector, etc.).

source
RadialBasisFunctions.calculate_batch_range Method

Calculate batch index range for kernel execution

source
RadialBasisFunctions.compute_hermite_poly_entry! Method
julia
compute_hermite_poly_entry!(a, i, data, mon)

Compute polynomial entries for Hermite interpolation. Dispatches based on boundary point type for type stability.

source
RadialBasisFunctions.compute_hermite_rbf_entry Method
julia
compute_hermite_rbf_entry(i, j, data, ops)

Compute single RBF matrix entry with Hermite boundary modifications. Dispatches based on point types (Interior/Dirichlet/NeumannRobin).

Uses BasisOperators for efficient evaluation (avoids functor construction in hot loop).

source
RadialBasisFunctions.construct_global_to_boundary Method
julia
construct_global_to_boundary(is_boundary)

Construct mapping from global indices to boundary-only indices. For boundary points: global_to_boundary[i] = boundary array index For interior points: global_to_boundary[i] = 0 (sentinel)

source
RadialBasisFunctions.count_nonzeros Method
julia
count_nonzeros(adjl, is_boundary, boundary_conditions)

Count exact number of non-zero entries for optimized allocation. Returns (total_nnz, row_offsets) where row_offsets[i] is the starting position for row i.

source
RadialBasisFunctions.extract_stencil_cotangent Method
julia
extract_stencil_cotangent(ΔW, eval_idx, neighbors, k, num_ops)

Extract cotangent values for a single stencil from a dense/sparse matrix cotangent. Used by the Enzyme extension.

source
RadialBasisFunctions.extract_stencil_cotangent_from_nzval Method
julia
extract_stencil_cotangent_from_nzval(ΔW_nzval, W, eval_idx, neighbors, k)

Extract cotangent values for a single stencil from sparse matrix nzval gradient. Used by Mooncake extension where gradients are stored in fdata.nzval.

source
RadialBasisFunctions.fill_dirichlet_entry! Method

Fill Dirichlet identity row for optimized allocation

source
RadialBasisFunctions.fill_entries! Method

Fill sparse matrix entries using indexed storage (row_offsets)

source
RadialBasisFunctions.grad_applied_laplacian_wrt_x Method
julia
grad_applied_laplacian_wrt_x(basis)

Get gradient of applied Laplacian operator w.r.t. evaluation point.

source
RadialBasisFunctions.grad_applied_laplacian_wrt_xi Method
julia
grad_applied_laplacian_wrt_xi(basis)

Get gradient of applied Laplacian operator w.r.t. data point. By symmetry, always the negation of the _wrt_x version.

source
RadialBasisFunctions.grad_applied_partial_wrt_x Method
julia
grad_applied_partial_wrt_x(basis, dim)

Get gradient of applied partial derivative operator w.r.t. evaluation point.

source
RadialBasisFunctions.grad_applied_partial_wrt_xi Method
julia
grad_applied_partial_wrt_xi(basis, dim)

Get gradient of applied partial derivative operator w.r.t. data point. By symmetry, always the negation of the _wrt_x version.

source
RadialBasisFunctions.grad_laplacian_gaussian_wrt_x Method
julia
grad_laplacian_gaussian_wrt_x(ε)

Returns a function computing ∂/∂x[j] of [∇²φ] for Gaussian.

Mathematical derivation: ∇²φ = (4ε⁴r² - 2ε²D) * φ

∂(∇²φ)/∂x[j] = φ * δ_j * 4ε⁴ * [2 + D - 2ε²r²]

source
RadialBasisFunctions.grad_laplacian_imq_wrt_x Method
julia
grad_laplacian_imq_wrt_x(ε)

Returns a function computing ∂/∂x[j] of [∇²φ] for IMQ.

Mathematical derivation: ∇²φ = sum_i [∂²φ/∂x[i]²] = 3ε⁴r²/s^(5/2) - D*ε²/s^(3/2)

∂(∇²φ)/∂x[j] = δ_j * [3(D+2)ε⁴/s^(5/2) - 15ε⁶r²/s^(7/2)]

source
RadialBasisFunctions.grad_laplacian_phs1_wrt_x Method
julia
grad_laplacian_phs1_wrt_x()

Returns a function computing ∂/∂x[j] of [∇²φ] for PHS1.

Mathematical derivation: ∇²φ = 2/r ∂/∂x[j] [2/r] = -2 * δ_j / r³

Note: At r=0, we return 0 to avoid singularity.

source
RadialBasisFunctions.grad_laplacian_phs3_wrt_x Method
julia
grad_laplacian_phs3_wrt_x()

Returns a function computing ∂/∂x[j] of [∇²φ] for PHS3.

Mathematical derivation: ∇²φ = 12r ∂/∂x[j] [12r] = 12 * δ_j / r

source
RadialBasisFunctions.grad_laplacian_phs5_wrt_x Method
julia
grad_laplacian_phs5_wrt_x()

Returns a function computing ∂/∂x[j] of [∇²φ] for PHS5.

Mathematical derivation: ∇²φ = 30r³ ∂/∂x[j] [30r³] = 30 * 3r² * δ_j / r = 90 * r * δ_j

source
RadialBasisFunctions.grad_laplacian_phs7_wrt_x Method
julia
grad_laplacian_phs7_wrt_x()

Returns a function computing ∂/∂x[j] of [∇²φ] for PHS7.

Mathematical derivation: ∇²φ = 56r⁵ ∂/∂x[j] [56r⁵] = 56 * 5r⁴ * δ_j / r = 280 * r³ * δ_j

source
RadialBasisFunctions.grad_partial_gaussian_wrt_x Method
julia
grad_partial_gaussian_wrt_x(ε, dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for Gaussian.

Mathematical derivation: φ = exp(-ε²r²) ∂φ/∂x[dim] = -2ε² * δ_d * φ

∂²φ/∂x[j]∂x[dim] = φ * [-2ε² * δ_{j,dim} + 4ε⁴ * δ_d * δ_j]

For j == dim: φ * (4ε⁴ * δ_d² - 2ε²) For j != dim: φ * 4ε⁴ * δ_d * δ_j

source
RadialBasisFunctions.grad_partial_imq_wrt_x Method
julia
grad_partial_imq_wrt_x(ε, dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for IMQ.

Mathematical derivation: Let s = ε²r² + 1, δ_d = x[dim] - xi[dim] ∂φ/∂x[dim] = -ε² * δ_d / s^(3/2)

∂²φ/∂x[j]∂x[dim] = -ε² * [δ_{j,dim} / s^(3/2) - δ_d * (3/2) * s^(-5/2) * 2ε² * δ_j] = -ε² * δ_{j,dim} / s^(3/2) + 3ε⁴ * δ_d * δ_j / s^(5/2)

For j == dim: -ε² / s^(3/2) + 3ε⁴ * δ_d² / s^(5/2) For j != dim: 3ε⁴ * δ_d * δ_j / s^(5/2)

source
RadialBasisFunctions.grad_partial_phs1_wrt_x Method
julia
grad_partial_phs1_wrt_x(dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for PHS1.

Mathematical derivation: ∂φ/∂x[dim] = δ_d / r

∂²φ/∂x[j]∂x[dim] = (δ_{j,dim} * r - δ_d * δ_j / r) / r² = δ_{j,dim} / r - δ_d * δ_j / r³

Note: At r=0, the derivative is singular but we return 0 since the RBF value itself is 0 at r=0, so this term doesn't contribute to the gradient.

source
RadialBasisFunctions.grad_partial_phs3_wrt_x Method
julia
grad_partial_phs3_wrt_x(dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for PHS3.

Mathematical derivation: ∂φ/∂x[dim] = 3 * δ_d * r where δ_d = x[dim] - xi[dim], r = ||x - xi||

∂²φ/∂x[j]∂x[dim] = 3 * (δ_{j,dim} * r + δ_d * δ_j / r)

For j == dim: 3 * (r + δ_d² / r) For j != dim: 3 * δ_d * δ_j / r

source
RadialBasisFunctions.grad_partial_phs5_wrt_x Method
julia
grad_partial_phs5_wrt_x(dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for PHS5.

Mathematical derivation: ∂φ/∂x[dim] = 5 * δ_d * r³

∂²φ/∂x[j]∂x[dim] = 5 * (δ_{j,dim} * r³ + δ_d * 3r * δ_j) = 5 * (δ_{j,dim} * r³ + 3 * δ_d * δ_j * r)

source
RadialBasisFunctions.grad_partial_phs7_wrt_x Method
julia
grad_partial_phs7_wrt_x(dim)

Returns a function computing ∂/∂x[j] of [∂φ/∂x[dim]] for PHS7.

Mathematical derivation: ∂φ/∂x[dim] = 7 * δ_d * r⁵

∂²φ/∂x[j]∂x[dim] = 7 * (δ_{j,dim} * r⁵ + δ_d * 5r³ * δ_j)

source
RadialBasisFunctions.hermite_mono_rhs! Method
julia
hermite_mono_rhs!(bmono, ℒmon, mon, eval_point, is_bound, bc, normal, workspace)

Apply boundary conditions to monomial operator evaluation. Dispatches based on boundary point type for type stability.

source
RadialBasisFunctions.hermite_rbf_rhs Method
julia
hermite_rbf_rhs(ℒrbf, eval_point, data_point, is_bound, bc, normal)

Apply boundary conditions to RBF operator evaluation.

  • Interior/Dirichlet: standard evaluation ℒΦ(x_eval, x_data)

  • Neumann/Robin: α_ℒΦ + β_ℒ(∂ₙΦ)

source
RadialBasisFunctions.launch_kernel! Method
julia
launch_kernel!(...)

Launch parallel CPU kernel for weight computation. Handles Dirichlet/Interior/Hermite stencil classification via dispatch.

source
RadialBasisFunctions.negate_grad Method
julia
negate_grad(grad_fn)

Given a gradient function grad_fn(x, xi), returns (x, xi) -> -grad_fn(x, xi). All _wrt_xi functions are the negation of their _wrt_x counterparts by symmetry.

source
RadialBasisFunctions.point_type Method

Determine boundary type of a single point

source
RadialBasisFunctions.∂Laplacian_φ_∂ε Method
julia
∂Laplacian_φ_∂ε(basis::Gaussian, x, xi)

Derivative of Laplacian of Gaussian basis w.r.t. shape parameter ε.

∇²φ = (-2ε²D + 4ε⁴r²) exp(-ε²r²), where D = dimension ∂(∇²φ)/∂ε = exp(-ε²r²) [-4εD + 16ε³r² + 4ε³r²D - 8ε⁵r⁴]

source
RadialBasisFunctions.∂Laplacian_φ_∂ε Method
julia
∂Laplacian_φ_∂ε(basis::IMQ, x, xi)

Derivative of Laplacian of IMQ basis w.r.t. shape parameter ε.

Let s = ε²r² + 1, D = dimension ∇²φ = -ε²D/s^(3/2) + 3ε⁴r²/s^(5/2) ∂(∇²φ)/∂ε = ∂/∂ε[-ε²D s^(-3/2) + 3ε⁴r² s^(-5/2)]

source
RadialBasisFunctions.∂Partial_φ_∂ε Method
julia
∂Partial_φ_∂ε(basis::Gaussian, dim::Int, x, xi)

Derivative of first partial derivative of Gaussian basis w.r.t. shape parameter ε.

∂φ/∂x_dim = -2ε²(x_dim - xi_dim) exp(-ε²r²) ∂/∂ε[∂φ/∂x_dim] = 4ε(x_dim - xi_dim)(ε²r² - 1) exp(-ε²r²)

source
RadialBasisFunctions.∂Partial_φ_∂ε Method
julia
∂Partial_φ_∂ε(basis::IMQ, dim::Int, x, xi)

Derivative of first partial derivative of IMQ basis w.r.t. shape parameter ε.

∂φ/∂x_dim = ε²(xi_dim - x_dim) s^(-3/2) ∂/∂ε[∂φ/∂x_dim] = 2ε(xi_dim - x_dim) s^(-3/2) + ε²(xi_dim - x_dim)(-3/2)s^(-5/2) · 2εr² = (xi_dim - x_dim)[2ε s^(-3/2) - 3ε³r² s^(-5/2)]

source
RadialBasisFunctions.∂φ_∂ε Method
julia
∂φ_∂ε(basis::Gaussian, x, xi)

Derivative of Gaussian basis function w.r.t. shape parameter ε.

φ(r) = exp(-ε²r²) ∂φ/∂ε = -2εr² exp(-ε²r²)

source
RadialBasisFunctions.∂φ_∂ε Method
julia
∂φ_∂ε(basis::IMQ, x, xi)

Derivative of IMQ basis function w.r.t. shape parameter ε.

φ(r) = (ε²r² + 1)^(-1/2) ∂φ/∂ε = -εr² (ε²r² + 1)^(-3/2)

source
RadialBasisFunctions.BasisOperators Type
julia
BasisOperators{B,G,Hess}

Bundle of pre-constructed basis operators for efficient evaluation in hot loops. Avoids repeated functor construction inside hermite_rbf_dispatch.

Fields:

  • φ: The basis function itself

  • ∇φ: Gradient operator (pre-constructed ∇(basis))

  • : Hessian operator (pre-constructed H(basis))

Usage:

julia
ops = BasisOperators(basis)
# In hot loop:
φ_val = ops.φ(x, xᵢ)
grad = ops.∇φ(x, xᵢ)      # Returns vector
hess = ops.(x, xᵢ)      # Returns matrix
= dot(n, grad)         # Directional derivative
D²φ = dot(ni, hess * nj)  # Second directional derivative
source
RadialBasisFunctions.BasisOperators Method

Construct BasisOperators from a basis function.

source
RadialBasisFunctions.BoundaryData Type
julia
BoundaryData{T}

Wrapper for global boundary information (replaces fragile tuples).

source
RadialBasisFunctions.BoundaryPointType Type

Trait types for individual point boundary classification

source
RadialBasisFunctions.D Type
julia
D{B<:AbstractRadialBasis,V}

Directional derivative operator functor. Construct with D(basis, v). Computes the derivative of the basis function in direction v.

source
RadialBasisFunctions.D² Type
julia
D²{B<:AbstractRadialBasis,V1,V2}

Directional second derivative operator functor. Construct with D²(basis, v1, v2).

source
RadialBasisFunctions.H Type
julia
H{B<:AbstractRadialBasis}

Hessian operator functor. Construct with H(basis). Returns the Hessian matrix of the basis function.

source
RadialBasisFunctions.StencilForwardCache Type
julia
StencilForwardCache{T}

Per-stencil storage from forward pass needed for backward pass.

  • lambda: Full solution vector (k+nmon) × num_ops from solving Aλ = b

  • A_mat: The symmetric collocation matrix (stored for backprop)

  • k: Number of RBF neighbors in stencil

  • nmon: Number of monomial basis functions

source
RadialBasisFunctions.StencilType Type

Trait types for stencil classification

source
RadialBasisFunctions.WeightsBuildForwardCache Type
julia
WeightsBuildForwardCache{T}

Global cache storing all stencil results and references to inputs.

  • stencil_caches: Vector of StencilForwardCache, one per evaluation point

  • k: Stencil size (number of neighbors)

  • nmon: Number of monomial basis functions

  • num_ops: Number of operators (1 for scalar, D for gradient)

source
RadialBasisFunctions.∂ Type
julia
∂{B<:AbstractRadialBasis}

Partial derivative operator functor. Construct with ∂(basis, dim).

source
RadialBasisFunctions.∂mixed Type
julia
∂mixed{B<:AbstractRadialBasis}

Mixed partial derivative operator functor. Construct with ∂mixed(basis, dim1, dim2). Computes ∂²φ/(∂x_{dim1} ∂x_{dim2}).

source
RadialBasisFunctions.∂² Type
julia
∂²{B<:AbstractRadialBasis}

Second partial derivative operator functor. Construct with ∂²(basis, dim).

source
RadialBasisFunctions.∇ Type
julia
∇{B<:AbstractRadialBasis}

Gradient operator functor. Construct with ∇(basis).

source
RadialBasisFunctions.∇² Type
julia
∇²{B<:AbstractRadialBasis}

Laplacian operator functor. Construct with ∇²(basis).

source