2,951
edits
No edit summary |
(Editing; contrast shape rules with conformability) |
||
Line 1: | Line 1: | ||
{{Built-in|Inner Product|<nowiki>.</nowiki>}} | {{Built-in|Inner Product|<nowiki>.</nowiki>}} is a [[dyadic operator]] that produces a [[dyadic function]] when applied with two dyadic functions. It's a generalisation of the [[wikipedia:Matrix multiplication|matrix product]], allowing not just addition-multiplication, but any [[dyadic function]]s given as [[operand]]s. | ||
== Examples == | == Examples == | ||
Line 25: | Line 25: | ||
</source> | </source> | ||
The [[shape]]s of the arguments must be compatible with each other: The last [[axis]] of the left argument must have the same length as the first axis of the right argument, or formally, for <source lang=apl inline>X f.g Y</source> it must be that <source lang=apl inline>(¯1↑⍴X)≡(1↑⍴Y)</source>. Although this rule differs from [[conformability]], the arguments may also be subject to [[scalar extension|scalar]] or [[singleton extension]]. The shape of the result is <source lang=apl inline>(¯1↓⍴X),(1↓⍴Y)</source>. | |||
For example, when applying inner product on two [[matrix|matrices]], the number of columns in the left array must match with number of rows in the right array, otherwise we will get an error. | For example, when applying inner product on two [[matrix|matrices]], the number of columns in the left array must match with number of rows in the right array, otherwise we will get an error. |