Overview
All composition operations preserve the positive semi-definite (PSD) property, ensuring the resulting kernels are valid for use in kernel methods like SVM.SumKernel
Sum of two kernels representing the direct sum of their Reproducing Kernel Hilbert Spaces (RKHS). Formula:k(x, y) = k₁(x, y) + k₂(x, y)
Mathematical property: The sum of two PSD kernels is PSD. Corresponds to the direct sum H = H₁ ⊕ H₂.
Constructor
First kernel function
Second kernel function
Methods
operator()
Evaluates the sum kernel.First input vector
Second input vector
Sum of kernel evaluations: k₁(x, y) + k₂(x, y)
Example
ProductKernel
Product of two kernels inducing the tensor product RKHS. Formula:k(x, y) = k₁(x, y) · k₂(x, y)
Mathematical property: The product of two PSD kernels is PSD.
Constructor
First kernel function
Second kernel function
Methods
operator()
Evaluates the product kernel.First input vector
Second input vector
Product of kernel evaluations: k₁(x, y) · k₂(x, y)
Example
ScaledKernel
Scalar multiplication of a kernel function. Formula:k(x, y) = α · k(x, y), where α ≥ 0
Mathematical property: Scalar multiplication by a non-negative constant preserves PSD.
Constructor
Scale factor α (must be non-negative)
Base kernel function to scale
Methods
operator()
Evaluates the scaled kernel.First input vector
Second input vector
Scaled kernel evaluation: α · k(x, y)
Example
ExponentialKernel
Exponentiated kernel transformation (advanced construction). Formula:k(x, y) = exp(k₀(x, y))
Mathematical property: Only PSD if the base kernel k₀ is conditionally PSD. This is provided as an advanced construction and should be used with care.
Constructor
Base kernel function k₀
Methods
operator()
Evaluates the exponentiated kernel.First input vector
Second input vector
Exponentiated kernel value: exp(k₀(x, y))
Example
Complex compositions
You can combine multiple composition operations to create sophisticated kernel functions:Design notes
Value semantics
All kernel composition classes work withKernelFunction, which provides value semantics (copyable and movable) while maintaining polymorphic behavior.
PSD preservation
SumKernel: Always preserves PSDProductKernel: Always preserves PSDScaledKernel: Preserves PSD if scale ≥ 0ExponentialKernel: Preserves PSD only under certain conditions on the base kernel
RKHS interpretation
- Sum: Direct sum of Hilbert spaces H₁ ⊕ H₂
- Product: Tensor product of Hilbert spaces H₁ ⊗ H₂
- Scaled: Scaled inner product space
- Exponential: Advanced transformation with complex RKHS structure