Inner Product
.
|
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 addition-multiplication, 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 N-dimensional arrays, their dimension must be compatible with each other.
For example, when applying inner-product 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 1 2 3 4 5 6 ⎕ ← y ← 4 2⍴⍳10 1 2 3 4 5 6 7 8 x+.×y LENGTH ERROR x+.×y ∧ ⎕ ← y ← 3 2⍴⍳10 ⍝ reshape y to be compatible with x x+.×y 22 28 49 64