From f3477cf28d8cc9d7d8926845a098a73950161692 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 8 Apr 2024 16:45:08 -0700 Subject: [PATCH] DRY vector_spherical_distance [skip ci] --- src/vector.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/vector.c b/src/vector.c index 54e6a3c..38be7f6 100644 --- a/src/vector.c +++ b/src/vector.c @@ -711,18 +711,11 @@ vector_spherical_distance(PG_FUNCTION_ARGS) { Vector *a = PG_GETARG_VECTOR_P(0); Vector *b = PG_GETARG_VECTOR_P(1); - float *ax = a->x; - float *bx = b->x; - float dp = 0.0; double distance; CheckDims(a, b); - /* Auto-vectorized */ - for (int i = 0; i < a->dim; i++) - dp += ax[i] * bx[i]; - - distance = (double) dp; + distance = (double) VectorInnerProduct(a->dim, a->x, b->x); /* Prevent NaN with acos with loss of precision */ if (distance > 1)