-
Notifications
You must be signed in to change notification settings - Fork 3
/
benchmarks.txt
290 lines (203 loc) · 11.1 KB
/
benchmarks.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
<h2>Benchmarks</h2>
<p>This page shows how Nemo compares to other computer algebra software on a selection of
artificial benchmarks.</p>
<h3>Fateman benchmark</h3>
<ul>
<li>f = 1 + x + y + z + t</li>
<li>p = f^30</li>
<li>time q = p*(p + 1)</li>
</ul>
<p>This benchmark tests generic polynomial arithmetic. Note that we don't have a dedicated multivariate polynomial module in Nemo yet, so this and the next benchmark are done with nested univariate polynomial rings. Where possible we do the same thing in the other systems we time (Pari/GP is an exception).</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.3</th></tr>
<tr><td>132s</td> <td>156s</td> <td>233s</td> <td>44s</td></tr>
</table>
</div>
<h3>Pearce benchmark</h3>
<ul>
<li>f = (x + y + 2z^2 + 3t^3 + 5u^5 + 1)^16</li>
<li>g = (u + t + 2z^2 + 3y^3 + 5x^5 + 1)^16</li>
<li>time q = f*g</li>
</ul>
<p>This benchmark is usually done with sparse multivariate polynomial arithmetic. We use it
here with our recursive dense polynomial arithmetic (there is no sparse polynomial representation in Nemo yet).</p>
<p>Note: this is not fair to other packages that implement sparse multivariate polynomial arithmetic,
as they could complete this benchmark faster if we used their sparse arithmetic. But that
would not be a very meaningful benchmark if the aim is to measure the relative performance
of the recursive dense polynomial arithmetic in Nemo. On the other hand, Pari/GP uses a
sparse-recursive representation (similar to recursive-dense, but with dedicated zero objects in each ring).</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.3</th></tr>
<tr><td>2900s</td> <td>798s</td> <td>647s</td> <td>167s</td></tr>
</table>
</div>
<h3>Resultant benchmark</h3>
<ul>
<li>R<x> = GF(17^11)</li>
<li>S = R[y]</li>
<li>T = S/(y^3 + 3x*y + 1)</li>
<li>U = T[z]</li>
<li>f = T(3y^2 + y + x)*z^2 + T((x + 2)*y^2 + x + 1)*z + T(4x*y + 3)</li>
<li>g = T(7y^2 - y + 2x + 7)*z^2 + T(3y^2 + 4x + 1)*z + T((2x + 1)*y + 1)</li>
<li>s = f^12</li>
<li>t = (s + g)^12</li>
<li>time r = resultant(s, t)</li>
</ul>
<p>This benchmark is designed to test generics, division and computation of the resultant.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.3</th></tr>
<tr><td> 179907s</td> <td>N/A</td> <td>82s</td> <td>0.2s</td></tr>
</table>
</div>
<h3>Bernoulli polynomials</h3>
<ul>
<li>R = QQ[x]</li>
<li>S = R[[t]]</li>
<li>u = t + O(t^1000)</li>
<li>time r = (u*exp(x*u))/(exp(u)-1))</li>
</ul>
<p>This benchmark is designed to test generic power series.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.3</th></tr>
<tr><td>161s</td> <td>235s</td> <td>4223s</td> <td>65s</td></tr>
</table>
</div>
<h3>Polynomials over number fields</h3>
<ul>
<li>R, x = CyclotomicField(20)</li>
<li>S = R[y]</li>
<li>f = (3x^7 + x^4 - 3x + 1)*y^3 + (2x^6-x^5+4x^4-x^3+x^2-1)*y +(-3x^7+2x^6-x^5+3x^3-2x^2+x)</li>
<li>time r = f^300</li>
</ul>
<p>This benchmark is designed to test dense polynomials over number fields.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.3</th></tr>
<tr><td>6.92s</td> <td>0.21s</td> <td>0.70s</td> <td>0.13s</td></tr>
</table>
</div>
<h3>Determinant over a commutative ring</h3>
<ul>
<li>n = 2003*1009</li>
<li>R = (Z/nZ)[x]</li>
<li>M is an 80x80 matrix with entries in R of random degree of at most 5 and
coefficients in the range [-100, 100] modulo n</li>
<li>time d = determinant(M)</li>
</ul>
<p>This benchmark is designed to test determinant over a generic commutative
ring. Note Pari cheats here and does divisions, which will occasionally cause
it to fail on such examples.<p>
<p>Magma exhausts the memory on the machine after some hours. Timings indicate
it uses an exponential algorithm which would take > 42369865294301626368s were
it given infinite memory.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>43.5s</td> <td>456s</td> <td>-</td> <td>7.5s</td></tr>
</table>
</div>
<h3>Determinant over a field</h3>
<ul>
<li>K, a = NumberField(x^3 + 3x + 1)</li>
<li>M is an 80x80 matrix with random entries in K of the form c_0 + c_1*a + c_2*a^2 with c_i in the range [-100, 100]</li>
<li>time d = determinant(M)</li>
</ul>
<p>This benchmark is designed to test determinant over a field where there is
coefficient blowup.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>5893s</td> <td>21.9s</td> <td>5.3s</td> <td>2.4s</td></tr>
</table>
</div>
<h3>Determinant of a matrix over a polynomial ring</h3>
<ul>
<li>M is an 40x40 matrix with random entries in ZZ[x] of the form c_0 + c_1*x + c_2*x^2 with c_i in the range [-20, 20]</li>
<li>time d = determinant(M)</li>
</ul>
<p>This benchmark is designed to test determinant over a polynomial ring over an integral domain.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>6.3s</td> <td>1.3s</td> <td>3.2s</td> <td>0.24s</td></tr>
</table>
</div>
<h3>Linear solving over a polynomial ring</h3>
<ul>
<li>M is an 20x20 matrix with random entries in ZZ[x][y] that are quadratic polynomials in y with coefficients of the form c_0 + c_1*x + c_2*x^2 with c_i in the range [-20, 20], and b is a 20x1 matrix over the same ring</li>
<li>time v, d = solve(M, b)</li>
</ul>
<p>The computation finds a 20x1 matrix v over ZZ[x][y] and a denominator d in ZZ[x][y] such that Av = db.</p>
<p>This benchmark is designed to test linear solving over a generic polynomial ring.</p>
<p>SageMath exhausted the memory on the machine and didn't complete, possibly because it doesn't reduce the bivariate rational functions that result, at any stage. On the other hand, we were forcing SageMath to work in iterated univariate polynomial rings rather than a true bivariate polynomial ring, which may explain the slowdown and memory use.</p>
<p>Magma requires the computation to be performed over the fraction field.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.8</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>> 100000s</td> <td>> 1300000s</td> <td>90s</td> <td>7s</td></tr>
</table>
</div>
<h3>Characteristic polynomial of a matrix over the integers</h3>
<ul>
<li>M is an 80x80 matrix with random entries in ZZ in the range [-20, 20]</li>
<li>time d = charpoly(M)</li>
</ul>
<p>This benchmark doesn't really test Nemo but the underlying Flint library.
However, the benchmark resulted from work done in Nemo that got moved into
Flint. Julia code can be quite easy to port to C in certain circumstances.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.9</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>0.20s</td> <td>0.58s</td> <td>0.06s</td> <td>0.04s</td></tr>
</table>
</div>
<h3>Minimal polynomial of a matrix over a gcd domain</h3>
<ul>
<li>Let M be a 20x20 matrix with random entries in ZZ[x] of degree 2 with coefficients in the range [-20, 20], but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter</li>
<li>Let P(r, d) denote a 20x20 identity matrix the zero entries of whose r-th row have been replaced with the value d</li>
<li>Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 20] and d in the range [-3:3]</li>
<li>time d = minpoly(M)</li>
</ul>
<p>This benchmark tests minimal polynomial over a gcd domain (i.e. not over a field).</p>
<p>Magma refuses to do this computation and Sage throws an exception. Pari/GP was terminated due to long running.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.9</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>--</td> <td>> 680000s</td> <td>--</td> <td>0.6s</td></tr>
</table>
</div>
<h3>Minimal polynomial of a matrix over a finite field</h3>
<ul>
<li>Let R be a finite field of order 103^2</li>
<li>Let M be a 80x80 matrix with random entries in R, but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter</li>
<li>Let P(r, d) denote an 80x80 identity matrix the zero entries of whose r-th row have been replaced with the value d</li>
<li>Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 80] and d in the range [-3:3]</li>
<li>time d = minpoly(M)</li>
</ul>
<p>This benchmark tests minimal polynomial over a finite field, and finite field arithmetic.</p>
<p>Magma is so fast in this example because it uses Zech logarithms and because it just has very fast finite field arithmetic. We are currently using generic matrices over Flint finite field elements and we are not using Zech logarithms. Both are areas for future improvement.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.9</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>10.6s</td> <td>2515s</td> <td>0.005s</td> <td>0.4s</td></tr>
</table>
</div>
<h3>Minimal polynomial of a matrix over the integers</h3>
<ul>
<li>Let M be a 80x80 matrix with random entries in ZZ in the range [-20, 20], but such that the upper right and lower left quarters of the matrix are zero and the lower right quarter is identical to the upper left quarter</li>
<li>Let P(r, d) denote an 80x80 identity matrix the zero entries of whose r-th row have been replaced with the value d</li>
<li>Apply ten random similarity transforms M = P^{-1}MP to M where each P is a matrix of the form P(r, d) for r in the range [1, 80] and d in the range [-3:3]</li>
<li>time d = minpoly(M)</li>
</ul>
<p>This benchmark doesn't really test Nemo, but Flint. However the implementation was a result of work carried out first in Nemo and then ported to Flint.</p>
<p>Pari/GP eventually exhausted the memory on the machine and did not complete.</p>
<div align="center">
<table class="benchmark">
<tr><th>SageMath 6.9</th> <th>Pari/GP 2.7.4</th> <th>Magma V2.21-4</th> <th>Nemo-0.4</th></tr>
<tr><td>0.07s</td> <td>> 600000s</td> <td>0.05s</td> <td>0.04s</td></tr>
</table>
</div>