Just for everybody edification:

   d0=: >:@<....@^. NB.  Length to represent y in base x 
   time =. 6!:2  NB. time in seconds
   pow=: 4 : '*/ *~^:(I.|.#:y) x'  NB. same as x^y
   powGB =: (**:)/@(|....@#:@]{1x,[) NB. same as x^y

   time '<: 2x ^ 216091'
7.57745
   time '<: 2x pow 216091'
3.86865
   time '<: 2x & powGB"0 ] 216091'
3.216

So. for extended numbers, powGB is a little faster than pow
which is about 2 times faster than *

d0 <: 2x ^ 216091
149783
   d0 <: 2x pow 216091
149783
   d0 <: 2x & powGB"0 ] 216091
149783

All answers have 149783 decimal digits.

   aexp =: <: 2x ^ 216091
   apow =: <: 2x pow 216091
   apowGB =:  2x & powGB"0 ] 216091

   aexp = apow
1
   apow = apowGB
1

So all the results are the same.

Thanks to everybody for their help.

:-)







----- Original Message Follows -----
From: "Dan Bron" <[email protected]>
To: "'Programming forum'" <[email protected]>
Subject: Re: [Jprogramming] Mersenne Prime initialization.
Date: Fri, 10 Apr 2009 20:26:23 -0400

>Butch Lakeshore wrote:
>> Cut/past what was in your email
>> 
>> powGB =: (* *:)/@(|.@|....@#:@] { 1x , [) 
>
>You still have two |.s in there.  Did you cut/paste the
>first definition (the quoted one) or the second (Bill's)? 
>The two |.s look like you took the copied the first, but
>the spacing looks like you copied the second.  
>
>Maybe your system, for some reason, duplicates  |.@  when
>it's in your copy buffer?  I can see no other reason for
>|.@  to be duplicated (assuming you're not doing it by
>hand).
>
>Try taking the definition above, and deleting the leftmost 
>|.@  so that you only have one instance of that train, and
>your definition looks byte for byte like this:
>
>       powGB =: (* *:)/@(|....@#:@] { 1x , [)
>
>If you put the above in quotes and enter the following
>sentences, you should get identical results:
>
>       # ;: 'powGB =: (* *:)/@(|....@#:@] { 1x , [)'
>    19
>
>       '|.@' +/@E.&;: 'powGB =: (* *:)/@(|....@#:@] { 1x , [)'
>    1
>       
>And, yes, testing reveals this definition is correct:
>
>       2 powGB 11
>    2048
>
>       2 powGB 13
>    8192
>
>       2 (powGB"0 -: ^) i. 100x
>    1
>
>I will be very surprised if it doesn't produce the same
>results on your system, once you have the proper
>definition.
>
>-Dan
>
>-----------------------------------------------------------
>----------- For information about J forums see
>http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to