Enabled "precise" mode; updated tests

This commit is contained in:
Alexey Milovidov 2019-08-01 22:17:49 +03:00
parent 99b9d354f7
commit 5c361c327b
15 changed files with 117 additions and 114 deletions

View File

@ -19,7 +19,7 @@ namespace
template <typename T>
static void execute(const T * src, size_t size, T * dst)
{
NFastOps::Exp<>(src, size, dst);
NFastOps::Exp<true>(src, size, dst);
}
};
}

View File

@ -19,7 +19,7 @@ namespace
template <typename T>
static void execute(const T * src, size_t size, T * dst)
{
NFastOps::Log<>(src, size, dst);
NFastOps::Log<true>(src, size, dst);
}
};
}

View File

@ -32,16 +32,16 @@ select tgamma(2) = 1;
select tgamma(3) = 2;
select tgamma(4) = 6;
select sum(abs(lgamma(x + 1) - log(tgamma(x + 1))) < 1.0e-9) / count() from system.one array join range(10) as x;
select sum(abs(lgamma(x + 1) - log(tgamma(x + 1))) < 1.0e-8) / count() from system.one array join range(10) as x;
select abs(e() - arraySum(arrayMap(x -> 1 / tgamma(x + 1), range(13)))) < 1.0e-9;
select log(0) = -inf;
select log(1) = 0;
select log(e()) = 1;
select log(exp(1)) = 1;
select log(exp(2)) = 2;
select sum(abs(log(exp(x)) - x) < 1.0e-9) / count() from system.one array join range(100) as x;
select abs(log(e()) - 1) < 1e-8;
select abs(log(exp(1)) - 1) < 1e-8;
select abs(log(exp(2)) - 2) < 1e-8;
select sum(abs(log(exp(x)) - x) < 1e-8) / count() from system.one array join range(100) as x;
select exp2(-1) = 1/2;
select exp2(0) = 1;

View File

