mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-15 09:06:56 +08:00
Switched to float for consistency with other distance functions
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@@ -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
|
||||||
|
|||||||
@@ -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++)
|
||||||
|
|||||||
Reference in New Issue
Block a user