Stackermann: Difference between revisions
(Created page with "{{lowercase}} '''stackermann''' is a program that calculates the w:Ackermann function. It utilises [http://gmplib.org/ GMP] in conjunction with a simplistic stack data-ty...") |
m (→Benchmark mode) |
||
Line 31: | Line 31: | ||
===Benchmark mode=== | ===Benchmark mode=== | ||
In benchmark mode (the <tt>-b</tt> option), stackermann does not print the calculated value at all; instead, it prints statistics on what it took to calculate it. The output produced is printed as a space-separated list | In benchmark mode (the <tt>-b</tt> option), stackermann does not print the calculated value at all; instead, it prints statistics on what it took to calculate it. The output produced is printed as a space-separated list of—respectively—total computation time in seconds, total number of stack pushes, maximum number of stack entries, and approximate maximum stack size in bytes. | ||
<pre>$ stackermann -b 4 2 | <pre>$ stackermann -b 4 2 | ||
0.050 131103 65534 1048552</pre> | 0.050 131103 65534 1048552</pre> |
Revision as of 02:48, 17 August 2013
stackermann is a program that calculates the Ackermann function. It utilises GMP in conjunction with a simplistic stack data-type to calculate the enormous values efficiently.
Limitations
To improve efficiency, stackermann does not allow the m-parameter to be greater than 255. In reality, this is unlikely to pose a problem, since no current computer will have the memory or speed required to compute the values with high m-parameters anyway.
Dependencies
- UNIX-like system (probably includes Cygwin; not tested, though.)
- ≥ gmp-4.0
Additionally, accurate computation timing requires librt; this is used by default and is present on just about any sane system.
Obtaining stackermann
stackermann is available as a source tarball at http://proj.penguindevelopment.org/stackermann/. Direct link to the latest version.
Installation follows the usual configure/make/make install procedure.
Quick overview
Normal usage
Given m and n, stackermann simply calculates the value and prints it to stdout:
$ stackermann 4 1 A(4, 1)=65533
Use the -t option to suppress the leading A(m, n)=:
$ stackermann 4 1 65533
If n is not given, n=m is assumed:
$stackermann 3 A(3, 3)=61
The -s option may be used to additionally print computation statistics to stderr:
$ stackermann -s 3 A(3, 3)=61 Processing time: 0.001 s. 8 stack ops; max stack size 4 (~72 bytes).
Benchmark mode
In benchmark mode (the -b option), stackermann does not print the calculated value at all; instead, it prints statistics on what it took to calculate it. The output produced is printed as a space-separated list of—respectively—total computation time in seconds, total number of stack pushes, maximum number of stack entries, and approximate maximum stack size in bytes.
$ stackermann -b 4 2 0.050 131103 65534 1048552
Additional options
For an up-to-date overview of all available options and features, see the manpage included in the source tarball.