Para este texto em português, veja README.pt.adoc.
The purple-arithmetic library contains procedures for arithmetics with "long" nonnegative integers.
This is an educational project with the purpose of learning and sharing algorithmic mathematics.
This library is defined as a C++26 module in src/main/ixx.
Notable module partitions:
-
word.concept.ixx:
concept Word<W> -
word.type.ixx:
type template word<B>base 2^B -
bi.ixx: bi-
Wordarithmetics -
tri.ixx: tri-
Wordarithmetics -
multi.ixx: multi-
Wordarithmetics
References:
-
Donald E. Knuth, "The Art of Computer Programming", volume 2, "Seminumerical Algorithms", third edition, ISBN 0-201-89684-2
-
MMIXmasters, "MIX to MMIX Conversion", https://mmix.cs.hm.edu/mmixmasters/index.html#MIXtoMMIX
-
Peter Montgomery, Torbjörn Granlund, "Division by Invariant Integers using Multiplication", PLDI '94, DOI: 10.1145/178243.178249
-
Alexander Stepanov, Paul McJones, "Elements of Programming", Addison-Wesley, 2009, ISBN 978-0-321-63537-2
-
Niels Möller, Torbjörn Granlund, "Improved division by invariant integers", IEEE Transactions on Computers, Volume 60, Issue 2, February 2011, DOI: 10.1109/TC.2010.143
-
Alexander Stepanov, Daniel Rose, "From Mathematics to Generic Programming", Addison Wesley, 2015, ISBN 978-0-321-94204-3
Building the library requires these tools.
-
clang 20+
-
ninja 1.11+
-
cmake 3.30+
To build the library:
cmake --preset default
cmake --build --preset defaultTo test for quality, run the purple-arithmetic-test program.
cmake-build-default/purple-arithmetic-testThis is a standard Google Test program, supporting the usual command line options.
To test for performance, run the purple-arithmetic-bechmark program.
cmake-build-default/purple-arithmetic-benchmarkThis is a standard Google Benchmark program, supporting the usual command line options.
Performance is compared against the GMP library.