Newsgroups: comp.lang.apl
Path: utzoo!utgpu!watserv1!watmath!ljdickey
From: ljdickey@watmath.waterloo.edu (L.J.Dickey)
Subject: Re: Grade Down Columns of An Array
Message-ID: <1991Jun24.001559.27591@watmath.waterloo.edu>
Organization: University of Waterloo
References: <33789@usc.edu> <1991Jun21.060649.919@watmath.waterloo.edu>
Date: Mon, 24 Jun 1991 00:15:59 GMT
Lines: 68

In article <1991Jun21.060649.919@watmath.waterloo.edu> I wrote:
>In article <33789@usc.edu> ann@neuro.usc.edu (Ann Simpson Chapin) writes:
>>Does anyone know how to grade down the columns of an array (rank 2) so that
>>each column of the array is graded down as if it is a separate vector?
>
>I have a solution to this problem.
> ...

Well, I have thought a little more about this and have learned some more.

Earlier, I presented this:

   NB: =: '0 0$0' : 'x.'
   shape =. 4 5
   m =. (($?~)*/) shape       NB: 'Deal me a matrix.'
   m                          NB: 'What did I get?'
   r =. (\:"1)&.|:m           NB: 'Grade down each row under transpose.'
   c =. ($m)$i.}.$m           NB: 'Plain column selectors.'
   ( <"1 r,"_2 c ){m          NB: 'The desired result.'

Here, I will show another solution that I found, a solution that
is far superior, in my opinion:

   (\:"1 m) {"1 m		

This can be presented as a tacit function

   sbr =. {"1 ~ \:"1
   sbr m			

and of course, as a consequence, the expression

   sbr &. |: m

does the desired task.  Finally, as was gently pointed
out by two kind readers, the expression
   
   \:~ "1 m

simply sorts by rows. So, 

   \:~ "1 &. |: m

sorts by columns.  I suppose that when all else fails, RYFM. (*)


Further comments:

My original solution seems quite silly to me now, because of the
complicated structure that I needed to build.  I have not found
a use for the indices yet.  I am afraid that it will be just an
amusing exercise.

As before, the rank operator plays an essential role in each
of the above solutions.  But in these two solutions above,
strong primitives are used (sort and grade down)

						Lee Dickey

(*) Reference: ``Computer Wimp'', by John Baer. Ten Speed Press,
Berkeley (1983), ISBN 0-89815-101-5, p. 204.


-- 
Prof L.J. Dickey, Faculty of Mathematics, U of Waterloo, Canada N2L 3G1
internet:       ljdickey@watmath.UWaterloo.ca	BITNET/EARN:	ljdickey@watdcs
obsolescent?:	ljdickey@watmath.waterloo.edu
UUCP:		ljdickey@watmath.UUCP	..!uunet!watmath!ljdickey
