[GAP Forum] ConvertToMagma

Thomas Breuer sam at Math.RWTH-Aachen.De
Tue Jul 28 23:31:18 BST 2020


Dear Keith,

in order to avoid printing the data to the screen,
I would suggest that you do not use 'LogTo' and 'Print'
but instead build a string and write it to a file in the end.
And in order to avoid unwanted backslashes in the file,
you can use 'FileString' instead of 'Print' for creating the file.

This approach is taken in the function 'CTblLib.MagmaStringOfPermGroup'
which is used as a utility by the GAP package 'CTblLib'.
Unfortunately, the currently distributed version of this package
does not contain this function.
You can find the code in the archive of the newer version 1.3
of CTblLib (see http://www.math.rwth-aachen.de/~Thomas.Breuer/ctbllib/),
or I can send you the code of the function.

All the best,
Thomas


On Tue, Jul 28, 2020 at 03:58:01PM -0400, R. K. Dennis wrote:
> Colleagues:
> 
> GAP provides a utility called
> 
>   ConvertToMagmaInputString(group)
> 
> which will give a description, in terms of magma commands, of a
> group, group, given by GAP.
> 
> For example, a permutation is given by
> 
>   PermutationGroup<n|perm1,perm2,...>
> 
> Here perm1, perm2, etc are permutations in cycle notation.
> Presumably, (I didn't try this) if one inputs this on the
> magma command line, everthing works out fine.
> 
> However, if one has a large n (the number of moved points),
> then one doesn't want to input this by hand, so one saves it
> to a file.  No matter what I tried, I couldn't get this 
> to work properly.
> 
> I wrote to magma help and received a reply from John
> Cannon:  He said (using GAP terminology), use ListPerm
> notation for the saved permutations.
> 
> So I wrote a GAP program to implement this:
> 
> Perm2MagmaFile.gap
> Perm2MagmaFile:=function(grp,fil)
>     local str,lrg,gen,num,i,beg,tmp,cat,prm,out;
>     if((not IsBound(grp)) or (not IsBound(fil))) then
>         return "A permutation group and an output file name must be given\n";
>     fi;
>     if(not IsPermGroup(grp)) then
>         return "Input group must be a permutation group\n";
>     fi;
>     str:="PermutationGroup<";
>     lrg:=LargestMovedPoint(grp);
>     gen:=SmallGeneratingSet(grp);
>     num:=Size(gen);
>     LogTo(fil);;
>     beg:=Concatenation(str,String(lrg),"|");
>     Print(beg);
>     for i in [1..num] do
>         prm:=ListPerm(gen[i],lrg);    
>         tmp:=String(prm);
>         RemoveCharacters(tmp," \n\t\r");    
>         if(i<num) then
>             cat:=Concatenation("\\",tmp,",");
>             Print("\n",cat);
>         else
>             cat:=Concatenation("\\",tmp,"\n>\n");
>             Print("\n",cat);
>         fi;
>     od;
>     LogTo();;
> end;
> 
> 
> For example, for the group PSL(3,3) one obtains the file
> 
> PermutationGroup<13|
> \[1,2,3,4,8,9,10,11,12,13,5,6,7],
> \[2,5,8,11,1,4,3,7,10,13,6,12,9]
> >
> 
> I chose an example that should appear correctly under e-mail.
> 
> The files written by the program, if read by "more" or "less" on
> a unix system will have no backslashes ( \ ) indicating line
> wraps; such will probably appear when using an editor (such as
> emacs) however.
> 
> One the reads the file from the command line as follows:
> 
> G := eval Read("file.lp");
> 
> which creates the group G from the file read.
> 
> I've tested this successfuly with reasonably large groups such as the
> Tits simple group and ON.
> 
> The main AWFUL problem with this program is that it sends the data to
> the screen as well as the file.  Presumably if one creates a file and
> uses AppentTo(file,data) one needs to prevent wrapping in the file
> using SetPrintFormattingStatus( , ), but I never could get this set
> properly.
> 
> So I'll end with a request and a suggestion:
> 
> 1.  Could someone show me how to stop the file printing from wrapping
>     lines without using LogTo?
> 
> 2.  I suggest that the manual pages for ConvertToMagmaInputString
>     either give an example to show exactly what to put on the
>     magma command line to input data saved as a file from output
>     described in the form as given.  Or, remark that results saved
>     in a file should be in ListPerm format, and give an example.
> 
> 
> Keith Dennis
> 
> 
> 
> 
> _______________________________________________
> Forum mailing list
> Forum at gap-system.org
> https://mail.gap-system.org/mailman/listinfo/forum



More information about the Forum mailing list