To build FastPathways, you will need to have https://cmake.org/[CMake] v2.8 or higher.
Once CMake is installed, building, testing and installing the library is a snap
$ cmake -H. -Bbuild -DCMAKE_BUILD_TYPE=Release
$ make -C build
This will compile down to shared and static libraries, and generate the following executables:
build/intchains
- compute the assembly indices of integers under additionbuild/subsecond
- determine the smallest integer for which it takes greater than 1s to compute the assembly indexbuild/test/fastpathways_unittests
- test the library
You can run the unit tests explicitly
$ ./build/test/fastpathways_unittests
or via make
$ make -C build test
The library, for the most part, exposes a single function thurber(int64_t n) -> int64_t
. The
argument is the integer for which you wish to compute the assembly index (minimal length of all
addition chains terminating at n
), and obviously the return value is that assembly index.
#include <fastpathways.h>
#include <iostream>
auto main(int argc, char **argv) -> int {
std::cout << thurber(607) << std::endl;
}
Output:
13
$ ./build/intchains
usage: intchain [subcommand] n
Subcommands:
<none>: compute and output the assembly index of `n`
time: compute and output the assembly index of `n` and run time.
perf: compute the assembly index of all integers from 1 to `n` (inclusive)
and output the sum and run time.
Exception: ./build/intchains exited with 255
[tty 6], line 1: ./build/intchains
$ ./build/intchains 607
13
$ ./build/intchains time 607
13
0.04888121s
$ ./build/intchains perf 1000
10808
2.83965543s