direct product



|for what it's worth, I don't think there's a built-in direct matrix product
|in Maxima, but you can easily define your own solution. For instance, I
|believe the following function will do what you expect:

Hi Viktor,

I'm not absoultely sure, but I think that

 |P:ZEROMATRIX(LENGTH(A)*LENGTH(A[1]),LENGTH(B)*LENGTH(B[1])),

should be something like

 P:ZEROMATRIX(LENGTH(A)*LENGTH(B),LENGTH(A[1])*LENGTH(B[1])),

and

 |P[(i-1)*LENGTH(A[1])+j,(k-1)*LENGTH(B[1])+l]:A[i,j]*B[k,l],

should be something like

 P[k+length(B)*(i-1),l+length(B[1])*(j-1) ]:A[i,j]*B[k,l],

apologies if my thinking is wrong.
----------
So the function would be, 

directprod(A,B):=([P],
   IF NOT (MATRIXP(A) AND MATRIXP(B)) THEN
      ERROR("Invalid arguments to DIRECTPROD()")
     ELSE
 P:ZEROMATRIX(LENGTH(A)*LENGTH(B),LENGTH(A[1])*LENGTH(B[1])),
 FOR i THRU LENGTH(A) DO
  FOR j THRU LENGTH(A[1]) DO
   FOR k THRU LENGTH(B) DO
    FOR l THRU LENGTH(B[1]) DO
 P[k+length(B)*(i-1),l+length(B[1])*(j-1) ]:A[i,j]*B[k,l],
 P
);

If I understand the direct produce and what is being computed,

for two matrices,
                                                                                          
A:matrix([1,2],[3,4]);
                             [ 1  2 ]

                             [ 3  4 ]
B:matrix([0,1],[1,0]);
                             [ 0  1 ]
                             [ 1  0 ]
                                                                                          
direct product a*b is
matrix([a[1,1]*b,a[1,2]*b],[a[2,1]*b,a[2,2]*b]);
                                                                                          
    [ [ 0  1 ]  [ 0  2 ] ]
    [ [      ]  [      ] ]
    [ [ 1  0 ]  [ 2  0 ] ]
    [                    ]
    [ [ 0  3 ]  [ 0  4 ] ]
    [ [      ]  [      ] ]
    [ [ 3  0 ]  [ 4  0 ] ]
                                                                                          
direct product b*a is
matrix([b[1,1]*a,b[1,2]*a],[b[2,1]*a,b[2,2]*a]);
                                                                                          
   [ [ 0  0 ]  [ 1  2 ] ]
   [ [      ]  [      ] ]
   [ [ 0  0 ]  [ 3  4 ] ]
   [                    ]
   [ [ 1  2 ]  [ 0  0 ] ]
   [ [      ]  [      ] ]
   [ [ 3  4 ]  [ 0  0 ] ]

I checked the above routine for directproduct(A,B) and
directproduct(B,A) for

a:matrix([1,2],[3,4]);
b:matrix([0,1],[1,0]);

a:matrix([1,2],[3,4]);
b:matrix([0,1,1],[1,0,1]);

a:matrix([1,2],[3,4]);
b:matrix([1,1,0],[0,1,1],[1,0,1]);

Can someone verify or correct my thinking?

lp