If you need exact integer results the expression should be v +//. x: n (or just v +//. n with n created to be extended precision). v x:@+//. n is a curious phrase and does not achieve the intent expressed in your msg.
----- Original Message ----- From: Mike Day <[EMAIL PROTECTED]> Date: Friday, September 28, 2007 3:07 Subject: [Jprogramming] Performance of exact keyed aggregate To: Programming forum <[email protected]> > Given values v, counts n: > v,:n > 1 2 1 2 1 2 1 2 1 > 20 30 40 30 40 20 40 30 40 > > We can sum the counts keyed by value > v (+//.) n > 180 110 > since > v (</.) n > +--------------+-----------+ > |20 40 40 40 40|30 30 20 30| > +--------------+-----------+ > > However my actual values for count get very large, > ie up to 2^50 or more, and I needed exact integer results > so used > v (x:@+//.) n > 180 110 > > but this got very slow. > > However once I used the indices i of the counts > i,v,:n > 0 1 2 1 2 0 2 > 1 2 > 1 2 1 2 1 2 1 > 2 1 > 20 30 40 30 40 20 40 30 40 > > the more indirect derivation > (v (</.) i) > +---------+-------+ > |0 2 2 2 2|1 1 0 1| > +---------+-------+ > (v (</.) i)(x:@+/@:{)every <n > 180 110 > > is much quicker. > > Any ideas why the circumlocution is faster than > the more obvious approach? (I don't know how > much because the slow version never finished.) > > Not really important in the scheme of things - > just a day lost in a Mathschallenge solution! > I hope that's not a give-away. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
