Kronecker product: Difference between revisions
Content added Content deleted
imported>Maxima enthusiast No edit summary |
imported>Maxima enthusiast |
||
Line 2,756: | Line 2,756: | ||
/* Kronecker product implementation */ |
/* Kronecker product implementation */ |
||
alternative_kronecker(MatA,MatB):=block(auxlength:length(first(args(MatA))),makelist(i*args(MatB),i,flatten(args(MatA))), |
|||
/* input: lists of lists trivially convertible to matrices */ |
|||
makelist(apply(matrix,%%[i]),i,1,length(%%)), |
|||
my_kronecker(Alist,Blist):=block(auxlength1:length(first(Alist)),auxlength2:length(first(Blist)),L:makelist(i*Blist,i,flatten(Alist)), |
|||
lst_equally_subdivided(%%,auxlength), |
|||
L1:makelist(auxkron(j,L),j,1,auxlength1),L2:makelist(lst_equally_subdivided(L1[i],auxlength1),i,1,length(L1)),makelist(auxkron(j,L2),j,1,auxlength1), |
|||
makelist(map(args,%%[i]),i,1,length(%%)), |
|||
flatten(%%),lst_equally_subdivided(%%,auxlength1*auxlength2),apply(matrix,%%)); |
|||
makelist(auxkron(j,%%),j,1,auxlength), |
|||
makelist(apply(append,%%[i]),i,1,length(%%)), |
|||
apply(matrix,%%), |
|||
transpose(%%), |
|||
args(%%), |
|||
makelist(apply(append,%%[i]),i,1,length(%%)), |
|||
apply(matrix,%%)); |
|||
</syntaxhighlight> |
</syntaxhighlight> |
||
{{out}}<pre> |
{{out}}<pre> |
||
Line 2,768: | Line 2,775: | ||
D:matrix([0,5],[6,7])$ |
D:matrix([0,5],[6,7])$ |
||
alternative_kronecker(A,B); |
|||
my_kronecker(args(A),args(B)); |
|||
/* matrix( |
/* matrix( |
||
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0], |
[0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0], |
||
Line 2,781: | Line 2,788: | ||
) */ |
) */ |
||
alternative_kronecker(C,D); |
|||
my_kronecker(args(C),args(D)); |
|||
/* matrix( |
/* matrix( |
||
[0, 5, 0, 10], |
[0, 5, 0, 10], |