@ -1,70 +1,70 @@
1 1.00 B 1 1.00 B 1 1.00 B
2.718282 2.72 B 2 2.00 B 2 2.00 B
7.389056 7.39 B 7 7.00 B 7 7.00 B
20.085537 20.09 B 20 20.00 B 20 20.00 B
54.59815 54.60 B 54 54.00 B 54 54.00 B
148.413159 148.41 B 148 148.00 B 148 148.00 B
403.428793 403.43 B 403 403.00 B 403 403.00 B
1096.633158 1.07 KiB 1096 1.07 KiB 1096 1.07 KiB
2980.957987 2.91 KiB 2980 2.91 KiB 2980 2.91 KiB
8103.083928 7.91 KiB 8103 7.91 KiB 8103 7.91 KiB
22026.465795 21.51 KiB 22026 21.51 KiB 22026 21.51 KiB
59874.141715 58.47 KiB 59874 58.47 KiB 59874 58.47 KiB
162754.791419 158.94 KiB 162754 158.94 KiB 162754 158.94 KiB
442413.392009 432.04 KiB 442413 432.04 KiB 442413 432.04 KiB
1202604.284165 1.15 MiB 1202604 1.15 MiB 1202604 1.15 MiB
3269017.372472 3.12 MiB 3269017 3.12 MiB 3269017 3.12 MiB
8886110.520508 8.47 MiB 8886110 8.47 MiB 8886110 8.47 MiB
24154952.753575 23.04 MiB 24154952 23.04 MiB 24154952 23.04 MiB
65659969.137331 62.62 MiB 65659969 62.62 MiB 65659969 62.62 MiB
178482300.963187 170.21 MiB 178482300 170.21 MiB 178482300 170.21 MiB
485165195.40979 462.69 MiB 485165195 462.69 MiB 485165195 462.69 MiB
1318815734.483214 1.23 GiB 1318815734 1.23 GiB 1318815734 1.23 GiB
3584912846.131592 3.34 GiB 3584912846 3.34 GiB -710054450 -677.16 MiB
9744803446.248903 9.08 GiB 9744803446 9.08 GiB 1154868854 1.08 GiB
26489122129.84347 24.67 GiB 26489122129 24.67 GiB 719318353 686.00 MiB
72004899337.38588 67.06 GiB 72004899337 67.06 GiB -1009544695 -962.78 MiB
195729609428.83878 182.29 GiB 195729609428 182.29 GiB -1838886188 -1.71 GiB
532048240601.79865 495.51 GiB 532048240601 495.51 GiB -527704103 -503.26 MiB
1446257064291.475 1.32 TiB 1446257064291 1.32 TiB -1146914461 -1.07 GiB
3931334297144.042 3.58 TiB 3931334297144 3.58 TiB 1439221304 1.34 GiB
10686474581524.463 9.72 TiB 10686474581524 9.72 TiB 595949076 568.34 MiB
29048849665247.426 26.42 TiB 29048849665247 26.42 TiB 1985842399 1.85 GiB
78962960182680.69 71.82 TiB 78962960182680 71.82 TiB -13554280 -12.93 MiB
214643579785916.06 195.22 TiB 214643579785916 195.22 TiB -1705798980 -1.59 GiB
583461742527454.9 530.66 TiB 583461742527454 530.66 TiB -974699554 -929.55 MiB
1586013452313430.8 1.41 PiB 1586013452313430 1.41 PiB -2005982378 -1.87 GiB
4311231547115195 3.83 PiB 4311231547115195 3.83 PiB -790034757 -753.44 MiB
11719142372802612 10.41 PiB 11719142372802612 10.41 PiB 1983119412 1.85 GiB
31855931757113756 28.29 PiB 31855931757113756 28.29 PiB 408891804 389.95 MiB
86593400423993740 76.91 PiB 86593400423993744 76.91 PiB 673862032 642.64 MiB
235385266837020000 209.06 PiB 235385266837020000 209.06 PiB 791567712 754.90 MiB
639843493530054900 568.30 PiB 639843493530054912 568.30 PiB 1874080000 1.75 GiB
1739274941520501000 1.51 EiB 1739274941520500992 1.51 EiB 538007808 513.08 MiB
4727839468229346000 4.10 EiB 4727839468229346304 4.10 EiB 2061616128 1.92 GiB
12851600114359308000 11.15 EiB 12851600114359308288 11.15 EiB -1681813504 -1.57 GiB
34934271057485095000 30.30 EiB 0 0.00 B 0 0.00 B
94961194206024480000 82.37 EiB 0 0.00 B 0 0.00 B
258131288619006750000 223.89 EiB 0 0.00 B 0 0.00 B
701673591209763100000 608.60 EiB 0 0.00 B 0 0.00 B
1.9073465724950998e21 1.62 ZiB 0 0.00 B 0 0.00 B
5.184705528587072e21 4.39 ZiB 0 0.00 B 0 0.00 B
1.4093490824269389e22 11.94 ZiB 0 0.00 B 0 0.00 B
3.831008000716577e22 32.45 ZiB 0 0.00 B 0 0.00 B
1.0413759433029089e23 88.21 ZiB 0 0.00 B 0 0.00 B
2.830753303274694e23 239.77 ZiB 0 0.00 B 0 0.00 B
7.694785265142018e23 651.77 ZiB 0 0.00 B 0 0.00 B
2.091659496012996e24 1.73 YiB 0 0.00 B 0 0.00 B
5.685719999335932e24 4.70 YiB 0 0.00 B 0 0.00 B
1.545538935590104e25 12.78 YiB 0 0.00 B 0 0.00 B
4.2012104037905144e25 34.75 YiB 0 0.00 B 0 0.00 B
1.1420073898156842e26 94.46 YiB 0 0.00 B 0 0.00 B
3.10429793570192e26 256.78 YiB 0 0.00 B 0 0.00 B
8.438356668741454e26 698.00 YiB 0 0.00 B 0 0.00 B
2.29378315946961e27 1897.37 YiB 0 0.00 B 0 0.00 B
6.235149080811617e27 5157.59 YiB 0 0.00 B 0 0.00 B
1.6948892444103338e28 14019.80 YiB 0 0.00 B 0 0.00 B
4.607186634331292e28 38109.75 YiB 0 0.00 B 0 0.00 B
1.2523631708422137e29 103593.05 YiB 0 0.00 B 0 0.00 B
3.404276049931741e29 281595.11 YiB 0 0.00 B 0 0.00 B
9.253781725587787e29 765454.88 YiB 0 0.00 B 0 0.00 B
1.00 B 1.00 B 1.00 B
2.72 B 2.00 B 2.00 B
7.39 B 7.00 B 7.00 B
20.09 B 20.00 B 20.00 B
54.60 B 54.00 B 54.00 B
148.41 B 148.00 B 148.00 B
403.43 B 403.00 B 403.00 B
1.07 KiB 1.07 KiB 1.07 KiB
2.91 KiB 2.91 KiB 2.91 KiB
7.91 KiB 7.91 KiB 7.91 KiB
21.51 KiB 21.51 KiB 21.51 KiB
58.47 KiB 58.47 KiB 58.47 KiB
158.94 KiB 158.94 KiB 158.94 KiB
432.04 KiB 432.04 KiB 432.04 KiB
1.15 MiB 1.15 MiB 1.15 MiB
3.12 MiB 3.12 MiB 3.12 MiB
8.47 MiB 8.47 MiB 8.47 MiB
23.04 MiB 23.04 MiB 23.04 MiB
62.62 MiB 62.62 MiB 62.62 MiB
170.21 MiB 170.21 MiB 170.21 MiB
462.69 MiB 462.69 MiB 462.69 MiB
1.23 GiB 1.23 GiB 1.23 GiB
3.34 GiB 3.34 GiB -677.16 MiB
9.08 GiB 9.08 GiB 1.08 GiB
24.67 GiB 24.67 GiB 686.00 MiB
67.06 GiB 67.06 GiB -962.78 MiB
182.29 GiB 182.29 GiB -1.71 GiB
495.51 GiB 495.51 GiB -503.26 MiB
1.32 TiB 1.32 TiB -1.07 GiB
3.58 TiB 3.58 TiB 1.34 GiB
9.72 TiB 9.72 TiB 568.34 MiB
26.42 TiB 26.42 TiB 1.85 GiB
71.82 TiB 71.82 TiB -12.93 MiB
195.22 TiB 195.22 TiB -1.59 GiB
530.66 TiB 530.66 TiB -929.55 MiB
1.41 PiB 1.41 PiB -1.87 GiB
3.83 PiB 3.83 PiB -753.44 MiB
10.41 PiB 10.41 PiB 1.85 GiB
28.29 PiB 28.29 PiB 389.95 MiB
76.91 PiB 76.91 PiB 642.59 MiB
209.06 PiB 209.06 PiB 755.06 MiB
568.30 PiB 568.30 PiB 1.75 GiB
1.51 EiB 1.51 EiB 511.72 MiB
4.10 EiB 4.10 EiB 1.92 GiB
11.15 EiB 11.15 EiB -1.57 GiB
30.30 EiB 0.00 B 0.00 B
82.37 EiB 0.00 B 0.00 B
223.89 EiB 0.00 B 0.00 B
608.60 EiB 0.00 B 0.00 B
1.62 ZiB 0.00 B 0.00 B
4.39 ZiB 0.00 B 0.00 B
11.94 ZiB 0.00 B 0.00 B
32.45 ZiB 0.00 B 0.00 B
88.21 ZiB 0.00 B 0.00 B
239.77 ZiB 0.00 B 0.00 B
651.77 ZiB 0.00 B 0.00 B
1.73 YiB 0.00 B 0.00 B
4.70 YiB 0.00 B 0.00 B
12.78 YiB 0.00 B 0.00 B
34.75 YiB 0.00 B 0.00 B
94.46 YiB 0.00 B 0.00 B
256.78 YiB 0.00 B 0.00 B
698.00 YiB 0.00 B 0.00 B
1897.37 YiB 0.00 B 0.00 B
5157.59 YiB 0.00 B 0.00 B
14019.80 YiB 0.00 B 0.00 B
38109.75 YiB 0.00 B 0.00 B
103593.05 YiB 0.00 B 0.00 B
281595.11 YiB 0.00 B 0.00 B
765454.88 YiB 0.00 B 0.00 B

