25 namespace NeighborhoodFunc {
28 double r_square = initial_radius * initial_radius;
31 double iter_factor = 1.0 * (total_iterations - iteration) / total_iterations;
32 iter_factor = iter_factor * iter_factor;
33 double x = bmu.first - cell.first;
34 double y = bmu.second - cell.second;
35 double dist_square = x * x + y * y;
36 if (dist_square < r_square * iter_factor) {
46 double init_sigma =
std::max(x_size, y_size) / 2.;
48 double cutoff_mult_square = sigma_cutoff_mult * sigma_cutoff_mult;
55 if (std::get<0>(sigma_buffer) != iteration || std::get<1>(sigma_buffer) != total_iterations) {
56 std::get<0>(sigma_buffer) = iteration;
57 std::get<1>(sigma_buffer) = total_iterations;
58 double time_constant = total_iterations /
std::log(init_sigma);
59 std::get<2>(sigma_buffer) = init_sigma *
std::exp(-1. * iteration / time_constant);
61 double sigma_square = std::get<2>(sigma_buffer) * std::get<2>(sigma_buffer);
63 double x =
static_cast<double>(bmu.first) - cell.first;
64 double y = static_cast<double>(bmu.second) - cell.second;
65 double dist_square = x * x + y * y;
67 if (dist_square < cutoff_mult_square * sigma_square) {
68 return std::exp(-1. * dist_square / (2. * sigma_square));
ELEMENTS_API Signature linearUnitDisk(double initial_radius)
ELEMENTS_API Signature kohonen(std::size_t x_size, std::size_t y_size, double sigma_cutoff_mult=1.)