NTL库中多项式、RR和ZZ的乘幂运算

4

我正在使用NTL库来实现RSA密码分析,但是经常遇到类型不匹配/不兼容的问题。

例如-

  1. I need RR type value of n^((h-1.0)/(h*k-1.0)) where n is type ZZ, and h and k are int. The overall exponent is float or double. I tried ^ , pow (works only for RR base), power (works only for long exponent). I eventually made n,h,k all of type RR to use pow, but is that really the way to do it?

  2. How to do (p(x))^k where p(x) is some polynomial? I had to use mul function in a loop k times. Also how to initialize a polynomial? It seems it can take something like a python list from stdin, yet I can't set it like that within the program. So,

    ZZX p;
    p = [1 2 3]
    

    or

    p = ZZX([1 2 3]) 
    

    doesn't work. I had to use SetCoeff to set each coefficient individually.

这只是我现在记得的两个例子。我遇到的不便太多了。
如果我没记错,我们甚至不能将ZZ和RR相乘。
1个回答

1

我也搜索了一段时间。

  1. 不好意思,没有内置的方法可以做到这一点。只有 RR^long 是浮点数和整数混合的组合。我认为最简单的方法是将所有值转换为 RR
  2. 在这里,我也没有发现内置的方法来计算多项式的幂次。但是有一种比自己乘 k 次更快的方法。看看 快速幂
    设置多项式只有一种方法,就是逐个系数进行设置。但是您可以编写一个函数,从向量中设置多项式的所有系数。

NTL 是一个很好的高性能数学库,但有很多东西使得使用这个库很难……我认识的每个人都有数据类型的问题(就像您提到的,当您尝试相乘 RRZZ 时)。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接