mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

CRGreathouse 2011-01-29 22:14

[QUOTE=science_man_88;250325]I couldn't get the addhelp to add help I've had it working before but I just tried the autosave that lavalamp got me doing and I can't get what I want to work.[/QUOTE]

Can you give an example? For example, what happens if you type
[code]foo()="bar";
addhelp(foo, "foo(): Bar.")
?foo[/code]
?

science_man_88 2011-01-29 22:38

[QUOTE=CRGreathouse;250363]Can you give an example? For example, what happens if you type
[code]foo()="bar";
addhelp(foo, "foo(): Bar.")
?foo[/code]
?[/QUOTE]

if works but I can't get it to work if i save it in file like that I bet. ? how'd it work I couldn't get mine to work grrr. I bet I messed up. also can you save vectors in file and call them back ? I can't get it or I'd save the MPE's it might save me a while lol. got it thanks again you are very useful.

CRGreathouse 2011-01-30 01:35

[QUOTE=science_man_88;250367]also can you save vectors in file and call them back ?[/QUOTE]

Yep. I have a few common ones in my auto-loaded script.

davar55 2011-01-30 01:46

To sm88: are you working on mersennes, perfects, abundants,
deficients, aliquots, riesels, sierpinskis, and brilliants too?

They are intimately connected.

Why not give us your versions of their definitions, just for fun.

davar55 2011-01-30 01:51

pari mutual question
 
How does one run pari?

davar55 2011-01-30 01:59

[QUOTE=science_man_88;243003][CODE]a=0;for(i=1,#mersenne,for(x=a+1,100,if(prime(x)==mersenne[i],a=x;break(),print1(x",");a=x;break())))[/CODE]Basically checking for [URL]http://oeis.org/A135980[/URL] , but it's not working as intended. I'm using a so x doesn't repeat a value, this seems to work however it reports 6 as the second term not 9 so I've made a major error. doh I should have reversed the order of the loops I think. I see why it prints six because it checks 11==13 and that's false so it prints x then puts 5 in a so it then increments without finding the next match and hence it returns 6 on finding 13!=17.[/QUOTE]

Not working as intended because why?

Re-think your whole programming methodology.

CRGreathouse 2011-01-30 03:05

[QUOTE=davar55;250409]How does one run pari?[/QUOTE]

Download the binary at
[url]http://pari.math.u-bordeaux.fr/[/url]
(or use your package manager, if on *nix) and run.

science_man_88 2011-01-31 15:07

CRG do you think I'm able enough in PARI to attempt the BWT algorithm of encoding ? it uses RLE and I've coded that. the main hard part is remembering all the vector alteration codes. I have to rotate through all combinations ( putting them in a vector may help) then I'd have to vecsort, alphabetically then take the last character of each element in the vector and then perform RLE. I also have to have a state so I can tell if compression or decompression is wanted I could use a variable there. I think the decompression si the hard part and I don't know if I ever tried decompression for RLE.

science_man_88 2011-02-04 14:19

hi is there a way in PARI to tell a function to only accept vectors and rename them to use them in the script I'm working on something of a aredisjoint(A,B) script. but I want the arguments to be treated as vectors:

[CODE]aredisjoint(A,B) = a=0;for(i=1,#A,for(j=1,#B,if(A[i]==B[j],return(0),a=a+1;if(a==#A,return(1)))))[/CODE]
I gave it a test and it failed it it always seems to return 1 even if the values are the same. if I get this to work I may start on a ispd (is pairwise disjoint) function. never mind I found my error it should be if(a==#A*#B

science_man_88 2011-02-04 14:27

final script with one other change and I get:

[CODE]aredisjoint(A=[],B=[]) = if(#A!=0 && #B!=0,a=0;for(i=1,#A,for(j=1,#B,if(A[i]==B[j],return(0),a=a+1;if(a==#A*#B,return(1))))),return(0))[/CODE]

science_man_88 2011-02-04 14:45

[CODE]ispd(C) = b=0;for(i=1,#C,for(j=1,#C,if(i!=j && aredisjoint(C[i],C[j]),b=b+1)));if(b==#C*#C-#C,return(1),return(0))[/CODE] I checked this on a vector with 2 other vectors inside it.


All times are UTC. The time now is 23:03.

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