Exponentiation of polynomials, RR and ZZ in NTL library

929 views Asked by At

I am using the NTL library for a RSA cryptanalysis implementation. But I am running into some problems frequently regarding type mismatch/incompatibility.

Eg-

  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.

These are just 2 instances I remember right now. I have encountered too many inconveniences.
Iirc, we can't even multiply ZZ and RR.

1

There are 1 answers

0
AbcAeffchen On

I searched this also for a while.

  1. No sorry. There is no built in way to do this. Only RR^long is a mix of floatingpoint and integral number. I think the easiest way is to convert all values to RR.
  2. Here I see also no built in method to compute the power of a polynomial. But there is a faster way to do it than multiply it k-times with it self. Take a look at the fast exponentiation.
    To set a polynomial there is only the way to set it one coefficent after another. But you can write a function to set all coefficents in a polynomial from a vector.

NTL is a good high performance math library, but there are a lot of things that make working with this libary hard... Everyone I know has problems with the datatypes (as you mentioned, when you try to multiply RR and ZZ).