Well, that's not exactly an improvement

   ts'x <[EMAIL PROTECTED] 17'
0.19952 2.09723e7
   ts'x (([ - |~) % ]) 17'
0.0545567 1.25841e7

   ts'x % 17'
0.0182892 8.38925e6
   ts'_4 (33 b.) x'
0.00982667 4.1952e6

   datatype x (([ - |~) % ]) 17
floating

Maybe a method that represents interger
division in terms of binary shifts.


Mike Day mike_liz.day at tiscali.co.uk wrote Sat Oct 21 16:18:53 HKT 2006 

FWIW, pending J6.02, this offers some improvement in
time and space:
   NB. in J 6.0.1
   NB. reduce x to an integer multiple of y before divide
   NB. does it work for -ve & +ve x
   (x-300000) (<[EMAIL PROTECTED] -: ([ - |~) % ]) 17
1
   ts'x  <[EMAIL PROTECTED] 17'
0.210536 2.09723e7
   ts'x (([ - |~) % ]) 17'
0.0587469 1.25841e7

I expect there's a better way still, and still in 6.01 !

Mike

Roger Hui wrote:
> Preliminary benchmarks:
>
> ts=: 6!:2 , 7!:[EMAIL PROTECTED]
> x=: 1e6 [EMAIL PROTECTED] 2e6
> ts 'Expression'
>
> Expression          J6.02x              J6.01            Factor
> x <[EMAIL PROTECTED] 512   0.0054822 4.19507e6  0.136416 2.09723e7   23.80 
> 5.00
> x <[EMAIL PROTECTED] 17    0.0213073 4.19507e6  0.154837 2.09723e7    7.27 
> 5.00


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to