gmp pow有两个mpf_t

时间:2011-03-24 17:37:04

标签: c++ gmp pow

gmp中是否有允许仅使用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);

1 个答案:

答案 0 :(得分:1)

我不这么认为,至少不是GNU Multi-Precision库。但是你可以使用mpfr,它基于gmp并支持mpfr_pow (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd)函数。请参阅here

如果您决定这样做,this也可以提供帮助。