From ba99255bbba57d1f74520ce5c053e12d0a2636f9 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Mon, 15 Apr 2024 10:20:27 -0700 Subject: [PATCH] Switched to float for consistency with other distance functions --- .github/workflows/build.yml | 2 ++ src/sparsevec.c | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 478cc0a..6e2e0bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -115,6 +115,8 @@ jobs: sudo -u postgres make prove_installcheck env: PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare + - if: ${{ failure() }} + run: cat pgvector/regression.diffs valgrind: if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }} runs-on: ubuntu-latest diff --git a/src/sparsevec.c b/src/sparsevec.c index 82b52a1..073e031 100644 --- a/src/sparsevec.c +++ b/src/sparsevec.c @@ -594,12 +594,12 @@ vector_to_sparsevec(PG_FUNCTION_ARGS) /* * Get the L2 squared distance between sparse vectors */ -static double +static float SparsevecL2SquaredDistance(SparseVector * a, SparseVector * b) { float *ax = SPARSEVEC_VALUES(a); float *bx = SPARSEVEC_VALUES(b); - double distance = 0.0; + float distance = 0.0; int bpos = 0; for (int i = 0; i < a->nnz; i++) @@ -673,12 +673,12 @@ sparsevec_l2_squared_distance(PG_FUNCTION_ARGS) /* * Get the inner product of two sparse vectors */ -static double +static float SparsevecInnerProduct(SparseVector * a, SparseVector * b) { float *ax = SPARSEVEC_VALUES(a); float *bx = SPARSEVEC_VALUES(b); - double distance = 0.0; + float distance = 0.0; int bpos = 0; for (int i = 0; i < a->nnz; i++)