Outer Product: Difference between revisions
Jump to navigation
Jump to search
m (remove duplicated code) |
mNo edit summary |
||
Line 1: | Line 1: | ||
== Outer Product == | == Outer Product == | ||
Outer product is a [[monadic operator]], which will produce a [[dyadic function]] when applied with a [[dyadic function]]. In APL, the outer product is a generalisation of the [https://en.wikipedia.org/wiki/Matrix_multiplication matrix product], which allows not only multiplication, but any [[dyadic function]] given. In short, outer product allows you to apply a given function for each element from the left array with each element to the right array. | |||
Outer product is a [[monadic operator]], which will produce a [[dyadic function]] when applied with a [[dyadic function]]. In APL, the outer product is a generalisation of the [https://en.wikipedia.org/wiki/Matrix_multiplication matrix product], which allows not only multiplication, but any [[dyadic function]] given. | |||
=== Syntax === | === Syntax === | ||
Line 24: | Line 23: | ||
8 10 12 | 8 10 12 | ||
12 15 18 | 12 15 18 | ||
⍝ works for multi-dimensional array as well | |||
y←2 3 ⍴ 'abcdef' | |||
x←2 2 ⍴ ⍳4 | |||
x∘.,y | |||
┌───┬───┬───┐ | |||
│1 a│1 b│1 c│ | |||
├───┼───┼───┤ | |||
│1 d│1 e│1 f│ | |||
└───┴───┴───┘ | |||
┌───┬───┬───┐ | |||
│2 a│2 b│2 c│ | |||
├───┼───┼───┤ | |||
│2 d│2 e│2 f│ | |||
└───┴───┴───┘ | |||
┌───┬───┬───┐ | |||
│3 a│3 b│3 c│ | |||
├───┼───┼───┤ | |||
│3 d│3 e│3 f│ | |||
└───┴───┴───┘ | |||
┌───┬───┬───┐ | |||
│4 a│4 b│4 c│ | |||
├───┼───┼───┤ | |||
│4 d│4 e│4 f│ | |||
└───┴───┴───┘ | |||
</source> | </source> | ||