| #include <cmath> |
| namespace { |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| void gauss_distribution_1d_(double *sequence, |
| const int int_diameter |
| , |
| const int int_radius, const double real_radius, |
| const double sigma |
| ) { |
| |
| for (int ii = 0; ii < int_diameter; ++ii) { |
| sequence[ii] = 0.0; |
| } |
| |
| |
| const int int_radius2 = (0 < int_radius) ? int_radius : 1; |
| const double real_radius2 = |
| (0. < real_radius) ? real_radius : 0.000000000000001; |
| |
| |
| |
| double dd = -1.0 * int_radius2 / real_radius2; |
| |
| |
| const double delta = -dd / int_radius2; |
| |
| |
| const int start_pos = (int_diameter - (int_radius2 * 2 + 1)) / 2; |
| |
| |
| const int end_pos = int_diameter - start_pos; |
| |
| |
| for (int ii = start_pos; ii < end_pos; ++ii) { |
| sequence[ii] = exp(-(dd * dd) / (2.0 * sigma * sigma)); |
| dd += delta; |
| } |
| |
| dd = 0.0; |
| for (int ii = start_pos; ii < end_pos; ++ii) { |
| dd += sequence[ii]; |
| } |
| |
| for (int ii = start_pos; ii < end_pos; ++ii) { |
| sequence[ii] /= dd; |
| } |
| } |
| } |