View File

@ -1 +1,4 @@
SELECT round(exp(number), 6) AS x, formatReadableSize(x), toUInt64(x) AS y, formatReadableSize(y), toInt32(y) AS z, formatReadableSize(z) FROM system.numbers LIMIT 70;
WITH round(exp(number), 6) AS x, toUInt64(x) AS y, toInt32(y) AS z
SELECT formatReadableSize(x), formatReadableSize(y), formatReadableSize(z)
FROM system.numbers
LIMIT 70;

View File

@ -1,2 +1,2 @@
SELECT quantileTiming(number) FROM (SELECT * FROM system.numbers LIMIT 10000);
SELECT floor(log(1 + number) / log(1.5)) AS k, count() AS c, quantileTiming(number % 10000) AS q FROM (SELECT * FROM system.numbers LIMIT 1000000) GROUP BY k ORDER BY k;
SELECT floor(log2(1 + number) / log2(1.5)) AS k, count() AS c, quantileTiming(number % 10000) AS q FROM (SELECT * FROM system.numbers LIMIT 1000000) GROUP BY k ORDER BY k;

View File

@ -1,6 +1,6 @@
42.4200 3.7476 42.419153766068966
42.4200 5.4066 42.41786197045111
42.4200 1.6275 42.413098391048806
42.4200 3.7476 42.419154
42.4200 5.4066 42.417862
42.4200 1.6275 42.413098
42.4200 6.513 42.419169
42.4200 3.4875 42.417263671875
1.00000 0.8427007929497149 0.15729920705028513
@ -8,9 +8,9 @@
0.00 0 1 0
3.14159265 0 -1 -0
1.00 1.5707963267948966 0 0.7853981633974483
42.4200 3.7476 42.419153766068966
42.4200 5.4066 42.41786197045111
42.4200 1.6275 42.413098391048806
42.4200 3.7476 42.419154
42.4200 5.4066 42.417862
42.4200 1.6275 42.413098
42.4200 6.513 42.419169
42.4200 3.4875 42.417263671875
1.00000 0.8427007929497149 0.15729920705028513
@ -18,9 +18,9 @@
0.00 0 1 0
3.14159265358979328 0 -1 -0
1.00 1.5707963267948966 0 0.7853981633974483
42.4200 3.7476 42.419153766068966
42.4200 5.4066 42.41786197045111
42.4200 1.6275 42.413098391048806
42.4200 3.7476 42.419154
42.4200 5.4066 42.417862
42.4200 1.6275 42.413098
42.4200 6.513 42.419169
42.4200 3.4875 42.417263671875
1.00000 0.8427007929497149 0.15729920705028513

