[Jprogramming] Speed of power
R.E. Boss
r.e.boss at planet.nl
Mon Jan 27 14:52:14 UTC 2014
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-bounces at forums.jsoftware.com [mailto:programming-
> bounces at forums.jsoftware.com] On Behalf Of Shaw, Ewart
> Sent: maandag 27 januari 2014 15:46
> To: programming at 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
More information about the Programming
mailing list