Domains
The domains module provides types for representing spatial domains and grids used throughout FunctionalGPs.jl.
Domain Types
FunctionalGPs.Domain Type
DomainAbstract supertype for all spatial domains in FunctionalGPs.
Subtypes must implement:
volume(::Domain): compute the domain's volumeBase.in(x, ::Domain): test if a point is inside the domain
Concrete implementations: Interval, BoxDomain.
FunctionalGPs.Interval Type
Interval{T<:Real} <: DomainA one-dimensional closed interval [lower, upper].
Fields
lower::T: the left endpointupper::T: the right endpoint
Examples
julia> I = Interval(0.0, 1.0)
Interval{Float64}(0.0, 1.0)
julia> 0.5 in I
true
julia> volume(I)
1.0See also: BoxDomain, uniform_grid_n, uniform_grid_step.
FunctionalGPs.BoxDomain Type
BoxDomain{T<:Real} <: DomainAn N-dimensional hyperrectangular (box) domain defined by per-dimension bounds.
Constructors
BoxDomain((lower₁, upper₁), (lower₂, upper₂), ...) # from tuples
BoxDomain(Interval(a, b), Interval(c, d), ...) # from IntervalsExamples
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)
2See also: Interval, uniform_grid_n, FactorizedGrid.
Grid Types
FunctionalGPs.FactorizedGrid Type
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:
grid = FactorizedGrid(0.0:0.1:1.0, 0.0:0.2:2.0)Examples
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.
FunctionalGPs.FactorizedBoxDomains Type
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
FactorizedBoxDomains(intervals_dim1, intervals_dim2, ...) # from interval vectors
intervals1 ⊗ intervals2 # via tensor product operatorExamples
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.
Grid Construction
FunctionalGPs.uniform_grid_n Function
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> uniform_grid_n(Interval(0.0, 1.0), 5)
0.0:0.25:1.0See also: uniform_grid_step.
uniform_grid_n(box::BoxDomain, N₁::Int, N₂::Int, ...)Create a FactorizedGrid over box with Nᵢ points along dimension i.
Examples
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.
FunctionalGPs.uniform_grid_step Function
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> uniform_grid_step(Interval(0.0, 1.0), 0.2)
0.0:0.2:1.0See also: uniform_grid_n.
uniform_grid_step(box::BoxDomain, step₁::Real, step₂::Real, ...)Create a FactorizedGrid over box with spacing stepᵢ along dimension i.
Examples
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.
FunctionalGPs.intervals_from_endpoints Function
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> 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)Domain Operations
FunctionalGPs.volume Function
volume(d::Domain)Compute the volume (or length/area in 1D/2D) of domain d.
Examples
julia> volume(Interval(0.0, 2.0))
2.0
julia> volume(BoxDomain((0.0, 1.0), (0.0, 2.0)))
2.0FunctionalGPs.get_intervals Function
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.
sourceKernel Matrix Computation
Efficient kernel matrix computation for tensor product grids:
KernelFunctions.kernelmatrix Method
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.
KernelFunctions.kernelmatrix_diag Method
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