View File

@ -1,6 +1,6 @@
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, exp(y);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, exp2(y);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, exp10(y);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, round(exp(y), 6);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, round(exp2(y), 6);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, round(exp10(y), 6);
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(sqrt(x), 3) AS y, y * y;
SELECT toDecimal32('42.42', 4) AS x, toDecimal32(cbrt(x), 4) AS y, toDecimal64(y, 4) * y * y;
@ -12,9 +12,9 @@ SELECT toDecimal32(pi(), 8) AS x, round(sin(x), 8), round(cos(x), 8), round(tan(
SELECT toDecimal32('1.0', 2) AS x, asin(x), acos(x), atan(x);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, exp(y);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, exp2(y);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, exp10(y);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, round(exp(y), 6);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, round(exp2(y), 6);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, round(exp10(y), 6);
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(sqrt(x), 3) AS y, y * y;
SELECT toDecimal64('42.42', 4) AS x, toDecimal32(cbrt(x), 4) AS y, toDecimal64(y, 4) * y * y;
@ -26,9 +26,9 @@ SELECT toDecimal64(pi(), 17) AS x, round(sin(x), 8), round(cos(x), 8), round(tan
SELECT toDecimal64('1.0', 2) AS x, asin(x), acos(x), atan(x);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, exp(y);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, exp2(y);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, exp10(y);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log(x), 4) AS y, round(exp(y), 6);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log2(x), 4) AS y, round(exp2(y), 6);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(log10(x), 4) AS y, round(exp10(y), 6);
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(sqrt(x), 3) AS y, y * y;
SELECT toDecimal128('42.42', 4) AS x, toDecimal32(cbrt(x), 4) AS y, toDecimal64(y, 4) * y * y;

View File

@ -19,7 +19,7 @@
0 1 0 0 0 0
0 1 0 0 0 0
nan nan nan nan nan nan
nan nan nan nan nan nan nan nan nan
nan 0 nan nan nan nan nan nan nan
nan nan nan nan nan
nan nan nan nan nan nan nan
-1 1

View File

@ -22,7 +22,7 @@ SELECT -nan = toFloat64(0.0), -nan != toFloat64(0.0), -nan < toFloat64(0.0), -na
--SELECT 1 % nan, nan % 1, pow(x, 1), pow(1, x); -- TODO
SELECT 1 + nan, 1 - nan, nan - 1, 1 * nan, 1 / nan, nan / 1;
SELECT nan AS x, exp(x), exp2(x), exp10(x), log(x), log2(x), log10(x), sqrt(x), cbrt(x);
SELECT nan AS x, isFinite(exp(x)) /* exp(nan) is allowed to return inf */, exp2(x), exp10(x), log(x), log2(x), log10(x), sqrt(x), cbrt(x);
SELECT nan AS x, erf(x), erfc(x), lgamma(x), tgamma(x);
SELECT nan AS x, sin(x), cos(x), tan(x), asin(x), acos(x), atan(x);

View File

@ -23,4 +23,4 @@ SELECT number % 10 AS k, boundingRatio(1000 + number, number * 1.5 - 111) FROM n
SELECT boundingRatio(1000 + number, number * 1.5 - 111) FROM numbers(2);
SELECT boundingRatio(1000 + number, number * 1.5 - 111) FROM numbers(1);
SELECT boundingRatio(1000 + number, number * 1.5 - 111) FROM numbers(1) WHERE 0;
SELECT boundingRatio(number, exp(number)) = e() - 1 FROM numbers(2);
SELECT boundingRatio(number, exp(number)) = exp(1) - 1 FROM numbers(2);

View File

@ -1,10 +1,10 @@
0 0 6 6 6
0 5 5 1.7917595 5
1 1 2 1.0986123 42
1 1 2 1.0986123 42
2 2 4 1.609438 2
0 5 5 1.79176 5
1 1 2 1.09861 42
1 1 2 1.09861 42
2 2 4 1.60944 2
3 3 3 3 3
4 0 4 1.609438 42
{"x":7,"y":7,"a":"14","b":2.7080503,"c":42,"n.a":["1","2"],"n.b":["a","b"]}
{"x":8,"y":8,"a":"16","b":2.8332133,"c":42,"n.a":["3","4"],"n.c":[0,0],"n.b":["c","d"]}
{"x":9,"y":9,"a":"18","b":2.944439,"c":42,"n.a":[],"n.c":[],"n.b":[]}
4 0 4 1.60944 42
{"x":7,"y":7,"a":"14","b":2.70805,"c":42,"n.a":["1","2"],"n.b":["a","b"]}
{"x":8,"y":8,"a":"16","b":2.83321,"c":42,"n.a":["3","4"],"n.c":[0,0],"n.b":["c","d"]}
{"x":9,"y":9,"a":"18","b":2.94444,"c":42,"n.a":[],"n.c":[],"n.b":[]}

View File

@ -6,7 +6,7 @@ CREATE TABLE defaults
x UInt32,
y UInt32,
a DEFAULT x + y,
b Float32 DEFAULT log(1 + x + y),
b Float32 DEFAULT round(log(1 + x + y), 5),
c UInt32 DEFAULT 42,
e MATERIALIZED x + y,
f ALIAS x + y

View File

@ -1,6 +1,6 @@
{"x":0,"y":0,"a":"6","b":6,"c":6}
{"x":0,"y":5,"a":"5","b":1.7917595,"c":5}
{"x":1,"y":1,"a":"2","b":1.0986123,"c":42}
{"x":2,"y":2,"a":"4","b":1.609438,"c":2}
{"x":0,"y":5,"a":"5","b":1.79176,"c":5}
{"x":1,"y":1,"a":"2","b":1.09861,"c":42}
{"x":2,"y":2,"a":"4","b":1.60944,"c":2}
{"x":3,"y":3,"a":"3","b":3,"c":3}
{"x":4,"y":0,"a":"4","b":1.609438,"c":42}
{"x":4,"y":0,"a":"4","b":1.60944,"c":42}

View File

@ -4,7 +4,7 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
. $CURDIR/../shell_config.sh
$CLICKHOUSE_CLIENT --query="DROP TABLE IF EXISTS defaults"
$CLICKHOUSE_CLIENT --query="CREATE TABLE defaults (x UInt32, y UInt32, a DEFAULT x + y, b Float32 DEFAULT log(1 + x + y), c UInt32 DEFAULT 42, e MATERIALIZED x + y, f ALIAS x + y) ENGINE = Memory"
$CLICKHOUSE_CLIENT --query="CREATE TABLE defaults (x UInt32, y UInt32, a DEFAULT x + y, b Float32 DEFAULT round(log(1 + x + y), 5), c UInt32 DEFAULT 42, e MATERIALIZED x + y, f ALIAS x + y) ENGINE = Memory"
echo -ne '{"x":1, "y":1}\n' | ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL_PARAMS}&query=INSERT%20INTO%20defaults%20FORMAT%20JSONEachRow%20SETTINGS%20input_format_defaults_for_omitted_fields=1" --data-binary @-
echo -ne '{"x":2, "y":2, "c":2}\n' | ${CLICKHOUSE_CURL} -sS "${CLICKHOUSE_URL_PARAMS}&query=INSERT+INTO+defaults+FORMAT+JSONEachRow+SETTINGS+input_format_defaults_for_omitted_fields=1" --data-binary @-