![]() |
doubt with PARI and modular operations
Hi
I'm playing with PARI and modular operations I write this [CODE]NN=17 NN=Mod(2,10000000019)^(NN-1)+1 [/CODE] And it gives me this [CODE]Mod(65537, 10000000019) [/CODE] But if I executre again [CODE] NN=Mod(2,10000000019)^(NN-1)+1 [/CODE] I get this error [CODE] *** at top-level: NN=Mod(2,10000000019)^(NN-1)+1 *** ^------------- *** _^_: incorrect type in glog (t_INTMOD).[/CODE] I guess it wants a number as exponent and not a modular expression. How can I "extract the number without the modulus? I think it's called the representative number. I know how to extract the modular base with NN.mod but not the other number. regards |
[QUOTE=skan;335264]Hi
I'm playing with PARI and modular operations I write this [CODE]NN=17 NN=Mod(2,10000000019)^(NN-1)+1 [/CODE] And it gives me this [CODE]Mod(65537, 10000000019) [/CODE] But if I executre again [CODE] NN=Mod(2,10000000019)^(NN-1)+1 [/CODE] I get this error [CODE] *** at top-level: NN=Mod(2,10000000019)^(NN-1)+1 *** ^------------- *** _^_: incorrect type in glog (t_INTMOD).[/CODE] I guess it wants a number as exponent and not a modular expression. How can I "extract the number without the modulus? I think it's called the representative number. I know how to extract the modular base with NN.mod but not the other number. regards[/QUOTE] a quick google search found me something form the pari commands thread I didn't see before that basically says you can use component(%,2) to get the first part of the answer. |
[CODE]lift(NN)[/CODE]
E.g. [CODE](17:17) gp > NN=17 %1 = 17 (17:17) gp > NN=Mod(2,10000000019)^(NN-1)+1 %2 = Mod(65537, 10000000019) (17:17) gp > lift(NN) %3 = 65537 [/CODE] This one wasn't easy to spot (I had to google it), but for many things, this [URL="http://www.staff.science.uu.nl/~beuke106/boek/refcard.pdf"]Pari/GP Reference Card[/URL] is very handy. |
Try the % operator.
|
Thanks.
The % operator produces overflow error when calculating powers with big numbers |
Use the "lift"/"centerlift" operators, which give you an integer when applied to modulus type. Pari has many conversion functions, and even for more complicated types you can use the "component" operator. With "component" you can create and access very complicated types, is like a "pointer" in C, but for the predefined types (like Mod), you have to know the internal structure, which is not always intuitive:
[CODE] gp > a=Mod(3,5) %1 = Mod(3, 5) gp > lift(a) %2 = 3 gp > centerlift(a) %4 = -2 gp > component(a,2) %5 = 3 gp > component(a,1) %6 = 5 gp > [/CODE] |
Thanks.
Another question: I've read at Pari website that there is GMP Pari version, faster. But now I don't want to compile Pari and GMP. I've downloaded the gmp precompiled binaries for windows. There is a gmp.dll file but I don't know how to force Pari to use it, where I have to leave it or what config files I have to modify. |
[QUOTE=skan;335350]Thanks.
Another question: I've read at Pari website that there is GMP Pari version, faster. But now I don't want to compile Pari and GMP. I've downloaded the gmp precompiled binaries for windows. There is a gmp.dll file but I don't know how to force Pari to use it, where I have to leave it or what config files I have to modify.[/QUOTE] A .DLL should be put either in the working directory or in the \windows\system32 folder. Luigi |
[QUOTE=ET_;335358]A .DLL should be put either in the working directory or in the \windows\system32 folder.
Luigi[/QUOTE] But Does Pari detect it automatically? |
[QUOTE=skan;335359]But Does Pari detect it automatically?[/QUOTE]
Wndows OS uses to look into these directories whenever a program needs a dll, so I guess so. Luigi |
[QUOTE=skan;335350]Thanks.
Another question: I've read at Pari website that there is GMP Pari version, faster. But now I don't want to compile Pari and GMP. I've downloaded the gmp precompiled binaries for windows. There is a gmp.dll file but I don't know how to force Pari to use it, where I have to leave it or what config files I have to modify.[/QUOTE] Why are you messing around with GMP dlls? Just download the PARI from here: [url]http://pari.math.u-bordeaux.fr/pub/pari/windows/snapshots/[/url] (the one that has GMP in the name). It has gmp compiled in. |
| All times are UTC. The time now is 08:01. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.