kronprod := proc (A, B) options `Maple Advisor Database 1.00 for Maple V Release 4`, `Copyright (c) 1998 by Robert B. Israel. All rights reserved`; local Ap, Bp, i,j; if nargs > 2 then RETURN(kronprod(kronprod(A,B),args[3..nargs])) fi; if type(A,{vector,list(algebraic)}) and type(B,{vector,list(algebraic)}) then # vector x vector = vector vector([seq(seq(A[i]*B[j], j=1..linalg[vectdim](B)), i=1..linalg[vectdim](A))]) else # otherwise result is matrix if type(A,matrix) then Ap:= A elif type(A,listlist) then Ap:= convert(A,matrix) elif type(A,list) then Ap:= matrix(map(t->[t],A)) elif type(A,specfunc(list,transpose)) then Ap:= matrix([op(A)]) else Ap:= convert(A,matrix) fi; if type(B,matrix) then Bp:= B elif type(B,listlist) then Bp:= convert(B,matrix) elif type(B,list) then Bp:= matrix(map(t->[t],B)) elif type(B,specfunc(list,transpose)) then Bp:= matrix([op(B)]) else Bp:= convert(B,matrix) fi; linalg[stack](seq(linalg[augment]( seq(linalg[scalarmul](Bp,Ap[i,j]), j = 1 .. linalg[coldim](Ap))), i = 1 .. linalg[rowdim](Ap))); fi end;