Skip to content

Domains

The domains module provides types for representing spatial domains and grids used throughout FunctionalGPs.jl.

Domain Types

FunctionalGPs.Domain Type
julia
Domain

Abstract supertype for all spatial domains in FunctionalGPs.

Subtypes must implement:

  • volume(::Domain): compute the domain's volume

  • Base.in(x, ::Domain): test if a point is inside the domain

Concrete implementations: Interval, BoxDomain.

source
FunctionalGPs.Interval Type
julia
Interval{T<:Real} <: Domain

A one-dimensional closed interval [lower, upper].

Fields

  • lower::T: the left endpoint

  • upper::T: the right endpoint

Examples

julia
julia> I = Interval(0.0, 1.0)
Interval{Float64}(0.0, 1.0)

julia> 0.5 in I
true

julia> volume(I)
1.0

See also: BoxDomain, uniform_grid_n, uniform_grid_step.

source
FunctionalGPs.BoxDomain Type
julia
BoxDomain{T<:Real} <: Domain

An N-dimensional hyperrectangular (box) domain defined by per-dimension bounds.

Constructors

julia
BoxDomain((lower₁, upper₁), (lower₂, upper₂), ...)  # from tuples
BoxDomain(Interval(a, b), Interval(c, d), ...)      # from Intervals

Examples

julia
julia> box = BoxDomain((0.0, 1.0), (0.0, 2.0))
BoxDomain{Float64}(((0.0, 1.0), (0.0, 2.0)))

julia> [0.5, 1.0] in box
true

julia> volume(box)
2.0

julia> ndims(box)
2

See also: Interval, uniform_grid_n, FactorizedGrid.

source

Grid Types

FunctionalGPs.FactorizedGrid Type
julia
FactorizedGrid{T} <: AbstractVector{T}

A tensor product grid stored in factorized form for efficient Kronecker computations.

Rather than materializing an N-dimensional grid as a dense array of points, a FactorizedGrid stores the 1D ranges for each dimension and computes products lazily. This enables efficient kernel matrix computation via Kronecker products when used with KernelTensorProduct kernels.

Construction

Typically created via uniform_grid_n or uniform_grid_step on a BoxDomain, or directly from ranges:

julia
grid = FactorizedGrid(0.0:0.1:1.0, 0.0:0.2:2.0)

Examples

julia
julia> box = BoxDomain((0.0, 1.0), (0.0, 1.0))
julia> grid = uniform_grid_n(box, 3, 3)
FactorizedGrid((3, 3))

julia> size(grid)
(3, 3)

julia> convert(Array, grid)  # materialize to dense array
3×3 Matrix{...}

See also: BoxDomain, uniform_grid_n, kernelmatrix.

source
FunctionalGPs.FactorizedBoxDomains Type
julia
FactorizedBoxDomains{N,T} <: AbstractArray{BoxDomain{T},N}

A factorized collection of N-dimensional BoxDomains.

Stores intervals per dimension and constructs box domains on-the-fly via indexing. Useful for representing tensor product domain decompositions without materializing all boxes explicitly.

Construction

julia
FactorizedBoxDomains(intervals_dim1, intervals_dim2, ...)  # from interval vectors
intervals1  intervals2                                    # via tensor product operator

Examples

julia
julia> x_intervals = intervals_from_endpoints([0.0, 0.5, 1.0])
julia> y_intervals = intervals_from_endpoints([0.0, 1.0])
julia> domains = x_intervals  y_intervals
2×1 FactorizedBoxDomains{2, Float64}

julia> domains[1, 1]  # access individual BoxDomain
BoxDomain{Float64}(((0.0, 0.5), (0.0, 1.0)))

See also: BoxDomain, Interval, get_intervals.

source

Grid Construction

FunctionalGPs.uniform_grid_n Function
julia
uniform_grid_n(interval::Interval, N::Int)

Create a uniform grid of N points over interval.

Returns a StepRangeLen spanning from interval.lower to interval.upper.

Examples

julia
julia> uniform_grid_n(Interval(0.0, 1.0), 5)
0.0:0.25:1.0

See also: uniform_grid_step.

source
julia
uniform_grid_n(box::BoxDomain, N₁::Int, N₂::Int, ...)

Create a FactorizedGrid over box with Nᵢ points along dimension i.

Examples

julia
julia> box = BoxDomain((0.0, 1.0), (0.0, 2.0))
julia> grid = uniform_grid_n(box, 3, 5)
FactorizedGrid((3, 5))

See also: uniform_grid_step, FactorizedGrid.

source
FunctionalGPs.uniform_grid_step Function
julia
uniform_grid_step(interval::Interval, step::Real)

Create a uniform grid over interval with spacing step.

Returns a StepRangeLen starting at interval.lower with the given step size.

Examples

julia
julia> uniform_grid_step(Interval(0.0, 1.0), 0.2)
0.0:0.2:1.0

See also: uniform_grid_n.

source
julia
uniform_grid_step(box::BoxDomain, step₁::Real, step₂::Real, ...)

Create a FactorizedGrid over box with spacing stepᵢ along dimension i.

Examples

julia
julia> box = BoxDomain((0.0, 1.0), (0.0, 1.0))
julia> grid = uniform_grid_step(box, 0.5, 0.25)
FactorizedGrid((3, 5))

See also: uniform_grid_n, FactorizedGrid.

source
FunctionalGPs.intervals_from_endpoints Function
julia
intervals_from_endpoints(endpoints::AbstractVector)

Construct a vector of adjacent Intervals from a sorted vector of endpoints.

Given [a, b, c, ...], returns [Interval(a,b), Interval(b,c), ...].

Examples

julia
julia> intervals_from_endpoints([0.0, 0.5, 1.0])
2-element Vector{Interval{Float64}}:
 Interval{Float64}(0.0, 0.5)
 Interval{Float64}(0.5, 1.0)
source

Domain Operations

FunctionalGPs.volume Function
julia
volume(d::Domain)

Compute the volume (or length/area in 1D/2D) of domain d.

Examples

julia
julia> volume(Interval(0.0, 2.0))
2.0

julia> volume(BoxDomain((0.0, 1.0), (0.0, 2.0)))
2.0
source
FunctionalGPs.get_intervals Function
julia
get_intervals(domains::FactorizedBoxDomains, i::Int)

Return the vector of Intervals for dimension i.

get_intervals(domains::FactorizedBoxDomains)

Return all interval vectors as a vector of vectors.

source

Kernel Matrix Computation

Efficient kernel matrix computation for tensor product grids:

KernelFunctions.kernelmatrix Method
julia
kernelmatrix(k::KernelTensorProduct, x::FactorizedGrid, y::FactorizedGrid)
kernelmatrix(k::KernelTensorProduct, x::FactorizedGrid)

Compute the kernel matrix between two FactorizedGrids using Kronecker products.

For a tensor product kernel k = k₁ ⊗ k₂ ⊗ ... and factorized grids, the kernel matrix decomposes as a Kronecker product of per-dimension kernel matrices, enabling efficient computation and storage.

Returns a Kronecker type from Kronecker.jl that supports efficient linear algebra.

source
KernelFunctions.kernelmatrix_diag Method
julia
kernelmatrix_diag(k::KernelTensorProduct, x::FactorizedGrid)

Compute the diagonal of the kernel matrix for a FactorizedGrid.

Returns the Kronecker product of per-dimension diagonals as a vector.

source