KernelFunction
Type-erased value-semantic kernel handle that provides copyable, movable, and polymorphic kernel functionality.Constructor
Unique pointer to a concrete kernel implementation
Methods
operator()
Evaluates the kernel function on two input vectors.First input vector
Second input vector
Kernel evaluation result k(x, y)
valid()
Checks if the kernel function is initialized.True if the kernel contains a valid implementation, false otherwise
LinearKernel
Linear kernel corresponding to the identity feature map in ℝⁿ. Formula:k(x, y) = ⟨x, y⟩
The linear kernel computes the standard dot product between two vectors. It is the simplest kernel and corresponds to no transformation of the feature space.
Constructor
Default constructor with no parameters.Methods
operator()
Computes the dot product between two vectors.First input vector
Second input vector
Dot product ⟨x, y⟩
Example
PolynomialKernel
Polynomial kernel that generates a finite-dimensional RKHS with dimension growing combinatorially with the degree. Formula:k(x, y) = (γ ⟨x, y⟩ + c)^d
Constructor
Scale parameter γ for the dot product
Independent coefficient c (offset term)
Polynomial degree d
Methods
operator()
Computes the polynomial kernel between two vectors.First input vector
Second input vector
Polynomial kernel value (γ ⟨x, y⟩ + c)^d
Example
RBFKernel
Radial Basis Function (Gaussian) kernel that induces an infinite-dimensional, separable RKHS. Universally consistent under mild conditions. Formula:k(x, y) = exp(-γ ||x - y||²)
The RBF kernel is one of the most popular kernels in practice due to its smoothness properties and universal approximation capabilities.
Constructor
Bandwidth parameter γ controlling the kernel width. Larger values lead to more localized influence.
Methods
operator()
Computes the RBF kernel between two vectors.First input vector
Second input vector
RBF kernel value exp(-γ ||x - y||²)
Example
Kernel base class
Abstract base class for all kernel implementations.Methods
operator()
Pure virtual method for kernel evaluation.First input vector
Second input vector
Kernel evaluation k(x, y)
clone()
Creates a deep copy of the kernel.Unique pointer to a cloned kernel instance
Type aliases
Vector=std::vector<double>- Standard vector type used throughout the kernel API