From 2883b57eb36363412d46b57ba2423b69d7cf9b9d Mon Sep 17 00:00:00 2001 From: Al Date: Mon, 22 Jan 2018 01:07:52 -0500 Subject: [PATCH] [fix] sqrt in l2 norm --- src/vector_math.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector_math.h b/src/vector_math.h index 3c964581..14aaf7a1 100644 --- a/src/vector_math.h +++ b/src/vector_math.h @@ -202,12 +202,12 @@ return result; \ } \ \ - static inline unsigned_type name##_l2_norm(type *array, size_t n) { \ + static inline double name##_l2_norm(type *array, size_t n) { \ unsigned_type result = 0; \ for (size_t i = 0; i < n; i++) { \ result += array[i] * array[i]; \ } \ - return result; \ + return sqrt((double)result); \ } \ \ static inline double name##_mean(type *array, size_t n) { \