Inner Product
Revision as of 02:28, 6 September 2021 by Hou32hou (talk  contribs) (Created page with "{{BuiltinInner Product<nowiki>.</nowiki>}}, is a dyadic operator, which will produce a dyadic function when applied with two dyadic functions. In APL, the inner...")
.

Inner Product (.
), is a dyadic operator, which will produce a dyadic function when applied with two dyadic functions. In APL, the inner product is a generalisation of the matrix product, which allows not only additionmultiplication, but any dyadic functions given.
Examples
x ← 1 2 3
y ← 4 5 6
x ,.(↓,) y ⍝ visualizing inner product
┌─────────────┐
│┌───┬───┬───┐│
││1 4│2 5│3 6││
│└───┴───┴───┘│
└─────────────┘
x+.×y ⍝ matrix multiplication
32
Note that for inner product between Ndimensional arrays, their dimension must be compatible with each other.
For example, when applying innerproduct to a 2D array, the column count of the left array must match with the row count of the right array, otherwise we will get an error.
x ← 2 3⍴⍳10
y ← 4 2⍴⍳19
x+.×y
LENGTH ERROR
x+.×y
∧
y ← 3 2⍴⍳10 ⍝ reshape y to be compatible with x
x+.×y
22 28
49 64