João Araújo wrote:
I have a matrix of transformations:
[[Transformation([1,2]),Transformation([2,2])],
[Transformation([2,2]),Transformation([2,2])],
[Transformation([1,2]),Transformation([2,1])]]

and I want to replace
[Transformation([1,2]) by 1;
[Transformation([2,2]) by 2;
[Transformation([2,1]) by 3

obtaining the matrix

[[1,2],
 [2,2],
 [1,3]].


Dear João,

You need a to create some sort of mapping from the transformations to the integers. You can do this directly as follows:


gap> d := Domain([ Transformation( [ 1, 2 ] ),Transformation( [ 2, 2 ] ) ,Transformation( [ 2, 1 ] )]);
<object>
gap> d2 := Domain([1,2,3]);
<object>
gap> tups := List([1..3], i->Tuple([AsList(d)[i],AsList(d2)[i]]));
[ Tuple( [ Transformation( [ 1, 2 ] ), 1 ] ), Tuple( [ Transformation( [ 2, 2 ] ), 2 ] ),
  Tuple( [ Transformation( [ 2, 1 ] ), 3 ] ) ]
gap> map := GeneralMappingByElements(d,d2,tups);
<general mapping: <object> -> <object> >
gap> IsBijective(map);
true

Then you can just use the map to obtain the matrix entries such as

gap> Image(map,Transformation([1,2]));
1


Another way is to create this map indirectly by putting the transformations in a list and asking for their position such as

gap> lst := [ Transformation( [ 1, 2 ] ), Transformation( [ 2, 2 ] ), Transformation( [ 2, 1 ] ) ]; [ Transformation( [ 1, 2 ] ), Transformation( [ 2, 2 ] ), Transformation( [ 2, 1 ] ) ]
gap> t := Transformation([1,2]);
Transformation( [ 1, 2 ] )
gap> Position(lst,t);
1

Hope this helps.

Robert F. Morse





_______________________________________________
Forum mailing list
[email protected]
http://mail.gap-system.org/mailman/listinfo/forum

Reply via email to