Inner Product: Difference between revisions

Jump to navigation Jump to search
94 bytes added ,  19:36, 6 September 2021
Editing; contrast shape rules with conformability
No edit summary
(Editing; contrast shape rules with conformability)
Line 1: Line 1:
{{Built-in|Inner Product|<nowiki>.</nowiki>}}, is a [[dyadic operator]], which will produce a [[dyadic function]] when applied with two [[dyadic function]]s. In APL, the inner product is a generalisation of the [https://en.wikipedia.org/wiki/Matrix_multiplication matrix product], which allows not only addition-multiplication, but any [[dyadic function]]s given.
{{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>


Note that 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>. The shape of the result is <source lang=apl inline>(¯1↓⍴X),(1↓⍴Y)</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.

Navigation menu