Functionals
Linear functionals are the core abstraction in FunctionalGPs.jl. A linear functional maps a function to a finite-dimensional vector. The most common examples are:
Point evaluation: Evaluate a function at specific input locations
Integration: Integrate a function over specified domains
Derivative evaluation: Evaluate derivatives at specific locations (via composition with differential operators)
Creating Functionals
Point Evaluation
using FunctionalGPs
# Evaluate at three points
X = [0.0, 0.5, 1.0]
δ = EvaluationFunctional(X)Integration
using FunctionalGPs
# Integrate over an interval
∫ = VectorizedLebesgueIntegral(Interval(0.0, 1.0))
# Integrate over multiple intervals
intervals = [Interval(0.0, 1.0), Interval(1.0, 2.0)]
∫_vec = VectorizedLebesgueIntegral(intervals)
# `IntegralFunctional` is a shorter alias for the same type
∫ = IntegralFunctional(Interval(0.0, 1.0))Derivative Evaluation
Compose an evaluation functional with a differential operator:
using FunctionalGPs
δ = EvaluationFunctional([0.0, 0.5, 1.0])
∂x = PartialDerivative((1,))
δ_dx = δ ∘ ∂x # Evaluate the first derivativeCombining Functionals
Functionals can be combined using three operators:
| Operator | Description | Example |
|---|---|---|
+ | Sum of functionals (same output shape required) | δ1 + δ2 |
∘ | Composition with differential operators | δ ∘ ∂x |
⊗ | Tensor product for separable domains | δ_x ⊗ ∫_y |
Stacking Functionals
Use StackedLinearFunctional to combine functionals with different output shapes:
δ = EvaluationFunctional(X)
∂x = PartialDerivative((1,))
δ_dx = δ ∘ ∂x
# Stack function values and derivative observations
stacked = StackedLinearFunctional(δ, δ_dx)Tensor Products
Use ⊗ for multi-dimensional domains with separable structure:
# Evaluate at x, integrate over y (axis-aligned line integrals)
k = k_x ⊗ k_y # Tensor product kernel
δ_x = EvaluationFunctional(x_points)
∫_y = VectorizedLebesgueIntegral(y_intervals)
ℒ = δ_x ⊗ ∫_yAPI Reference
Point Evaluation
FunctionalGPs.EvaluationFunctional Type
EvaluationFunctional <: AbstractLinearFunctionalPoint evaluation functional that evaluates a function at specified input locations.
When applied to a GP kernel, this produces the standard covariance matrix between evaluation points. This is the most common functional used in GP regression.
Fields
X::AbstractVector: Input locations where the function is evaluatedoutput_shape::Tuple: Shape of the output (automatically set tosize(X))
Example
# Evaluate at three points
X = [0.0, 0.5, 1.0]
δ = EvaluationFunctional(X)
# Compose with differentiation to get derivative observations
∂x = PartialDerivative((1,))
δ_dx = δ ∘ ∂x # Evaluates the derivative at XSee also
VectorizedLebesgueIntegral: For integral observationsStackedLinearFunctional: To combine with other functionals
Integration
FunctionalGPs.VectorizedLebesgueIntegral Type
VectorizedLebesgueIntegral{T <: Domain} <: AbstractLinearFunctionalIntegration functional that computes integrals over one or more domains.
This functional represents the Lebesgue integral ∫_D f(x) dx for each domain D in the provided collection. It is useful for Bayesian quadrature, cell-averaged observations, and integral constraints.
Fields
domains::AbstractArray{T}: Array of domains to integrate over
Example
using FunctionalGPs
# Single interval integration
∫ = VectorizedLebesgueIntegral(Interval(0.0, 1.0))
# Multiple intervals (vectorized)
intervals = [Interval(0.0, 1.0), Interval(1.0, 2.0), Interval(2.0, 3.0)]
∫_vec = VectorizedLebesgueIntegral(intervals)
# 2D box integration
box = BoxDomain((0.0, 1.0), (0.0, 1.0))
∫_2d = VectorizedLebesgueIntegral(box)See also
EvaluationFunctional: For point evaluationTensorProductFunctional: For combining with evaluation on other dimensions
FunctionalGPs.IntegralFunctional Type
IntegralFunctionalAlias for VectorizedLebesgueIntegral. The shorter name reads better alongside EvaluationFunctional and PartialDerivative in narrative code.
Differential Operators
FunctionalGPs.PartialDerivative Type
PartialDerivative(multi_idx::NTuple{M, Integer})
PartialDerivative{N}(output_idx, multi_idx)A partial derivative operator specified by a multi-index.
The multi-index (i₁, i₂, ...) represents the operator ∂^(i₁+i₂+...)/∂x₁^i₁∂x₂^i₂....
Examples
∂x = PartialDerivative((1,)) # ∂/∂x (first derivative in 1D)
∂xx = PartialDerivative((2,)) # ∂²/∂x² (second derivative in 1D)
∂xy = PartialDerivative((1, 1)) # ∂²/∂x∂y (mixed partial in 2D)Composing with functionals
δ = EvaluationFunctional([0.0, 0.5, 1.0])
∂x = PartialDerivative((1,))
δ_dx = δ ∘ ∂x # Evaluate the first derivative at the given pointsFunctionalGPs.AbstractLinearFunctionOperator Type
AbstractLinearFunctionOperatorAbstract supertype for linear operators that act on functions (e.g., differentiation).
Operators can be composed with functionals using ∘ to create new functionals. For example, EvaluationFunctional(X) ∘ PartialDerivative((1,)) creates a functional that evaluates the first derivative at points X.
Subtypes
PartialDerivative: Partial differentiation operatorLinearDifferentialOperator: Linear combinations of partial derivatives
Combining Functionals
FunctionalGPs.StackedLinearFunctional Type
StackedLinearFunctional <: AbstractLinearFunctionalA linear functional that stacks multiple linear functionals together. When applied to a kernel from both sides, it creates a symmetric block matrix where each block represents the cross-covariance between pairs of functionals.
Fields
linfunctionals::Tuple: A tuple of linear functionals to stack
Example
δ1 = EvaluationFunctional(X1)
δ2 = EvaluationFunctional(X2)
stacked = StackedLinearFunctional(δ1, δ2) # or StackedLinearFunctional([δ1, δ2])
# Apply to kernel to create StackedPVCrosscov
pv_stack = stacked(kernel)
# Apply again to create block matrix
block_matrix = stacked(pv_stack) # Creates [[δ1∘δ1, δ1∘δ2], [δ2∘δ1, δ2∘δ2]]FunctionalGPs.TensorProductFunctional Type
TensorProductFunctional{N, F}A tensor product of N linear functionals, where each functional operates on a separate dimension of a tensor product kernel.
For a tensor product kernel k = k₁ ⊗ k₂ ⊗ ... ⊗ kₙ, applying a TensorProductFunctional with functionals ℒ = ℒ₁ ⊗ ℒ₂ ⊗ ... ⊗ ℒₙ produces ℒ₁(k₁) ⊗ ℒ₂(k₂) ⊗ ... ⊗ ℒₙ(kₙ).
This is particularly useful for axis-aligned line integrals on 2D domains:
k = k_x ⊗ k_y
eval_x = EvaluationFunctional(x_points)
∫_y = VectorizedLebesgueIntegral(y_intervals)
ℒ = eval_x ⊗ ∫_y # Line integral: evaluate at x points, integrate over yType Parameters
N: Number of factorsF <: NTuple{N, AbstractLinearFunctional}: Concrete tuple type for type stability
FunctionalGPs.SumLinearFunctional Type
SumLinearFunctional{N} <: AbstractSumLinearFunctional{N}A sum of N linear functionals, typically created using the + operator.
The sum functional applies each summand and adds the results. All summands must have the same output shape.
Fields
summands::NTuple{N, AbstractLinearFunctional}: The functionals being summed
Example
δ1 = EvaluationFunctional([0.0, 0.5])
δ2 = EvaluationFunctional([1.0, 1.5])
sum_fctl = δ1 + δ2 # Creates SumLinearFunctionalFunctionalGPs.LinFctlLinFuncOpConcat Type
LinFctlLinFuncOpConcat{N} <: AbstractLinFctlLinFuncOpConcat{N}Composition of a linear functional with N function operators, created using ∘.
This represents the operation ℒ ∘ D₁ ∘ D₂ ∘ ... ∘ Dₙ, where ℒ is a functional and Dᵢ are operators like differentiation. Used for derivative observations and physics-informed constraints.
Fields
linfctl::AbstractLinearFunctional: The base functionallinfuncops::NTuple{N, AbstractLinearFunctionOperator}: The operators to apply
Example
# Evaluate the first derivative at specific points
δ = EvaluationFunctional([0.0, 0.5, 1.0])
∂x = PartialDerivative((1,))
δ_dx = δ ∘ ∂x
# Evaluate the second derivative
δ_d2x = δ ∘ ∂x ∘ ∂x
# Use in GP conditioning
obs = LinearObservation(δ_dx, derivative_values, noise)See also
EvaluationFunctional: Common base functionalPartialDerivative: Common operator for differentiation
Abstract Types
FunctionalGPs.AbstractLinearFunctional Type
AbstractLinearFunctionalAbstract supertype for all linear functionals on functions.
A linear functional is a linear map from a function space to a finite-dimensional vector space. Common examples include point evaluation, integration over domains, and compositions with differential operators.
Linear functionals can be combined using:
+: Sum of functionals (must have same output shape)∘: Composition with aAbstractLinearFunctionOperator(e.g., differentiation)⊗: Tensor product for multi-dimensional domains
Implementing a new functional
Custom functionals should subtype AbstractLinearFunctional and implement:
output_shape(ℒ): Return a tuple specifying the output dimensions
See also
EvaluationFunctional: Point evaluationVectorizedLebesgueIntegral: Integration over domainsStackedLinearFunctional: Stack multiple functionalsTensorProductFunctional: Tensor product of functionals
FunctionalGPs.AbstractSumLinearFunctional Type
AbstractSumLinearFunctional{N} <: AbstractLinearFunctionalAbstract type for sums of linear functionals.
Sums are created using the + operator on functionals. All summands must have the same output shape.
See also
SumLinearFunctional: Concrete implementation
FunctionalGPs.AbstractLinFctlLinFuncOpConcat Type
AbstractLinFctlLinFuncOpConcat{N} <: AbstractLinearFunctionalAbstract type for a linear functional composed with function operators.
Compositions are created using the ∘ operator, e.g., δ ∘ ∂x for evaluating the derivative.
See also
LinFctlLinFuncOpConcat: Concrete implementation