mersenneforum.org IntegerExponent Equivalent in Pari-GP
 User Name Remember Me? Password
 Register FAQ Search Today's Posts Mark Forums Read

 2018-09-14, 02:53 #265 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 23·3·79 Posts PARI/GP experts, What is the correct reference term to the software? PARI, or PARI/GP? In particular how would you label a PARI/GP scripting code? Thank you for your time.
 2018-09-14, 11:11 #266 ldesnogu     Jan 2008 France 10000100002 Posts According to the official site: https://pari.math.u-bordeaux.fr/ PARI is the name of the C library and GP the name of the scripting language. So I would say PARI/GP
 2018-09-14, 11:47 #267 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 23×3×79 Posts Thank you for the clarification.
 2018-09-14, 13:02 #268 CRGreathouse     Aug 2006 134418 Posts To expand on ldesnogu's answer: --- If you write a script like this: Code: forprime(p=2, 97, print(p)) the language you used is called GP. If you write a program like this: Code: #include /* return d = gcd(a,b), sets u, v such that au + bv = gcd(a,b) */ GEN extgcd(GEN A, GEN B, GEN *U, GEN *V) { pari_sp av = avma; GEN ux = gen_1, vx = gen_0, a = A, b = B; if (typ(a) != t_INT) pari_err_TYPE("extgcd",a); if (typ(b) != t_INT) pari_err_TYPE("extgcd",b); if (signe(a) < 0) { a = negi(a); ux = negi(ux); } while (!gequal0(b)) { GEN r, q = dvmdii(a, b, &r), v = vx; vx = subii(ux, mulii(q, vx)); ux = v; a = b; b = r; } *U = ux; *V = diviiexact( subii(a, mulii(A,ux)), B ); gerepileall(av, 3, &a, U, V); return a; } int main() { GEN x, y, d, u, v; pari_init(1000000,2); printf("x = "); x = gp_read_stream(stdin); printf("y = "); y = gp_read_stream(stdin); d = extgcd(x, y, &u, &v); pari_printf("gcd = %Ps\nu = %Ps\nv = %Ps\n", d, u, v); pari_close(); return 0; } the language you used is C and the library installed via #include is called PARI. If you run a little calculator program and it says something like Code: Reading GPRC: gprc.txt ...Done. GP/PARI CALCULATOR Version 2.12.0 (development 22943-2eb50d55b) amd64 running mingw (x86-64/GMP-6.1.2 kernel) 64-bit version compiled: Aug 22 2018, gcc version 7.3-win32 20180506 (GCC) threading engine: single (readline v6.2 enabled, extended help enabled) Copyright (C) 2000-2018 The PARI Group PARI/GP is free software, covered by the GNU General Public License, and comes WITHOUT ANY WARRANTY WHATSOEVER. Type ? for help, \q to quit. Type ?17 for how to get moral (and possibly technical) support. parisizemax = 800000000, primelimit = 300000000 (Sep 14 08:59) gp > when it starts, the name of the program is gp. The combination of the library PARI, the scripting language GP, and the program gp is called "PARI/GP". Last fiddled with by CRGreathouse on 2018-09-14 at 13:03
 2020-08-06, 04:11 #269 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 23·3·79 Posts Hey Pari experts, Is there a way to pass a small integer value to the Pari program in the command line. Something similar to what can be done in a batch file: https://www.tutorialspoint.com/batch..._variables.htm I am not looking for complex or large values here. Thanks in advance.
2020-08-06, 04:45   #270
paulunderwood

Sep 2002
Database er0rr

26·53 Posts

Quote:
 Originally Posted by a1call Hey Pari experts, Is there a way to pass a small integer value to the Pari program in the command line. Something similar to what can be done in a batch file: https://www.tutorialspoint.com/batch..._variables.htm I am not looking for complex or large values here. Thanks in advance.
https://rosettacode.org/wiki/Parse_c...ents#PARI.2FGP

"GP exists in a REPL and so it doesn't make sense to parse command-line arguments. But PARI can parse them just like C"

All I can think to do is to put your arguments in a file in vector form or one line per argument and have your script read or readvec them.

Last fiddled with by paulunderwood on 2020-08-06 at 05:00

 2020-08-06, 05:08 #271 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 35508 Posts Thanks for that Paul. It doesn't make sense but would have been very useful if they allowed it anyway. I am trying to avoid having multiple files written for multiple instances. The closest I managed to get it to is to change the "TITLE" of the launching window and reading it in Pari with the system command. But the system command executes the command and returns 0 as the return value. A simple/primitive feature made absolutely impossible in such an advanced program.
 2020-08-06, 05:28 #272 paulunderwood     Sep 2002 Database er0rr 26×53 Posts Code: cat test.gp V=read("./myvec.txt"); for(v=1,#V,print(V[v])) Code: echo "[1,2,3,4]" > myvec.txt; gp -q < test.gp 1 2 3 4 Clunky! Last fiddled with by paulunderwood on 2020-08-06 at 05:28
2020-08-06, 13:45   #273
CRGreathouse

Aug 2006

172116 Posts

Quote:
 Originally Posted by paulunderwood Code: cat test.gp V=read("./myvec.txt"); for(v=1,#V,print(V[v])) Code: echo "[1,2,3,4]" > myvec.txt; gp -q < test.gp 1 2 3 4 Clunky!
You can do better than that:

Code:
echo "Pi" | gp -q

 2020-08-15, 07:27 #274 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 23×3×79 Posts Good day experts, foreach is present on this page https://pari.math.u-bordeaux.fr/doch...tatements.html But I can't find it on Pari-gp How can I use it? Thanks n advance
2020-08-15, 12:23   #275
Dr Sardonicus

Feb 2017
Nowhere

5×691 Posts

Quote:
 Originally Posted by a1call Good day experts, foreach is present on this page https://pari.math.u-bordeaux.fr/doch...tatements.html But I can't find it on Pari-gp How can I use it? Thanks n advance
My guess is, your version of Pari-GP predates the function, in which case the answer to your question is, "You can't."

I don't know the earliest version of Pari-GP that included foreach(V, X, seq) but I did find it mentioned on a reference card for version 2.12.1.

 Thread Tools

 Similar Threads Thread Thread Starter Forum Replies Last Post HellGauss Math 5 2012-04-12 14:01 petrw1 Software 0 2009-12-05 04:41 g0ods Software 9 2009-09-15 14:12 fivemack Math 4 2008-03-27 17:58 dsouza123 Programming 25 2005-10-08 05:10

All times are UTC. The time now is 06:50.

Sat Sep 19 06:50:07 UTC 2020 up 9 days, 4:01, 0 users, load averages: 2.06, 1.56, 1.50

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.