bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Fwd: tensor product


From: Tobia C.
Subject: Re: [Bug-apl] Fwd: tensor product
Date: Sun, 24 Jan 2016 21:40:38 +0100

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]