Complex number arithmetic

Vincent Lefevre vincent+gmp at
Fri May 4 12:41:57 CEST 2007

On 2007-05-03 21:40:26 +0200, Vegard Nossum wrote:
> I am not sure if this is needed or wanted, but I keep finding myself
> wanting to do complex-number arithmetic with MP, so I've written a very
> simple GMP add-on for complex numbers.

This is complex rational number arithmetic, isn't it?

> I've introduced a new type, the mpc_t, which contains two rational numbers
> for the real and imaginary parts. The related functions work pretty much
> like the rest of the library, though I might have missed a few (such as
> conversion to string, which I didn't get my head around).

FYI, there's already an MPC library:

which also uses the mpc_t type, but this is complex floating-point
arithmetic (based on MPFR).

To avoid a conflict, the types should probably be named mpcq_t and
mpcf_t respectively (and one could also have mpcz_t for Gaussian

Vincent Lefèvre <vincent at> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / Arenaire project (LIP, ENS-Lyon)

More information about the gmp-devel mailing list