Repeated squaring (from http://www.jsoftware.com/jwiki/Essays/Repeated%20Squaring ) is as fast but twice as fat as intpower
ts'pr=:9223372036854775807x (4 : ''*/ *~^:(I.|.#:y) x'') 10000' 5.9712462 3560960 R.E. Boss (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics ) > -----Original Message----- > From: programming-boun...@forums.jsoftware.com [mailto:programming- > boun...@forums.jsoftware.com] On Behalf Of R.E. Boss > Sent: maandag 27 januari 2014 15:52 > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] Speed of power > > Same here > > ts 'p0=: 9223372036854775807x ^ 10000' > 16.509273 5436416 > ts 'p1=: 9223372036854775807x intpower 10000' > 5.9769485 1710080 > > JVERSION > Engine: j701/2011-01-10/11:25 > Library: 8.01.016 > Qt IDE: 1.0.22/4.8.5 > Platform: Win 64 > Installer: j801 beta install > > > R.E. Boss > > (Add your info to > http://www.jsoftware.com/jwiki/Community/Demographics ) > > > -----Original Message----- > > From: programming-boun...@forums.jsoftware.com > [mailto:programming- > > boun...@forums.jsoftware.com] On Behalf Of Shaw, Ewart > > Sent: maandag 27 januari 2014 15:46 > > To: programm...@jsoftware.com > > Cc: Shaw, Ewart > > Subject: [Jprogramming] Speed of power > > > > A recent thread moved to chat, "more fork examples", looks at timings > > for high powers of BIGNUMs. The following suggests a speedup is possible > > (at least in J6.02, to which I'm restricted until my life settles down - > sorry!) > > > ---------------------------------------------------------------------------- > ----------- > > > > intpower=: 3 : 0 > > 2x intpower y > > : > > a=. 1 [ xp=. x > > for_k. |. }. #: y do. > > if. k do. a=. a*xp end. > > xp=. *: xp > > end. > > a*xp > > ) > > > > ts 'p0=: 9223372036854775807x ^ 10000' > > 16.3665 5.43642e6 > > ts 'p1=: 9223372036854775807x intpower 10000' > > 5.94679 1.71008e6 > > p0 = p1 > > 1 > > > > > ---------------------------------------------------------------------------- > ----------- > > The current J6.02 timings are similar to what I get with an extra, > redundant > > xp=. *: xp after the calculation. Again apologies if this is sorted in > J7/8. > > Best wishes, Ewart > > > > Ewart Shaw (Dr. J.E.H.Shaw) Department of Statistics, University of > > Warwick. > > ---------------------------------------------------------------------- > > For information about J forums see > http://www.jsoftware.com/forums.htm > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm