# HP Forums

Full Version: Matrix tensor product
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 !
(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 !

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-
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :