On Thursday 02 Feb 2012 19:16:51 Waldek Hebisch wrote: > I do not think we have this operation. We could add this, however:
I have added Kronecker product and Kronecker sum to Matrix code here: https://github.com/martinbaker/fricas/blob/master/src/algebra/matrix.spad.pamphlet Its probably better if you make any changes to RepresentationPackage1. > - currently inner loop is wasting work testing for equality of > indices, I think it is possible to eliminate it I have put 2 versions of kroneckerSum in the above code (kroneckerSum and kroneckerSum2) because I'm not sure which is most efficient, please delete the one that you like the least. kroneckerSum has loops nested to 4 levels and equality testing as above. It handles non-square matrices better (as defined kroneckerSum only applies to square matrices but it seems to work with non-square as if padded with zeroes). kroneckerSum2 has loops nested to 3 levels and no equality testing but it has more loops and more function calling so I'm not sure if it would be faster or, more importantly, if it would scale up better? It fails with error message if operands are not square. I have not added them to MatrixCategory as I don't know the implications of that. I put kroneckerSum in Matrix rather than SquareMatrix because SquareMatrix has a fixed dimension and therefore could not use a (%,%)- >% signature in SquareMatrix. The code from Franz looks a lot more compact than the version I adapted from RepresentationPackage1 but I'm not qualified to judge the relative performance issues so I will leave you to choose whether to substitute this: KroneckerProduct(A:Matrix R, B:Matrix R):Matrix R == i,j: Integer res1:List Matrix R := [ reduce(horizConcat$(Matrix R), _ [A(i,j)*B for j in 1..ncols(A)]) for i in 1..nrows(A)] reduce(vertConcat,res1) the other code from Franz also looks interesting but I don't know the issues for including it in FriCAS? > - I am not sure how you arrived at 'cartesianProduct' name, > certainly I will not look for this operation under such name. > I have met this operation IIRC under name 'tensorSum', but > it seems that for matrices usual name is 'kroneckerSum' The equivalent operations in graph theory seem to use the names tensor and Cartesian product: http://en.wikipedia.org/wiki/Tensor_product_of_graphs http://en.wikipedia.org/wiki/Cartesian_product_of_graphs and I'm sure that I’ve seen this in other algebras where these products are appropriate. Also in category theory when we need to distinguish from the categorical product. But I agree that for matrix algebra Kronecker product and Kronecker sum names are more common. > - the question is where to put this operation, RepresentationPackage1 > is not a good place. I think we should have such operations > in Matrix, I would add 'kroneckerSum' (modified version of code above), > 'kroneckerProduct' (former 'tensorProduct' from RepresentationPackage1) > and 'directSum' (form matrix corresponding to action on direct sum > of vector spaces) to Matrix. > Probably each in two versions: one > taking two arguments, the other one taking list of arguments. I have only added two argument versions so far. (I assume they are associative?) > Then in RepresentationPackage1 we could define 'tensorProduct' > simply as another name for 'kroneckerProduct' (tesnor product > is part of established terminology for representations, so I > want to preserve this name). I'll leave you to do that. It would be useful to me if you could include this matrix.spad.pamphlet in the next release, even if you don't have time to do any optimisations or RepresentationPackage1 stuff until some later release. Martin -- You received this message because you are subscribed to the Google Groups "FriCAS - computer algebra system" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/fricas-devel?hl=en.
