scalar functions

APL-related discussions - a stream of APL consciousness.
Not sure where to start a discussion ? Here's the place to be
Forum rules
This forum is for discussing APL-related issues. If you think that the subject is off-topic, then the Chat forum is probably a better place for your thoughts !

scalar functions

Postby Roger|Dyalog on Fri Apr 17, 2020 8:04 pm

Of the APL primitive functions, the scalar functions are particularly nice: they extend to higher-rank arguments, and the dyadic functions accept arguments with unequal (but conforming) shapes. In the first generation APLs, the advantages of scalar functions over other functions are even more pronounced than in current APLs, because they and only they can be operands for the reduction, inner product, and outer product operators. Even now, they and only they are pervasive.

The treatment of the dyadic scalar functions on higher-ranked arguments is known as scalar extension, and the rules governing same are known as conformance rules. Scalar extension is a generalization of scalar multiplication in mathematics, defined for scalar × vector. Scalar extension, let alone the conformance rules, was not fully developed in A Programming Language [Iverson 1962]. §S.5 of the Summary of Notation speaks of “scalar multiple”, but it is only for multiplication on a scalar times a numerical or logical vector (but not the commute of same). Scalar extension was further developed in “Iverson Notation” in A Formal Description of System/360 [Falkoff et al. 1964]. In Table 1 on page 200, under “Logical and Numerical”, there is the following side paragraph:
All operations are extended component-by-component to dimensionally compatible vectors and matrices. If one of the operands is a scalar, it is treated as a vector or matrix of appropriate dimension whose components are all equal. Examples:

zx+y
zx×y
WUV
wxy
wx<y

Iverson notation, like A Programming Language, uses x–z to denote numerical values, u–w to denote logical values, lower case for scalars, lower case bolded for vectors, and upper case bolded for matrices (among other such conventions). In the printed journal, even reading with a magnifying glass, for the last of the five expressions above, I had to determine from context that the w is not (should not be) bolded because x and y are more clearly not bolded.

The conformance rules for a scalar dyadic function ⍺ f ⍵ are as follow:
  • (⍴⍺)≡(⍴⍵), or ⍺ or ⍵ is scalar (strict)
  • (⍴⍺)≡(⍴⍵), or ⍺ or ⍵ is single (permissive)
(A single is an array all of which dimensions are 1s, ∧/1=⍴⍵.) Other permissive alternatives are specified in some dialects.

The permissive treatment goes back to APL\360. The APL\360 Terminal System [Falkoff and Iverson 1967] and the APL\360 User’s Manual [Falkoff and Iverson 1968] were silent on the issue (the word “conformable” did not appear). But Sandra Pakin’s 1972 edition (first edition 1968) of APL\360 Reference Manual clearly stated the permissive treatment of singles.

More later about the possible origin and motivation of the permissive conformance rules.
Roger|Dyalog
 
Posts: 207
Joined: Thu Jul 28, 2011 10:53 am

Return to APL Chat

Who is online

Users browsing this forum: No registered users and 1 guest