Reputation: 344
In APL, one can construct a generalized inner product using f.g
. According to the manual, the result is an array in which each item is constructed from the vectors of the left and right operands as f/x g¨y
(x
and y
being the vectors taken along a specific axis of said operands). On first glance, the outer product looks to be derived from this: it is ∘.g
, which I obtain by setting f ← ∘
. If I evaluate this using the definition of the inner product, though, I don't seem to get valid APL code (I get ∘/x g¨y
, where ∘/
doesn't make a lot of sense in particular).
Are these two operators related with some magic underneath the hood, or is ∘.
just interpreted as a different operator which has nothing to do with the inner product?
Upvotes: 1
Views: 236
Reputation: 11
According to the IBM APL2 language reference (page 165):
Z←L LO.RO R ←→ Z←LO/¨(⊂[ρρL]L)∘.RO ⊂[1]R
(where ⎕IO←1 and LO and RO are your functions f and g respectively).
Upvotes: 0
Reputation: 7616
In all modern APLs, including Dyalog, ∘.
is indeed just special-cased, and no left operand to .
will make it behave like ∘.
— indeed, ∘
is a dyadic operator, which cannot be an operand to another dyadic operator (.
).
Historically, ∘.g
was seen as a sort of deficient f.g
since f.g
can be seen as f/
over the diagonal values of ∘.g
and thus, removing the reductions' part of the algorithm, an outer product remains. ∘
was used as a sort of "null function", but the symbol was later overloaded to become a regular dyadic (composition) operator.
It is however worth noting that Iverson later generalised the outer product in the form of the "tie" operator, where the left operand is a number indicating the number of "tied-up" dimensions, leaving all other dimensions to provide arguments that would be used in all combinations. Thus, 0 .g
became equivalent of ∘.g
and ∘
was defined as a boxed empty vector (essentially equivalent to today's ⊂⍬
) and was treated as 0
when used with .
.
Upvotes: 6