mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2011-01-29, 22:14   #2113
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
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.
Can you give an example? For example, what happens if you type
Code:
foo()="bar";
addhelp(foo, "foo(): Bar.")
?foo
?
CRGreathouse is offline   Reply With Quote
Old 2011-01-29, 22:38   #2114
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Can you give an example? For example, what happens if you type
Code:
foo()="bar";
addhelp(foo, "foo(): Bar.")
?foo
?
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.

Last fiddled with by science_man_88 on 2011-01-29 at 22:47
science_man_88 is offline   Reply With Quote
Old 2011-01-30, 01:35   #2115
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

10111010110112 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
also can you save vectors in file and call them back ?
Yep. I have a few common ones in my auto-loaded script.
CRGreathouse is offline   Reply With Quote
Old 2011-01-30, 01:46   #2116
davar55
 
davar55's Avatar
 
May 2004
New York City

108B16 Posts
Default

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 is offline   Reply With Quote
Old 2011-01-30, 01:51   #2117
davar55
 
davar55's Avatar
 
May 2004
New York City

423510 Posts
Default pari mutual question

How does one run pari?
davar55 is offline   Reply With Quote
Old 2011-01-30, 01:59   #2118
davar55
 
davar55's Avatar
 
May 2004
New York City

423510 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
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())))
Basically checking for http://oeis.org/A135980 , 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.
Not working as intended because why?

Re-think your whole programming methodology.
davar55 is offline   Reply With Quote
Old 2011-01-30, 03:05   #2119
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by davar55 View Post
How does one run pari?
Download the binary at
http://pari.math.u-bordeaux.fr/
(or use your package manager, if on *nix) and run.
CRGreathouse is offline   Reply With Quote
Old 2011-01-31, 15:07   #2120
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

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 is offline   Reply With Quote
Old 2011-02-04, 14:19   #2121
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

20C016 Posts
Default

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)))))
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

Last fiddled with by science_man_88 on 2011-02-04 at 14:21
science_man_88 is offline   Reply With Quote
Old 2011-02-04, 14:27   #2122
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26·131 Posts
Default

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))
science_man_88 is offline   Reply With Quote
Old 2011-02-04, 14:45   #2123
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

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))
I checked this on a vector with 2 other vectors inside it.
science_man_88 is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 15:31.


Fri Aug 6 15:31:39 UTC 2021 up 14 days, 10 hrs, 1 user, load averages: 2.36, 2.72, 2.83

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, 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.