🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.apl
Article #86

mixed rank scalar functions

#86
From: Andrew Koenig
Date: Tue, 01 May 1984 19:14
23 lines
1849 bytes
I once thought through the problem of extending scalar functions to act
on arrays of different rank.  The basic problem is this: if you are
adding a matrix and a vector, should the vector be added to each row
of the matrix or each column?  I concluded that it should be possible
to do either, with the following syntax obviously suggesting itself:

	A+[1]B     or A+[2]B

Now, which should be which?  Well, suppose we consider higher ranks.
Then, in the cimplest non-trivial case, A and B will differ by one in
rank, and, if you like, the effect will be as if we had inserted a
1 in the appropriate place in the dimension vector of the lower-ranked
array, and then replicated it along that coordinate as appropriate.
Thus, if we are adding a 3 by 7 by 2 array to a 3 by 7 by 9 by 2 array,
we are inserting a new third element into the dimension vector of the
3 by 7 by 2 array, so this should be written as A+[3]B.

Back to the matrix+vector (or vector+matrix) case.  If we apply the
rule given above, we find that A+[1]B adds A to each row of B (or
B to each row of A), and A+[2]B adds A to each column of B.  Consistency
with other uses of [] requires that the highest possible subscript value
should be the default, so just adding a vector and a matrix should add
the vector to the columns of the matrix.
Technical Details
Message-ID: <2763@rabbit.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!ark

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.1 6/24/83; site rabbit.UUCP
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!allegra!alice!rabbit!ark
From: ark@rabbit.UUCP (Andrew Koenig)
Newsgroups: net.lang.apl
Subject: mixed rank scalar functions
Message-ID: <2763@rabbit.UUCP>
Date: Tue, 1-May-84 15:14:34 EDT
Article-I.D.: rabbit.2763
Posted: Tue May  1 15:14:34 1984
Date-Received: Wed, 2-May-84 05:37:07 EDT
Organization: AT&T Bell Laboratories, Murray Hill
Lines: 23