 |
MeLOn
|
Go to the documentation of this file.
28 template <
typename T,
typename V>
33 using RET = decltype(std::declval<T>() + std::declval<V>());
57 template <
typename T,
typename V>
58 class StationaryKernel :
public Kernel<T, V> {
73 for (
size_t i = 0; i < x1.size(); i++) {
74 distance += pow(x1.at(i) - x2.at(i), 2);
106 template <
typename T,
typename V>
107 class KernelCompositeAdd :
public Kernel<T, V> {
110 using typename Kernel<T, V>
::RET;
117 void add(std::shared_ptr<Kernel<T, V>> kernel) {
children.push_back(kernel); }
131 value += kernel->evaluate_kernel(x1, x2);
137 std::vector<std::shared_ptr<Kernel<T, V>>>
children;
144 template <
typename T,
typename V>
145 class KernelCompositeMultiply :
public Kernel<T, V> {
148 using typename Kernel<T, V>
::RET;
155 void add(std::shared_ptr<Kernel<T, V>> kernel) {
children.push_back(kernel); }
169 value *= kernel->k(x1, x2);
175 std::vector<std::shared_ptr<Kernel<T, V>>>
children;
182 template <
typename T,
typename V>
183 class KernelConstant :
public Kernel<T, V> {
186 using typename Kernel<T, V>
::RET;
229 template <
typename T,
typename V>
280 return exp(-
_gamma * distance);
RET calculate_distance(std::vector< T > x1, std::vector< V > x2) override
Function for calculating the distance used in the kernel (type of distance used can vary among kernel...
Definition: kernel.h:293
std::vector< std::shared_ptr< Kernel< T, V > > > children
Definition: kernel.h:201
std::vector< std::shared_ptr< Kernel< T, V > > > children
Definition: kernel.h:163
RET evaluate_kernel(std::vector< T > x1, std::vector< V > x2)
Function for evalualting the kernel.
Definition: kernel.h:242
virtual RET evaluate_kernel(std::vector< T > x1, std::vector< V > x2)=0
Function for evalualting the kernel for the points x1 and x2.
KernelConstant()
Constructor. Initializes the kernels return value to 1.
Definition: kernel.h:217
virtual RET calculate_distance(std::vector< T > x1, std::vector< V > x2)=0
Function for calculating the distance used in the kernel (type of distance used can vary among kernel...
KernelRBF(const double gamma)
Constructor.
Definition: kernel.h:266
void add(std::shared_ptr< Kernel< T, V >> kernel)
Function for adding another subkernel to the composite kernel.
Definition: kernel.h:143
RET evaluate_kernel(std::vector< T > x1, std::vector< V > x2) override
Function for evalualting the kernel.
Definition: kernel.h:278
RET evaluate_kernel(std::vector< T > x1, std::vector< V > x2)
Function for evalualting the kernel.
Definition: kernel.h:192
Abstract parent class for kernel implementations.
Definition: kernel.h:55
RET evaluate_kernel(std::vector< T > x1, std::vector< V > x2)
Function for evalualting the kernel.
Definition: kernel.h:154
virtual RET evaluate_kernel(RET distance)=0
Function for evalualting the kernel for a given distance.
const double _gamma
Definition: kernel.h:311
decltype(std::declval< T >()+std::declval< V >()) RET
Definition: kernel.h:59
Implementation of Radial Basis Function kernel.
Definition: kernel.h:256
virtual ~Kernel()=default
Destructor.
void add(std::shared_ptr< Kernel< T, V >> kernel)
Function for adding another subkernel to the composite kernel.
Definition: kernel.h:181
const RET _f
Definition: kernel.h:247
virtual RET _quadratic_distance(std::vector< T > x1, std::vector< V > x2)
Calculates the quadratic distance between two points x1 and x2.
Definition: kernel.h:96