Created
June 11, 2018 15:58
-
-
Save TheFausap/ac323e70009504f32587fd4855fea3a3 to your computer and use it in GitHub Desktop.
kronecker_product for MACSYMA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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