commit 687e86ef25e9277b96906bc0ec78ac8a2938c8fe
parent 1aec72151cd8e04b4fe6022b0eeb4999b02b4fe8
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date: Sat, 7 Feb 2026 08:06:56 +0100
refactor(arrays): replace pow(x, 2.0) with direct multiplication in euclidean helpers
Diffstat:
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/arrays.c b/arrays.c
@@ -327,7 +327,7 @@ euclidean_norm(const double *a, const int n)
double out = 0.0;
for (i = 0; i < n; i++)
- out += pow(a[i], 2.0);
+ out += a[i] * a[i];
return sqrt(out);
}
@@ -339,7 +339,7 @@ euclidean_distance(const double *a, const double *b, const int n)
double out = 0.0;
for (i = 0; i < n; i++)
- out += pow(b[i] - a[i], 2.0);
+ out += (b[i] - a[i]) * (b[i] - a[i]);
return sqrt(out);
}