2011-03-24 6 views
0

Existe-t-il une implémentation dans gmp qui autorise une fonction de puissance avec seulement mpf_t comme argument? Je veux faire ceci:gmp pow avec deux mpf_t

mpf_t s ; 
mpf_init (s); 
mpf_set_d (s,boost::lexical_cast<double>(sec)); 
mpf_t ten,mil; 
mpf_init(ten); 
mpf_init(mil); 
mpf_set_d(ten,10.0); 
mpf_set_d(mil,0.001); 
mpf_div(s,s,ten); 
mpf_pow_ui(s,ten,s); //<- this doesn't work because it need an unsigned int as third argument but I need it with a mpf_t 
mpf_mul(s,s,mil); 

Répondre

1

Je ne pense pas, au moins pas avec la bibliothèque GNU Multi-Precision seulement. Mais vous pouvez utiliser mpfr, qui est basé sur gmp et prend en charge une fonction mpfr_pow (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd). Voir here.

Si vous décidez de faire cela, this pourrait aussi vous être utile.