A. Improved |
initial writing: 2000-00-00 last updated: 2004-10-21 |
The dyad A. is now faster and uses less space,
especially when the right argument is i.n .
Time and space comparisons are as follows:
ts=: 6!:2 , 7!:2@] ts '(i.!n) A. i.n' NB. all permutations ts 'i A. i.n' [ i=: ?(!1>.n-1)$!n NB. random permutations
All Permutations
n | J 4.05 | J 4.04 |
1 | 4.441904e_5 1.600000e3 | 4.693333e_5 1.664000e3 |
2 | 4.441904e_5 1.600000e3 | 4.860952e_5 1.728000e3 |
3 | 4.777142e_5 1.792000e3 | 5.699047e_5 2.176000e3 |
4 | 7.123808e_5 2.816000e3 | 9.638094e_5 4.352000e3 |
5 | 2.857904e_4 1.100800e4 | 3.595428e_4 1.971200e4 |
6 | 1.465828e_3 7.315200e4 | 2.392762e_3 1.694080e5 |
7 | 1.100838e_2 5.749120e5 | 2.038834e_2 1.245632e6 |
8 | 1.047242e_1 4.588992e6 | 2.015694e_1 9.957824e6 |
9 | 1.057751e0 3.670163e7 | 2.049871e0 8.501805e7 |
Random Permutations
n | J 4.05 | J 4.04 |
1 | 3.687618e_5 1.408000e3 | 4.190476e_5 1.536000e3 |
2 | 3.771428e_5 1.472000e3 | 4.190476e_5 1.600000e3 |
3 | 3.855238e_5 1.536000e3 | 4.441904e_5 1.792000e3 |
4 | 4.358095e_5 1.792000e3 | 5.363809e_5 2.304000e3 |
5 | 7.542856e_5 3.456000e3 | 9.805713e_5 5.504000e3 |
6 | 3.084190e_4 1.004800e4 | 4.064761e_4 2.649600e4 |
7 | 1.659428e_3 6.892800e4 | 2.639162e_3 1.652480e5 |
8 | 1.243733e_2 5.420160e5 | 2.290933e_2 1.212800e6 |
9 | 1.168506e_1 4.326720e6 | 2.214423e_1 9.695616e6 |