stackermann

From Penguin Development
Revision as of 11:30, 17 September 2013 by Link (talk | contribs) (→‎Normal usage)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

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.

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 -t 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.

Limitations, bugs and feedback

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. This is not a bug; do NOT report it as one!

Bugs and feedback

Report bugs via email at bugs[at]proj[dot]penguindevelopment[dot]org.

Send your feedback to feedback[at]proj[dot]penguindevelopment[dot]org.