Martin Baker wrote:RepresentationPackage1
>
> tensorProduct is defined in RepresentationPackage1 but I can't find
> cartesianProduct. Have I missed it? If not would it be possible to add
> the following.
>
> definition:
>
> cartesianProduct : (M R, M R) -> M R
> ++ cartesianProduct(a,b) calculates the Kronecker sum
> ++ of the matrices {\em a} and b.
>
> implementation:
>
> cartesianProduct(a: M R, b: M R) ==
> n : NNI := nrows a
> m : NNI := nrows b
> nc : NNI := ncols a
> mc : NNI := ncols b
> c : M R := zero(n * m, nc * mc)
> indexr : NNI := 1 -- row index
> for i in 1..n repeat
> for k in 1..m repeat
> indexc : NNI := 1 -- column index
> for j in 1..nc repeat
> for l in 1..mc repeat
> if i = j then
> c(indexr,indexc) := c(indexr,indexc) + b(k,l)
> if k = l then
> c(indexr,indexc) := c(indexr,indexc) + a(i,j)
> indexc := indexc + 1
> indexr := indexr + 1
> c
>
> The reason I would like this is to check the Cartesian product of the
> graphs I am working on by taking Kronecker sum of adjacency matrix.
I do not think we have this operation. We could add this, however:
- currently inner loop is wasting work testing for equality of
indices, I think it is possible to eliminate it
- 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 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.
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 am not sure if you want to do all of this, if not I can do it.
--
Waldek Hebisch
[email protected]
--
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.