mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-13 16:16:56 +08:00
Improved consistency of sparsevec_l1_distance with vector [skip ci]
This commit is contained in:
@@ -862,7 +862,7 @@ sparsevec_l1_distance(PG_FUNCTION_ARGS)
|
|||||||
SparseVector *b = PG_GETARG_SPARSEVEC_P(1);
|
SparseVector *b = PG_GETARG_SPARSEVEC_P(1);
|
||||||
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;
|
||||||
|
|
||||||
CheckDims(a, b);
|
CheckDims(a, b);
|
||||||
@@ -897,7 +897,7 @@ sparsevec_l1_distance(PG_FUNCTION_ARGS)
|
|||||||
for (int j = bpos; j < b->nnz; j++)
|
for (int j = bpos; j < b->nnz; j++)
|
||||||
distance += fabsf(bx[j]);
|
distance += fabsf(bx[j]);
|
||||||
|
|
||||||
PG_RETURN_FLOAT8(distance);
|
PG_RETURN_FLOAT8((double) distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user