【问题标题】:gmp pow with two mpf_t带有两个 mpf_t 的 gmp pow
【发布时间】:2011-03-24 17:37:03
【问题描述】:

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);

【问题讨论】:

    标签: c++ gmp pow


    【解决方案1】:

    我不这么认为,至少对于 GNU Multi-Precision 库来说不是这样。但是您可以使用mpfr,它基于gmp 并支持mpfr_pow (mpfr_t rop, mpfr_t op1, mpfr_t op2, mpfr_rnd_t rnd) 功能。见here

    如果您决定这样做,this 也可能会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多