pd 'reset' pd 'type marker' pd 'color red' pd j./"1 ,:7.87302 2.63376e8 pd 'color green' pd j./"1 ,:2.74571 3.24026e8 pd 'color blue' pd j./"1 [6.53307 2.23953e8 ,: 2.46257 2.33259e8 pd 'color black' pd j./"1 ,:11.5519 5.73956e8 pd 'show'
2 <-> red 3 <-> blue 4<-> green 5 <-> black NB. I had to use "1 ,: otherwise error in: plot_gs_paint length error: qtmark_diamond 'x y' =.|:y and I had to force J down Engine: j701/2011-01-10/11:25 Library: 8.02.10 Qt IDE: 1.1.3/5.3.0 Platform: Win 64 Installer: J802 install R.E. Boss (Add your info to http://www.jsoftware.com/jwiki/Community/Demographics ) > -----Original Message----- > From: programming-boun...@forums.jsoftware.com [mailto:programming- > boun...@forums.jsoftware.com] On Behalf Of Joe Bogner > Sent: zondag 27 juli 2014 15:19 > To: programm...@jsoftware.com > Subject: Re: [Jprogramming] finding matching sets > > Thank you all for the suggestions and alternate implementations. I ran > benchmarks on them all and wanted to share: > > $ t2 > 1763140 3 > > NB. Thomas's suggestion > groups1 =: 3 : 0 > ]key=. (}."1</.{."1) y > (<"1 t) ,.~ (;key) ,. (<"1|:e.key) > ) > timespacex 'groups1 t2' > NB. out of memory > > NB. Joe's implementation > groups2 =: 3 : 0 > groups=. [: (}."1 each </. ]) ({."1 </. ]) > ids=. ; L:2 @: ([: (~.L:1) 0{"1 L:1 ]) > ids groups y > ) > timespacex 'groups2 t2' > NB. 7.87302 2.63376e8 > > NB. R.E. Boss's 1st implementation > groups3a=: 3 : 0 > (~. {."1 t2) </.~ (i.~ ~.) ({."1 </. }."1) y > ) > timespacex 'groups3a t2' > NB. 6.53307 2.23953e8 > > NB. R.E. Boss's 2nd implementation > groups3b =: 3 : 0 > T=.(i.~ ~.)"1 &.|:y > (~.{."1 y) </.~ (i.~ ~.)({."1 </.}."1) T > ) > timespacex 'groups3b t2' > NB. 2.46257 2.33259e8 > > NB. Greg Hei's implementation > groups4 =: 3 : 0 > (~.{."1 y) </. ~ (i.~ ~.) ({."1 </.([:;}.)"1) y > ) > timespacex 'groups4 t2' > NB. 2.74571 3.24026e8 > > NB. Pascal Jasmin's symbol test > groups5 =: 3 : 0 > symboled=. ( ({. (, <) [: s: <@:(1&{:: , ' ' , [: ": 2&{::))) "1 y > (([: ~. {."1) </.~ [: (i.~ ~.)({."1 </.}."1)) symboled > ) > timespacex 'groups5 t2' > NB. 11.5519 5.73956e8 > > timespacex '(([: ~. {."1) </.~ [: (i.~ ~.)({."1 </.}."1)) symboled' > NB. 5.42007 1.38506e8 > > If I apply Greg's to the symboled: > timespacex '(~.{."1 symboled) </. ~ (i.~ ~.) ({."1 </.([:;}.)"1) symboled' > NB. 1.43217 1.09604e8 > > So it seems that the symbol comparisons are faster, but in this case > probably not worth the six second penalty to create > > > Of the 1.7M rows: > > There are 2104 unique values in the first column > $ ~. 0{"1 t2 > 2104 > > And 7,277 in the 2nd two columns > $ ~. }."1 t2 > 7277 2 > > On Sun, Jul 27, 2014 at 12:58 AM, greg heil <ghei...@gmail.com> wrote: > > Joe > > > > If the only thing that matters is the car and cdr of each entry why > > not just raze the cdr, eg > > > > (~.{."1 t)</.~ (i.~ ~.) ({."1 </.([:;}.)"1) t > > > > or just not box them separately in the first place;-) > > > > One could independently take symbols, and do that timing experiment. > > > > greg > > ~krsnadas.org > > ---------------------------------------------------------------------- > > 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