I need to find the Modular Multiplicative Inverse of two numbers, who data types are any of the ones offered by Boost's Multiprecision library (gmp_int, cpp_int etc). Is there a built in function to do so? If not, can you explain how to proceed?

1

There are 1 best solutions below

0
On

Modular multiplicative inverses were added to boost just a few weeks ago. They are not yet in any Boost release (but should be available in 1.70). To use them, you'll need to clone

$ git clone https://github.com/boostorg/integer

into your Boost tree, or clone all of boost and point your include paths to it:

$ git clone --recursive https://github.com/boostorg/boost
$ cd boost/libs/integer
$ git checkout develop

The source code is here and the documentation is here.