> is not a "rank-0 monad" like the others (the result can be non-scalar).
*: is implemented as *~ and is not affected by this particular optimization. Other ways of computing the identity function better have a pretty good story (such as the one you gave for <.integers) and a pretty easy implementation to warrant optimization. ----- Original Message ----- From: Henry Rich <[EMAIL PROTECTED]> Date: Wednesday, January 3, 2007 7:52 pm Subject: RE: [Jprogramming] Special code for <. on integers? > Also could have > > B I D X Q > > 1 1 1 1 1 > *: 1 > > > Henry Rich > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [EMAIL PROTECTED] On Behalf Of Roger Hui > > Sent: Wednesday, January 03, 2007 6:08 PM > > To: Programming forum > > Subject: Re: [Jprogramming] Special code for <. on integers? > > > > I am not sure that it is a Good Thing but it is > > (to quote a recent comment by a user) probably > > harmless, so I have tweaked the following cases > > of rank-0 monads: > > > > B I D X Q > > <. 1 1 1 > > >. 1 1 1 > > + 1 1 1 1 1 > > * 1 > > %: 1 > > | 1 > > > > The following benchmarks demonstrate the improvements: > > > > J6.02x > > x=: 1e6 [EMAIL PROTECTED] 2e9 > > ts=: 6!:2 , 7!:[EMAIL PROTECTED] > > ts ']x' > > 2.05645e_6 512 > > ts '<.x' > > 2.05962e_6 576 > > ts '+x' > > 1.90164e_6 512 > > > > J6.01: > > ts ']x' > > 1.89801e_6 512 > > ts '<.x' > > 0.00571713 4.19488e6 > > ts '+x' > > 0.00588315 4.19482e6 > > > > > > > > ----- Original Message ----- > > From: Henry Rich <[EMAIL PROTECTED]> > > Date: Wednesday, January 3, 2007 10:44 am > > Subject: [Jprogramming] Special code for <. on integers? > > > > > t =. ? 1000000 # 1000 > > > ts '] t' > > > 4.21309e_6 640 > > > ts '<. t' > > > 0.00720339 4.19494e6 > > > > > > I am working on graphics display lists which need > > > to end up as integers. They sometimes turn to > > > floats when they are scaled, and then they have to > > > be turned back into integers. To accommodate all > > > the cases I have, I end up executing <. more times than > > > is really necessary. > > > > > > Wouldn't it be a Good Thing for <. and >. to be fast NOPs > > > (i. e. like ]) when applied to integer or Boolean arrays? > > > > > > I guess I can use <.^:(4 < 3!:0) but I still think the change > > > is worthwhile. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
