C code that gets executed when mpz_mul() is invoked

Marco Bodrato bodrato at mail.dm.unipi.it
Tue May 15 19:32:26 UTC 2018


Ciao,

Il Mar, 15 Maggio 2018 2:24 am, Tanushree Banerjee ha scritto:
> I had a general question about the multiplication techniques used by GNU
> GMP implementation.
>>From the documentation I understand it uses Karatsuba for smaller sized
> inputs, for larger inputs Toom Cook 3/4 way and for very large ones FFT
> based multiplication.

It's a bit more complex than that. There is a basecase implementation for
smaller sizes, a couple of larger degree Toom-k+½ in between Toom-4 and
FFT. Moreover there are Toom-inspired functions specially crafted for
operands of different sizes...

https://gmplib.org/manual/Multiplication-Algorithms.html

> I want to see the C code which GMP uses for multiplication when I use
> mpz_mul () function and compile my C code using -lgmp flag.

You can find the code of mpz_mul() in gmp/mpz/mul.c

> Is it the code in the folder    gmp-6.1.2\mpn\generic\mul_n.c ?

That is a good starting point

Ĝis,
m

-- 
http://bodrato.it/



More information about the gmp-discuss mailing list