There is definitely an OS difference. I have a dual-boot (XP and Linux) laptop with 1G memory rated at 1.59 GHz. Using R.E. Boss's timing code I get
Windows XP Professional ts 'D=:10000000$d' NB. reference timing 0.102902 6.71098e7 ts'((1,2>/\]);@(<&(<./\);. 1)])D' 0.352682 8.38894e7 ts'((1,}:>}.);@(<&(<./\);. 1)])D' 0.42031 1.50998e8 ts '(}.>}:)D' 0.283239 1.50996e8 ts '(2: >/\ ])D' 0.223209 1.67792e7 Linux Fedora Core 4 ts 'D=:10000000$d' NB. reference timing 0.082827 6.71098e7 ts'((1,2>/\]);@(<&(<./\);. 1)])D' 0.88911 8.38894e7 ts'((1,}:>}.);@(<&(<./\);. 1)])D' 0.680525 1.50998e8 ts '(}.>}:)D' 0.36968 1.50996e8 ts '(2: >/\ ])D' 0.597623 1.67792e7 It appears that the Windows implementation favors 2>/\] while the Linux implementation favors }.>}:, and the Windows version is generally faster. Anyone have any ideas why this should be so? Best wishes, John Mike Day wrote: > Getting off topic; perhaps differences in machine/OS > are to blame? I'm running Windows XP Home Professional > on a 512 Mb PC with 1 Pentium 4 rated at 2.66GHz ... > > Anyway, as I said earlier, there's not much to choose > between the idioms, and as John Randall says, it's > easier to remember the old one, at least for me! > > Mike > > R.E. Boss wrote: > >>I cannot confirm the performance figures of Day: >> ts 'D=:10000000$d' NB. reference timing >>0.0505433 6.71098e7 >> >> ts'((1,2>/\]);@(<&(<./\);. 1)])D' >>0.203427 8.38894e7 >> ts'((1,}:>}.);@(<&(<./\);. 1)])D' >>0.215576 1.50998e8 >> >>neither detect much difference in performance in: >> ts '(}.>}:)D' >>0.142718 1.50996e8 >> ts '(2: >/\ ])D' >>0.146728 1.67792e7 >> >>R.E. Boss >> >>-----Oorspronkelijk bericht----- >>Van: [EMAIL PROTECTED] >>[mailto:[EMAIL PROTECTED] Namens John Randall >>Verzonden: vrijdag 24 maart 2006 13:54 >>Aan: Programming forum >>Onderwerp: Re: [Jprogramming] Closest local minimums of data >> >>I am aware of 2 >/\ ], but I tend to use }:>}. for prototyping and small >>arrays, since I can accurately read and write it without looking anything >>up. Of course there is a performance penalty for large arrays, since >>}:>}. must create two intermediate arrays of size n-1 as well as the >>result. >> >>Best wishes, >> >>John >> >>Mike Day wrote: >> >> >>>As you noted, John Randall's }: > }. is of interest. >>>2 >/\ ] is a natural J/APL2 way to do it, whereas }: > }. is the J >>>form of an ancient APL1 idiom for first differences and the like, >>>and seems faster for smallish d, but loses out for your required >>>size of vector for space requirement. However, the performance >>>is pretty good with either idiom. >>> >>> ts =: 6!:2 , 7!:[EMAIL PROTECTED] NB. time & space >>> >>> D=:10000$d NB. "old" method faster >>> ts'((1,2>/\]);@(<&(<./\);. 1)])D ' >>>0.000238578 85248 >>> ts'((1,}:>}.);@(<&(<./\);. 1)])D ' >>>0.000155048 150464 >>> >>> D=:50000$d NB. both similar for time >>> ts'((1,2>/\]);@(<&(<./\);. 1)])D ' >>>0.00151164 331008 >>> ts'((1,}:>}.);@(<&(<./\);. 1)])D ' >>>0.00151807 592832 >>> >>> D=:100000$d NB. "new" method faster >>> ts'((1,2>/\]);@(<&(<./\);. 1)])D NB. tacit form' >>>0.00302441 658688 >>> ts'((1,}:>}.);@(<&(<./\);. 1)])D NB. tacit form' >>>0.00445364 1.18266e6 >>> >>>Mike >>> >>> >>>Mikl Kurkov wrote: >>> >>> >>> >>>>On Fri, 24 Mar 2006 02:43:00 +0300, Mike Day >>>><[EMAIL PROTECTED]> wrote: >>>> >>>> >>>> >>>>>I was drafting this before Oleg's reply arrived. It's slightly >>>>>different from his, and shows a derivation of a tacit form. >>>>>============================================================== >>>>>Is this the sort of thing you need? Consider: >>>>> >>>>> >>>>Yes, exactly. >>>> >>>> >>>> >>>>> d >>>>>10 7 5 6 7 1 9 8 2 4 >>>>> (1 , 2 >/\ ])d NB. boolean for = left > right for each pair ? >>>>>1 1 1 0 0 1 0 1 1 0 >>>>> >>>>> 1 1 1 0 0 1 0 1 1 0 < ;. 1 d NB. partition d by this boolean >>>>>+--+-+-----+---+-+---+ >>>>>|10|7|5 6 7|1 9|8|2 4| >>>>>+--+-+-----+---+-+---+ >>>>> 1 1 1 0 0 1 0 1 1 0(<&(<./\);. 1)d NB. required work in boxes >>>>>+--+-+-----+---+-+---+ >>>>>|10|7|5 5 5|1 1|8|2 2| >>>>>+--+-+-----+---+-+---+ >>>>> >>>>> 1 1 1 0 0 1 0 1 1 0 ;@(<&(<./\);. 1)d NB. unbox >>>>>10 7 5 5 5 1 1 8 2 2 >>>>> >>>>> ((1,2>/\]);@(<&(<./\);. 1)])d NB. tacit form >>>>>10 7 5 5 5 1 1 8 2 2 >>>>> >>>>> (;@(<&(<./\);. 1)~1,2>/\])d NB. tacit avoiding one "]" 10 7 5 5 5 >>>>>1 1 8 2 2 >>>>> >>>>>Mike >>>>> >>>>> >>>>Thanks for explanations. Your version seems to be most efficient. >>>> >>>> >>>> >>>---------------------------------------------------------------------- >>>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 >> >> >> >> > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
