-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel_function.h
More file actions
31 lines (27 loc) · 817 Bytes
/
kernel_function.h
File metadata and controls
31 lines (27 loc) · 817 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#ifndef KERNEL_FUNCTION_H
#define KERNEL_FUNCTION_H
#include <vector>
/* standard gaussian kernel */
class Kernel_Function {
public:
// constructor
Kernel_Function(const double epsilon):_epsilon(epsilon) {}
// copy constructor
Kernel_Function(const Kernel_Function& gk):_epsilon(gk._epsilon) {}
// move constructor
Kernel_Function(Kernel_Function&& gk): _epsilon(std::move(gk._epsilon)) {}
/* no assignment operator, only const members */
~Kernel_Function() {}
double operator()(const std::vector<double>& x1, const std::vector<double>& x2) const {
int n = x1.size();
double norm = 0;
for(int i = 0; i < n; i++) {
norm += std::pow(x1[i] - x2[i], 2);
}
return std::exp(-norm/(_epsilon*_epsilon));
}
private:
/* const double _epsilon; */
double _epsilon;
};
#endif