Complex numbers using mpfr_class

Durufle marc marc_durufle at
Fri Dec 16 14:58:06 CET 2005

I have some little problems when i use complex numbers
like that :

typedef complex<mpfr_class> Complex_wp;

The main problem is that i can't declare :

Complex_wp c(0);

because the imaginary part of c will not be
initialized, the imaginary part of c is equal to NaN.
The only way, I find to solve this problem is to put :

Complex_wp c(0,0);

But, i am very confused because i use template
functions (for real or complex numbers), and for real
numbers, this syntax is incorrect. So i would know if
there is a way to solve my problem, with keeping the
compatibility with real numbers. 

I asked my-self, if it is not a problem of the
standard complex class, which doesn't allow to
initialize a complex number with only one integer

Complex_wp c(0);

It is amazing because with the standard double class

complex<double> c(0)

it works very well, and i never met a nan in this
case. So there is a compatibility problem between gmp
and standard complex class, no ?


Nouveau : téléphonez moins cher avec Yahoo! Messenger ! Découvez les tarifs exceptionnels pour appeler la France et l'international.
Téléchargez sur

More information about the gmp-bugs mailing list