|
From: | Louis de Forcrand |
Subject: | Re: [Bug-apl] tensor product |
Date: | Sun, 24 Jan 2016 22:21:41 +0100 |
I have no idea what you’re actually trying to do, but this (inelegant) lambda works: tensor←{ ,[1 2] { { ,[3 4] 1 3 2 4 ⍉ ⍵} ⍣ (2 < ⍴⍴⍵) ⍵ } ⍺ ∘.× ⍵} Basically, it conditionally executes the transpose and first ravel if the result of the outer product is of rank greater than 2. If you don’t mind having a stray variable floating around, this is more readable: tensor←{ ,[1 2] { ,[3 4] 1 3 2 4 ⍉ ⍵} ⍣ ( 2 < ⍴⍴T ) T ← ⍺ ∘.× ⍵} Best regards! Louis
|
[Prev in Thread] | Current Thread | [Next in Thread] |