Code: Select all
u@(v"(1+lv,_))
where lv is the left rank of v and _ is infinity. The common inner product in math and in APL, +.×, would then be:
Code: Select all
+⌿@×"1 ∞
(The left rank of × is 0.) Coupled with the prefix agreement in J, this prescribes an efficient implementation (factor of 10). For example, if x←2 3⍴⍳6 and y←10+3 4⍴⍳12, this +⌿@×"1 ∞ definition prescribes that the two rows of the result be computed as:
Code: Select all
+⌿ 0 1 2×⍤¯1 ⊢y
+⌿ 3 4 5×⍤¯1 ⊢y
See Inner Product -- An Old/New Problem http://www.jsoftware.com/papers/innerproduct/ip.htm .
Each left and each right can be effected using rank (J or Dyalog) in a more general way. For example, you can say each row of the left against the entire of the right, the entire of the left against each scalar of the right, etc.:
Code: Select all
x←2 3⍴⍳6
y←3 2⍴'abcdef'
x {⍺⍵}⍤0 99⊢y ⍝ link each left
┌─┬──┐
│0│ab│
│ │cd│
│ │ef│
├─┼──┤
│1│ab│
│ │cd│
│ │ef│
├─┼──┤
│2│ab│
│ │cd│
│ │ef│
└─┴──┘
┌─┬──┐
│3│ab│
│ │cd│
│ │ef│
├─┼──┤
│4│ab│
│ │cd│
│ │ef│
├─┼──┤
│5│ab│
│ │cd│
│ │ef│
└─┴──┘
x {⍺⍵}⍤1 99⊢y ⍝ link each left row
┌─────┬──┐
│0 1 2│ab│
│ │cd│
│ │ef│
├─────┼──┤
│3 4 5│ab│
│ │cd│
│ │ef│
└─────┴──┘
x {⍺⍵}⍤99 1⊢y ⍝ link each right row
┌─────┬──┐
│0 1 2│ab│
│3 4 5│ │
├─────┼──┤
│0 1 2│cd│
│3 4 5│ │
├─────┼──┤
│0 1 2│ef│
│3 4 5│ │
└─────┴──┘