Tests with long arrays

This commit is contained in:
Alexander Gololobov 2022-07-02 22:13:48 +02:00
parent 7adc87a37d
commit 92cbc2a3b5
4 changed files with 111 additions and 27 deletions

View File

@ -32,21 +32,51 @@ nan
0.020204102886728692
0.11808289631180313
0
1 1 218.74642854227358 47850
1 2 1348.2117786164013 1817675
2 1 219.28064210048274 48084
2 2 1347.4008312302617 1815489
3 1 214.35251339790725 45947
3 2 1342.8856987845243 1803342
1 1 218.74642854227358 47850
1 2 1348.2117786164013 1817675
2 1 219.28064210048274 48084
2 2 1347.4008312302617 1815489
3 1 214.35251339790725 45947
3 2 1342.8856987845243 1803342
1 1 218.74642854227358 47850
1 2 1348.2117786164013 1817675
2 1 219.28064210048274 48084
2 2 1347.4008312302617 1815489
3 1 214.35251339790725 45947
3 2 1342.8856987845243 1803342
1 1 0 0 0 0 0 0
1 2 2031 788 981.3289733414064 1182.129011571918 1397429 0.1939823640079572
2 1 2031 788 981.3289733414064 1182.129011571918 1397429 0.1939823640079572
2 2 0 0 0 0 0 0
3 3 0 0 0 0 0 0
3 4 68 2 6.238144819822315 11.661903789690601 136 0.0010041996325123037
4 3 68 2 6.238144819822315 11.661903789690601 136 0.0010041996325123037
4 4 0 0 0 0 0 0
5 5 0 0 0 0 0 0
5 6 268 2 9.70940985211152 23.15167380558045 536 0.00007815428961455151
6 5 268 2 9.70940985211152 23.15167380558045 536 0.00007815428961455151
6 6 0 0 0 0 0 0
1 1 0 0 0 0 0 0
1 2 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 1 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 2 0 0 0 0 0 0
3 3 0 0 0 0 0 0
3 4 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 3 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 4 0 0 0 0 0 0
5 5 0 0 0 0 0 0
5 6 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 5 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 6 0 0 0 0 0 0
1 1 0 0 0 0 0 0
1 2 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 1 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 2 0 0 0 0 0 0
3 3 0 0 0 0 0 0
3 4 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 3 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 4 0 0 0 0 0 0
5 5 0 0 0 0 0 0
5 6 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 5 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 6 0 0 0 0 0 0
1 1 0 0 0 0 0 0
1 2 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 1 2031 788 992.2102104083964 1182.129011571918 1397429 0.1939823640079572
2 2 0 0 0 0 0 0
3 3 0 0 0 0 0 0
3 4 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 3 68 2 6.479223602554966 11.661903789690601 136 0.0010041996325123037
4 4 0 0 0 0 0 0
5 5 0 0 0 0 0 0
5 6 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 5 268 2 10.234459893824097 23.15167380558045 536 0.00007815428961455151
6 6 0 0 0 0 0 0

View File

