Post Reply 
Matrix tensor product
02-25-2018, 05:02 PM
Post: #1
Matrix tensor product
Hey guys, i'm looking for a way to "properly" do a tensor product.
By properly i mean: [0, 1] tensor [1, 0] = [0, 1, 0, 0]
Precisely i want the calculator to keep the dimensions, and he don't, which cause me troubles in cases like:

x x x x
x x x x
x x x x . tensor([0, 1], [1, 0])
x x x x

because the tensor's returned matrix is 1x3.

Thanks ! Smile
Find all posts by this user
Quote this message in a reply
06-27-2019, 07:28 PM
Post: #2
RE: Matrix tensor product
(02-25-2018 05:02 PM)Akrone Wrote:  Hey guys, i'm looking for a way to "properly" do a tensor product.
By properly i mean: [0, 1] tensor [1, 0] = [0, 1, 0, 0]
Precisely i want the calculator to keep the dimensions, and he don't, which cause me troubles in cases like:

x x x x
x x x x
x x x x . tensor([0, 1], [1, 0])
x x x x

because the tensor's returned matrix is 1x3.

Thanks ! Smile

I know this bus has long since left the station, but:

Thanks to Didier Lachieze, his kronecker program will accomplish the task. Please note that the result for the two vectors in the OP's example is not correct, it should be: [0,0,1,0].

The tensor product is useful in the field of quantum mechanics, which is where I encountered it, (today), and hence this late reply!

Code:

//        kronecker(a,b)
//        Didier Lachieze 
//          2/17/2019

#cas
kronecker(a,b):=
BEGIN
 local m,n,p,q;
 m:=rowDim(a); n:=colDim(a);
 p:=rowDim(b); q:=colDim(b);
 makemat((j,k)→a(iquo(j-1,p)+1,iquo(k-1,q)+1)*b(irem(j-1,p)+1,irem(k-1,q)+1),m*p,n*q);
END;
#end

-Dale-
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)