usage of mpz_mul function for squaring

Marco Bodrato bodrato at mail.dm.unipi.it
Mon Nov 29 20:41:48 UTC 2021


Ciao Gašper,

Il 2021-11-29 19:50 Gašper Močnik ha scritto:
> My question is: Does the mpz_mul function detect when you want to 
> square a
> number i.e. you input the same mpz_t variable for both the op1 and op2

Yes, it does.

> Multiplication section of Manual it is stated that squaring is about 
> 1.5x
> faster than multiplying. I'm assuming squaring is also faster than
> multiplication when other algorithms are used (Karatsuba, Toom, FFT, 
> ...)

> Is my assumption correct?

Yes, it is :-)

Ĝis,
m


More information about the gmp-discuss mailing list