@ -37,14 +37,56 @@ SELECT cosineDistance([3, 2, 1], v) FROM vec1;
SELECT LinfDistance(v, materialize([0, -2, 0])) FROM vec1;
SELECT cosineDistance(v, materialize([1., 1., 1.])) FROM vec1;
INSERT INTO vec2 VALUES (1, [100, 200, 0]), (2, [888, 777, 666]);
SELECT v1.id, v2.id, L2Distance(v1.v, v2.v), L2SquaredDistance(v1.v, v2.v) as dist FROM vec1 v1, vec2 v2;
INSERT INTO vec2 VALUES (1, [100, 200, 0]), (2, [888, 777, 666]), (3, range(1, 35, 1)), (4, range(3, 37, 1)), (5, range(1, 135, 1)), (6, range(3, 137, 1));
SELECT
v1.id,
v2.id,
L1Distance(v1.v, v2.v),
LinfDistance(v1.v, v2.v),
LpDistance(v1.v, v2.v, 3.1),
L2Distance(v1.v, v2.v),
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2 v1, vec2 v2
WHERE length(v1.v) == length(v2.v);
INSERT INTO vec2f VALUES (1, [100, 200, 0]), (2, [888, 777, 666]);
SELECT v1.id, v2.id, L2Distance(v1.v, v2.v), L2SquaredDistance(v1.v, v2.v) as dist FROM vec1 v1, vec2f v2;
INSERT INTO vec2f VALUES (1, [100, 200, 0]), (2, [888, 777, 666]), (3, range(1, 35, 1)), (4, range(3, 37, 1)), (5, range(1, 135, 1)), (6, range(3, 137, 1));
SELECT
v1.id,
v2.id,
L1Distance(v1.v, v2.v),
LinfDistance(v1.v, v2.v),
LpDistance(v1.v, v2.v, 3),
L2Distance(v1.v, v2.v),
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2f v1, vec2f v2
WHERE length(v1.v) == length(v2.v);
INSERT INTO vec2d VALUES (1, [100, 200, 0]), (2, [888, 777, 666]);
SELECT v1.id, v2.id, L2Distance(v1.v, v2.v), L2SquaredDistance(v1.v, v2.v) as dist FROM vec1 v1, vec2d v2;
INSERT INTO vec2d VALUES (1, [100, 200, 0]), (2, [888, 777, 666]), (3, range(1, 35, 1)), (4, range(3, 37, 1)), (5, range(1, 135, 1)), (6, range(3, 137, 1));
SELECT
v1.id,
v2.id,
L1Distance(v1.v, v2.v),
LinfDistance(v1.v, v2.v),
LpDistance(v1.v, v2.v, 3),
L2Distance(v1.v, v2.v),
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2d v1, vec2d v2
WHERE length(v1.v) == length(v2.v);
SELECT
v1.id,
v2.id,
L1Distance(v1.v, v2.v),
LinfDistance(v1.v, v2.v),
LpDistance(v1.v, v2.v, 3),
L2Distance(v1.v, v2.v),
L2SquaredDistance(v1.v, v2.v),
cosineDistance(v1.v, v2.v)
FROM vec2f v1, vec2d v2
WHERE length(v1.v) == length(v2.v);
SELECT L1Distance([0, 0], [1]); -- { serverError 190 }
SELECT L2Distance([1, 2], (3,4)); -- { serverError 43 }

View File

@ -8,23 +8,35 @@
2 2 2 4 2 2
3 9 5.196152422706632 27 4.506432087111623 3
4 0 0 0 0 0
5 330 78.16648898345122 6110 54.82161001608108 26
6 5250 599.12436104702 358950 350.73959029428204 102
1 11
2 11
3 11
4 11
5 11
6 11
1 7 5 25 4.601724723020627 4
2 2 2 4 2 2
3 9 5.196152422706632 27 4.506432087111623 3
4 0 0 0 0 0
5 330 78.16648898345122 6110 54.82161001608108 26
6 5250 599.12436104702 358950 350.73959029428204 102
1 11
2 11
3 11
4 11
5 11
6 11
1 7 5 25 4.601724723020627 4
2 2 2 4 2 2
3 9 5.196152422706632 27 4.506432087111623 3
4 0 0 0 0 0
5 330 78.16648898345122 6110 54.82161001608108 26
6 5250 599.12436104702 358950 350.73959029428204 102
1 11
2 11
3 11
4 11
5 11
6 11

View File

@ -21,9 +21,9 @@ DROP TABLE IF EXISTS vec1d;
CREATE TABLE vec1 (id UInt64, v Array(UInt8)) ENGINE = Memory;
CREATE TABLE vec1f (id UInt64, v Array(Float32)) ENGINE = Memory;
CREATE TABLE vec1d (id UInt64, v Array(Float64)) ENGINE = Memory;
INSERT INTO vec1 VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL);
INSERT INTO vec1f VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL);
INSERT INTO vec1d VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL);
INSERT INTO vec1 VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL), (5, range(7, 27)), (6, range(3, 103));
INSERT INTO vec1f VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL), (5, range(7, 27)), (6, range(3, 103));
INSERT INTO vec1d VALUES (1, [3, 4]), (2, [2]), (3, [3, 3, 3]), (4, NULL), (5, range(7, 27)), (6, range(3, 103));
SELECT id, L1Norm(v), L2Norm(v), L2SquaredNorm(v), LpNorm(v, 2.7), LinfNorm(v) FROM vec1;
SELECT id, L1Norm(materialize([5., 6.])) FROM vec1;