mirror of
https://github.com/pgvector/pgvector.git
synced 2026-07-14 08:36:54 +08:00
Fixed vector to sparsevec conversion
This commit is contained in:
@@ -570,7 +570,7 @@ vector_to_sparsevec(PG_FUNCTION_ARGS)
|
|||||||
if (j == nnz)
|
if (j == nnz)
|
||||||
elog(ERROR, "safety check failed");
|
elog(ERROR, "safety check failed");
|
||||||
|
|
||||||
result->indices[j] = i;
|
result->indices[j] = i + 1;
|
||||||
values[j] = vec->x[i];
|
values[j] = vec->x[i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ ERROR: expected 4 dimensions, not 5
|
|||||||
SELECT '[0,1.5,0,3.5,0]'::vector::sparsevec;
|
SELECT '[0,1.5,0,3.5,0]'::vector::sparsevec;
|
||||||
sparsevec
|
sparsevec
|
||||||
-----------------
|
-----------------
|
||||||
{1:1.5,3:3.5}/5
|
{2:1.5,4:3.5}/5
|
||||||
(1 row)
|
(1 row)
|
||||||
|
|
||||||
SELECT '{1:0,2:1,3:0}/3'::sparsevec;
|
SELECT '{1:0,2:1,3:0}/3'::sparsevec;
|
||||||
|
|||||||
Reference in New Issue
Block a user