Search code examples
c++ntl

NTL Library: How to assign a big integer to ZZ_p


In NTL library I know that we can define a big integer value as:

ZZ p;
p=to_ZZ("1111111111111111111111111111111333333333333333");
ZZ_p::init(p);
ZZ_p b(12);

My question is: What if I want to assign a big integer to b rather than 12 ?

e.g.

ZZ_p b("1111111111111111111111111111111333333333333334");

So it should modulo p and assign 1 to b.

I need it for fFindRoots(vec_ZZ_p& x, const ZZ_pX& ff), so would be able to insert big integers to a vector as coefficients (of a polynomial)


Solution

  • First: I tried the code you posted and the line ZZ_p b(12); did not work for me. I had to use

    ZZ_p b;
    b = 12;
    

    If you want to assign a big integer you can do this by

    ZZ_p b;
    b = to_ZZ_p(conv<ZZ>("1111111111111111111111111111111333333333333334"));
    

    or

    char bigInteger[47] = "1111111111111111111111111111111333333333333334";
    ZZ_p b;
    b = to_ZZ_p(conv<ZZ>(bigInteger));
    

    cout << b << endl; will now print 1.