Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!mips!news.cs.indiana.edu!ux1.cso.uiuc.edu!csrd.uiuc.edu!sp27.csrd.uiuc.edu!jaxon From: jaxon@sp27.csrd.uiuc.edu (Greg P. Jaxon) Newsgroups: comp.lang.apl Subject: Re: WANTED: a way to sort array so each column i Message-ID: <1991Apr19.145007.2201@csrd.uiuc.edu> Date: 19 Apr 91 14:50:07 GMT References: <31931@usc> <13APR91.22583472@uc780.umd.edu> <14APR91.18400456@uc780.umd.edu> <1991Apr17.151913.4891@csrd.uiuc.edu> Sender: news@csrd.uiuc.edu (news) Organization: UIUC Center for Supercomputing Research and Development Lines: 43 >> mix[K] is the left inverse of split[K], so just mix[#IO] F" split[#IO] A. >Is this solution correct? Don't you have to insert a new first dimension >and therefore the axis for mix should be fractional? The axes given to Mix (aka Disclose) name the NEW axs in the result array which will hold the axes of the items of the argument array. If you split them out with enclose[K], you can put them back with disclose[K]. >Underlying my original question regarding the APL2 method is the sense >that you often need auxiliary functions where in J you can do without. >Is this a general feeling? I've only been really annoyed by Indexing not being a 'function' and by '/' no longer being a function. In the sort problem, we only need the auxillary function for the indexing step, call it INX: mix[#IO] INX" grdn" split[#IO] A > I wonder if using >internal or external subroutines have different implications >regarding performance. >Eythan Weg Some: there's less hope of optimizing across the routine boundary. In APLB we found an efficient way to drive user-defined functions under control of primitive operators that made simple fns like INX 10 times faster when driven by (e.g.) the Each operator, than they are when driven by an equivalent loop. - We only enter and exit INX once! Robert Frey suggests: > A[; grdn rotate A] (surely you mean transpose, not rotate/reverse) > A[; grdn[1] A] I'm not sure about the last one, but in either case one permutation vector is being applied to all the columns, the question asks for the columns to be individually sorted so that each one is in descending order. To turn the philosophy discussion around, what do you think about doing the split and mix steps up in the user-accessible data domain? I kind of like seeing those intermediate data organizations, it gives me a handle on what I need to do next. In dictionary APL (and I think in J), more of this work is done silently inside the rank operator, where I'll grant you it can be a lot more efficient; but much more obscure! Greg Jaxon