This is a fork of the mini version of the GNU Multi-Precision library with some patches/optimizations for usage in numerical geometry and easy-to-use CMakeList (tested under Windows, Linux, Mac).
My changes are listed in mini-gmp-plus-Changelog,
and indicated by [Bruno Levy] tags in the sources, with the date and reason
for the modification.
In numerical geometry, one manipulates numbers that are relatively
small (a few 64-bit limbs), so Karatsuba multiplication is not
needed, hence mini-gmp suffices. On the other hand, it is interesting
to avoid dynamic allocation, hence numbers smaller than a certain threshold (that
corresponds to 5 64-bits numbers by default) are allocated on the
stack. Modern processors have some instructions that can significantly optimize
some multi-precision operations, such as finding the number of leading and
trailing zeroes in an integer, shifting 128 bit numbers, multiplying two 64-bit
numbers and obtaining the 128-bits result, or adding 64-bit numbers and
propagating the carry in multi-limb operations. While 64-bit add/subtract with
carry propagation is recognized and optimized by modern compilers, it is not the
case for the other operations, that are implemented by some compiler-dependent
intrinsics. For this reason, I needed to create a new bitops64.h
file to abstract them. These two modifications (local storage and
64 bits intrinsics) introduced a couple of very simple yet not completely
trivial changes (I must confess I did not have them right the first time), so it
is important - I would say vital - to be able to run the testsuite. For this
reason I also created new CMakeLists.txt files as well as a github action that
runs the (already existing, thank you !) mini-gmp testsuite under Linux,Mac
and Windows.
As compared to mini-gmp, mini-gmp-plus has the following differences:
- limitation: limb size is fixed as 64 bits
- numbers smaller than a certain size (5 limbs) are stored in the
mpz_tstructure for better multithreading (avoids most dynamic allocations) - the file bitops64.h, not part of mini-gmp, contains some wrappers for efficient bit operations on 64-bit numbers, for GCC, Clang and VisualC++ using these compiler's intrinsics
mini-gmp-plusis compiled as a dynamic library- CMakeLists.txt optionally builds and runs non-regression
tests using CTest, use
cmake -DMINI_GMP_PLUS_WITH_TESTS=1to compile and run the testsuite. - The github action builds and runs the testsuite
systematically. Under Windows, the github action installs
gmp(throughvcpkg) and declares it (throughpkgconf) so that tests/CMakeLists.txt sees it. Note thatgmpis only needed if you want to run the non-regression testsuite.
Bruno Lévy, November 2025