Skip to content

Instantly share code, notes, and snippets.

@TheFausap
Created June 11, 2018 15:58
Show Gist options
  • Select an option

  • Save TheFausap/ac323e70009504f32587fd4855fea3a3 to your computer and use it in GitHub Desktop.

Select an option

Save TheFausap/ac323e70009504f32587fd4855fea3a3 to your computer and use it in GitHub Desktop.
kronecker_product for MACSYMA
kprod(m1,m2) := block([res,t,t1],
if (not matrixp(m1)) or (not matrixp(m2)) then error("Wrong args"),
t : m1[1,1] * m2,
t1 : makelist(0,length(m1)),
for j : 1 thru length(m2) do (
for i : 2 thru length(m1) do (
t : addcol(t, m1[j,i]*m2)),
t1[j] : t,
t : m1[j,1]*m2),
res : t1[1],
for i : 2 thru length(t1) do (
res : addrow(res,t1[i])),
res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment