![]() |
[QUOTE=CRGreathouse;252871]Not ,,2. Not ,,3. The flag you want to set is 1 and none of the others. (You can see what they do by reading the manual, or get an overview with ?vecsort, but they're not applicable here.)[/QUOTE]
but the value 1 only returns a permutation of order in the vector by the looks of it. so unless you go through the indexes I don't see how. |
[QUOTE=science_man_88;252877]go through the indexes[/QUOTE]
Look at that, he has an idea! |
[QUOTE=CRGreathouse;252931]Look at that, he has an idea![/QUOTE]
It's not having an idea that's new, It's that it may work for once I'm guessing. |
[QUOTE=science_man_88;252964]It's not having an idea that's new, It's that it may work for once I'm guessing.[/QUOTE]
So you have a vector you need to put in order, plus two vectors that tell you how to order them. The first is a list of the indexes that should be reordered. The second is the ordering for those indexes. |
[QUOTE=CRGreathouse;252967]So you have a vector you need to put in order, plus two vectors that tell you how to order them. The first is a list of the indexes that should be reordered. The second is the ordering for those indexes.[/QUOTE]
my code (#2210) does that but adds one thing instead of ordering y ( because it may be used again afterwards), it orders D to get the order of the indexes. |
[QUOTE=CRGreathouse;252751]Great, put it up!
You can do them if you like, or post it here if you want feedback.[/QUOTE] I think I should put up a few more looks like I forgot a few I tried out. anyone else want to put them up ? I'm pretty sure by the looks of it I forgot to put up the code for the base conversion code. |
[QUOTE=CRGreathouse;252145]Incidentally, since you're working with Mersenne primes and exponents a lot, here's an idea for a script for your file:
[code]MeVec=[2, 3, 5, 7, 13, 17, 19, 31, 61, 89, 107, 127, 521, 607, 1279, 2203, 2281, 3217, 4253, 4423, 9689, 9941, 11213, 19937, 21701, 23209, 44497, 86243, 110503, 132049, 216091, 756839, 859433, 1257787, 1398269, 2976221, 3021377, 6972593, 13466917]; Me(n)={ if(n<=#MeVec, MeVec[n] , error("not known") ) }; addhelp(Me, "Me(n): Returns the n-th Mersenne prime exponent, Sloane's A000043."); M(n,modulus=0)={ if(n>#MeVec, error("not known")); if(modulus, lift(Mod(2,modulus)^MeVec[n]-1) , 1<<MeVec[n]-1 ) }; addhelp(M, "M(n, {modulus}): Returns the n-th Mersenne prime, Sloane's A000668. If modulus is given, instead return the n-th Mersenne number mod the modulus.");[/code] (Of course you can expand the vector to include the numbers whose primality is known but whose order is not.) This should not only save you keystrokes but time on longer calculations since the modular calculations are efficient compared to creating a large number and dividing it.[/QUOTE] this gives errors I should of figured. M(29,233) should be 0 it's 36 apparently. I found the error in the code and fixed it on my end. |
[QUOTE=science_man_88;253203]this gives errors I should of figured. M(29,233) should be 0 it's 36 apparently. I found the error in the code and fixed it on my end.[/QUOTE]
oh wait another error popped out of it. It won't let n be greater than #MeVec so when you say n-th mersenne number you mean with n<=#MeVec. Also even with lower ones if you use your form we get n entangled with MeVec[n] in one of the equations in the second if, it doesn't work for me in that form but works fine with it replaced with n. so with n < #MeVec it could be confusing n between the index into the mersenne prime exponents or the mersenne number index, so that part doesn't work which pretty much fails the function. the most proper to the definition you gave that I can get is: [CODE]M(n,modulus=0)=if(modulus,return(lift(Mod(2,modulus)^n-1)),if(n>#MeVec,error("not known"),return(2^MeVec[n]-1)))[/CODE] and I never had to learn the math behind it, I knew one fact that told me the old one was wrong. |
[QUOTE=science_man_88;253203]this gives errors I should of figured. M(29,233) should be 0 it's 36 apparently. I found the error in the code and fixed it on my end.[/QUOTE]
Huh? The 29-th Mersenne prime is a prime (greater than 233) so it isn't divisible by 233. [QUOTE=science_man_88;253208]oh wait another error popped out of it. It won't let n be greater than #MeVec so when you say n-th mersenne number you mean with n<=#MeVec.[/QUOTE] Well sure -- I can't tell you what the millionth Mersenne number is mod 101 since I don't know what that will be. [QUOTE=science_man_88;253208]Also even with lower ones if you use your form we get n entangled with MeVec[n] in one of the equations in the second if, it doesn't work for me in that form but works fine with it replaced with n. so with n < #MeVec it could be confusing n between the index into the mersenne prime exponents or the mersenne number index, so that part doesn't work which pretty much fails the function.[/QUOTE] This is what the help entries are for. |
[QUOTE]Huh? The 29-th Mersenne prime is a prime (greater than 233) so it isn't divisible by 233.[/QUOTE]
ah but your definition states if modulus is present it goes to mersenne numbers not mersenne primes so since the 233 is there it checks M29 [B]not[/B] 2^MeVec[29]-1 by definition. [QUOTE]Well sure -- I can't tell you what the millionth Mersenne number is mod 101 since I don't know what that will be. This is what the help entries are for.[/QUOTE] yes I know and they helped me spot a flaw in the function. |
I see what you're saying. Yes, the documentation is in error; M(n,m) should be equal to M(n)%m.
|
| All times are UTC. The time now is 23:00. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.