24 #ifndef SOM_NEIGHBORHOODFUNC_H
25 #define SOM_NEIGHBORHOODFUNC_H
32 namespace NeighborhoodFunc {
38 double r_square = initial_radius * initial_radius;
41 double iter_factor = 1.0 * (total_iterations - iteration) / total_iterations;
42 iter_factor = iter_factor * iter_factor;
43 double x = bmu.first - cell.first;
44 double y = bmu.second - cell.second;
45 double dist_square = x * x + y * y;
46 if (dist_square < r_square * iter_factor) {
56 double init_sigma =
std::max(x_size, y_size) / 2.;
58 double cutoff_mult_square = sigma_cutoff_mult * sigma_cutoff_mult;
65 if (std::get<0>(sigma_buffer) != iteration || std::get<1>(sigma_buffer) != total_iterations) {
66 std::get<0>(sigma_buffer) = iteration;
67 std::get<1>(sigma_buffer) = total_iterations;
68 double time_constant = total_iterations /
std::log(init_sigma);
69 std::get<2>(sigma_buffer) = init_sigma *
std::exp(-1. * iteration / time_constant);
71 double sigma_square = std::get<2>(sigma_buffer) * std::get<2>(sigma_buffer);
73 double x =
static_cast<double>(bmu.first) - cell.first;
74 double y =
static_cast<double>(bmu.second) - cell.second;
75 double dist_square = x * x + y * y;
77 if (dist_square < cutoff_mult_square * sigma_square) {
78 return std::exp(-1. * dist_square / (2. * sigma_square));