[GAP Forum] Two questions: newline suppression and iterators....

Max Neunhoeffer neunhoef at mcs.st-and.ac.uk
Thu Aug 6 09:42:34 BST 2009


Dear Gordon,

On Thu, Aug 06, 2009 at 08:31:18AM +0800, Gordon Royle wrote:
> Dear Gapsters
>
> I have two questions: one is minor
>
> (Q1) When I am printing  output with GAP (using "Print") for future  
> processing with another program, GAP appears to insert "newline"  
> characters without being asked; this screws up my subsequent program  
> which wants to process one line at a time.  How can I tell GAP to only  
> print newlines when I ask it to!
>
> The second would appear to be a very common need, but my search of the  
> archives has not revealed a solution...
This one is easy: See 
  ?SetPrintFormattingStatus
You simply do

gap> f := OutputTextFile("myoutput");;
gap> SetPrintFormattingStatus(f,false);

and then use 
   PrintTo(f,   STUFF   );
as you would use Print. This gets rid of the "nice" formatting.

In the end, do 

gap> CloseStream(f);

to close the file.

You can also say
gap> f := OutputTextUser();
gap> SetPrintFormattingStatus(f,false);

and then use PrintTo to write unformatted output to standard output
(do not close the stream in this case when you are done!).
>
> (Q2)  I want to process every element in a large RightTransversal. It is 
> too big to store as a list, but small enough to be processed "one  
> element at a time" - is there a way of making an iterator for  a  
> RightTransversal WITHOUT constructing the actual transversal itself...  
> just some way of saying "give me the next element of the transversal"?
As far as I see this is in general not easy to do and thus not
implemented in general. However, with a bit of luck you can use the
following technique using the "orb" package, if you can enumerate 
the orbit of G acting on the right cosets of your subgroup in some
other way (for example, if your subgroup is a point stabilizer):

  gens := AtlasGenerators("M24",1).generators;
  m24 := Group(gens);
  gensi := List(gens,x->x^-1);
  o := Orb(m24,1,OnPoints,rec(schreier := true));
  Enumerate(o);

This enumerates the orbit and stores a Schreier tree relatively
compactly.

  for i in [1..Length(o)] do
  w := TraceSchreierTreeForward(o,i);
  el := ORB_ApplyWord(One(m24),w,gens,gensi,OnRight);
  Print(el,"\n");
  od;

This produces a right transversal of the point stabiliser one by one.
Note that in general there will be some multiplications of group
elements necessary, so maybe you want to add a few random elements of
the group to your generating set to make the Schreier tree shallower.

If you have your subgroup given by generators, well, to use this
method you need to find something which is fixed under the subgroup
such that the orbit has the right size (this is where the luck comes
in):

gap> gens := AtlasGenerators("M24",11).generators;
gap> s := AtlasStraightLineProgram("M24",5).program;
gap> hgens := ResultOfStraightLineProgram(s,gens);
gap> null := List(hgens,x->NullspaceMat(x-One(x)));
gap> inter := SumIntersectionMat(null[1],null[2]);
gap> v := inter[2][1];
gap> v*hgens[1]=v;
true
gap> v*hgens[2]=v;
true
gap> o := Orb(gens,v,OnRight,rec(schreier := true));                
<open orbit, 1 points with Schreier tree>
gap> Enumerate(o);
<closed orbit, 1771 points with Schreier tree>

And now the same works. Although this is not a general method, it has
worked for me before (and will again, I am sure).

Cheers,
  Max.
>
> Cheers
>
> Gordon
>
>
> Professor Gordon Royle
> School of Mathematics and Statistics
> University of Western Australia
> gordon at maths.uwa.edu.au
>
>
>
>
>
>
>
> _______________________________________________
> Forum mailing list
> Forum at mail.gap-system.org
> http://mail.gap-system.org/mailman/listinfo/forum

-- 
Max Neunhoeffer              http://www-groups.mcs.st-and.ac.uk/~neunhoef/
> > > > > > > > > > >  May the Source be with you! < < < < < < < < < < < < 
The University of St Andrews is a registered Scottish charity: No SC013532



More information about the Forum mailing list