Switched to float for consistency with other distance functions

This commit is contained in:
Andrew Kane
2024-04-15 10:20:27 -07:00
parent 55845bfd5f
commit ba99255bbb
2 changed files with 6 additions and 4 deletions

View File

@@ -115,6 +115,8 @@ jobs:
sudo -u postgres make prove_installcheck sudo -u postgres make prove_installcheck
env: env:
PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare PG_CFLAGS: -DUSE_ASSERT_CHECKING -Wall -Wextra -Werror -Wno-unused-parameter -Wno-sign-compare
- if: ${{ failure() }}
run: cat pgvector/regression.diffs
valgrind: valgrind:
if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }} if: ${{ !startsWith(github.ref_name, 'mac') && !startsWith(github.ref_name, 'windows') }}
runs-on: ubuntu-latest runs-on: ubuntu-latest

View File

@@ -594,12 +594,12 @@ vector_to_sparsevec(PG_FUNCTION_ARGS)
/* /*
* Get the L2 squared distance between sparse vectors * Get the L2 squared distance between sparse vectors
*/ */
static double static float
SparsevecL2SquaredDistance(SparseVector * a, SparseVector * b) SparsevecL2SquaredDistance(SparseVector * a, SparseVector * b)
{ {
float *ax = SPARSEVEC_VALUES(a); float *ax = SPARSEVEC_VALUES(a);
float *bx = SPARSEVEC_VALUES(b); float *bx = SPARSEVEC_VALUES(b);
double distance = 0.0; float distance = 0.0;
int bpos = 0; int bpos = 0;
for (int i = 0; i < a->nnz; i++) 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 * Get the inner product of two sparse vectors
*/ */
static double static float
SparsevecInnerProduct(SparseVector * a, SparseVector * b) SparsevecInnerProduct(SparseVector * a, SparseVector * b)
{ {
float *ax = SPARSEVEC_VALUES(a); float *ax = SPARSEVEC_VALUES(a);
float *bx = SPARSEVEC_VALUES(b); float *bx = SPARSEVEC_VALUES(b);
double distance = 0.0; float distance = 0.0;
int bpos = 0; int bpos = 0;
for (int i = 0; i < a->nnz; i++) for (int i = 0; i < a->nnz; i++)