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?
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 deficientf.g
sincef.g
can be seen asf/
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 as0
when used with.
.