I'm studying tensor products[1] and I came up with these two definitions, resp. for the operation between vectors and between matrices:
tensor1←{,⍺∘.×⍵}
tensor2←{,[1 2],[3 4]1 3 2 4⍉⍺∘.×⍵}
Jay's version is more efficient, because it performs a single reshape, but it needs (⍴⍺)×⍴⍵, not (⍴⍺)+⍴⍵:
tensor2←{((⍴⍺)×⍴⍵)⍴1 3 2 4⍉⍺∘.×⍵}
It only works in Wikipedia's example because (2+2)=2×2
Can anybody suggest an idiomatic way to combine tensor1 and tensor2 into a single function? (Without using multi-statement functions or non-GNU APL syntax.)
Tobia
[1] on this very interesting book: Yanofsky, Mannucci - Quantum Computing for Computer Scientists