mirror of
https://github.com/pgvector/pgvector.git
synced 2026-06-06 05:51:21 +08:00
147 lines
2.8 KiB
Plaintext
147 lines
2.8 KiB
Plaintext
SELECT l2_distance('[0,0]'::halfvec, '[3,4]');
|
|
l2_distance
|
|
-------------
|
|
5
|
|
(1 row)
|
|
|
|
SELECT l2_distance('[0,0]'::halfvec, '[0,1]');
|
|
l2_distance
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT l2_distance('[1,2]'::halfvec, '[3]');
|
|
ERROR: different halfvec dimensions 2 and 1
|
|
SELECT '[0,0]'::halfvec <-> '[3,4]';
|
|
?column?
|
|
----------
|
|
5
|
|
(1 row)
|
|
|
|
SELECT inner_product('[1,2]'::halfvec, '[3,4]');
|
|
inner_product
|
|
---------------
|
|
11
|
|
(1 row)
|
|
|
|
SELECT inner_product('[1,2]'::halfvec, '[3]');
|
|
ERROR: different halfvec dimensions 2 and 1
|
|
SELECT inner_product('[65504]'::halfvec, '[65504]');
|
|
inner_product
|
|
---------------
|
|
4290774016
|
|
(1 row)
|
|
|
|
SELECT '[1,2]'::halfvec <#> '[3,4]';
|
|
?column?
|
|
----------
|
|
-11
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,2]'::halfvec, '[2,4]');
|
|
cosine_distance
|
|
-----------------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,2]'::halfvec, '[0,0]');
|
|
cosine_distance
|
|
-----------------
|
|
NaN
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,1]'::halfvec, '[1,1]');
|
|
cosine_distance
|
|
-----------------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,0]'::halfvec, '[0,2]');
|
|
cosine_distance
|
|
-----------------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,1]'::halfvec, '[-1,-1]');
|
|
cosine_distance
|
|
-----------------
|
|
2
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,2]'::halfvec, '[3]');
|
|
ERROR: different halfvec dimensions 2 and 1
|
|
SELECT cosine_distance('[1,1]'::halfvec, '[1.1,1.1]');
|
|
cosine_distance
|
|
-----------------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT cosine_distance('[1,1]'::halfvec, '[-1.1,-1.1]');
|
|
cosine_distance
|
|
-----------------
|
|
2
|
|
(1 row)
|
|
|
|
SELECT '[1,2]'::halfvec <=> '[2,4]';
|
|
?column?
|
|
----------
|
|
0
|
|
(1 row)
|
|
|
|
SELECT l1_distance('[0,0]'::halfvec, '[3,4]');
|
|
l1_distance
|
|
-------------
|
|
7
|
|
(1 row)
|
|
|
|
SELECT l1_distance('[0,0]'::halfvec, '[0,1]');
|
|
l1_distance
|
|
-------------
|
|
1
|
|
(1 row)
|
|
|
|
SELECT l1_distance('[1,2]'::halfvec, '[3]');
|
|
ERROR: different halfvec dimensions 2 and 1
|
|
SELECT quantize_binary('[1,0,-1]'::halfvec);
|
|
quantize_binary
|
|
-----------------
|
|
100
|
|
(1 row)
|
|
|
|
SELECT quantize_binary('[0,0.1,-0.2,-0.3,0.4,0.5,0.6,-0.7,0.8,-0.9,1]'::halfvec);
|
|
quantize_binary
|
|
-----------------
|
|
01001110101
|
|
(1 row)
|
|
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, 1, 3);
|
|
subvector
|
|
-----------
|
|
[1,2,3]
|
|
(1 row)
|
|
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, 3, 2);
|
|
subvector
|
|
-----------
|
|
[3,4]
|
|
(1 row)
|
|
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, -1, 3);
|
|
subvector
|
|
-----------
|
|
[1]
|
|
(1 row)
|
|
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, 3, 9);
|
|
subvector
|
|
-----------
|
|
[3,4,5]
|
|
(1 row)
|
|
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, 1, 0);
|
|
ERROR: halfvec must have at least 1 dimension
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, 3, -1);
|
|
ERROR: halfvec must have at least 1 dimension
|
|
SELECT subvector('[1,2,3,4,5]'::halfvec, -1, 2);
|
|
ERROR: halfvec must have at least 1 dimension
|