diff options
Diffstat (limited to 'util.h')
-rw-r--r-- | util.h | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -21,6 +21,23 @@ exit(EXIT_FAILURE); \ } while (0) +// calculate squared euclidean distance between two points +static inline float +distance_squared( + const size_t num_floats, + const float * const a, + const float * const b +) { + float r = 0.0; + + for (size_t i = 0; i < num_floats; i++) { + r += (b[i] - a[i]) * (b[i] - a[i]); + } + + // return squared distance + return r; +} + static inline float km_score( const float mean_distance, |