[GAP Forum] some questions
Jack Schmidt
jack at ms.uky.edu
Sun Jun 17 04:19:28 BST 2007
Here are some hopefully helpful suggestions from Alexander Konovalov,
Steve Linton, and myself.
R. Keith Dennis wrote:
> Dear Colleagues:
>
> I have several questions and would appreciate any suggestions. I've
> only recently attempted to do any real programming in GAP, so probably
> the solutions are obvious:
>
> 1. How does one generate file names (by program) so that a given
> session may have multiple output files? E.g., run a program without
> for each group order - test.16, test.32, test.64,... or append a time
> stamp, or even better, "if file xxx.001 exists then newfile name =
> xxx.002".
>
> LogTo didn't seem to accept the names I attempted to give in (in
> quotes, it used the variable name & without gave an error).
Some functions that take "string-like" arguments will convert your input
for you, but some really require strings, or even a single string.
LogTo and the related function PrintTo both require the filename to be a
string.
You can create such a string using the String and Concatenation
functions. For instance
gap> Concatenation("myfile.",String(23));
"myfile.23"
or an old trick for padding:
gap> Concatenation("myfile.",String(1023){[2..4]});
"myfile.023"
You can check if a file already exists with IsExistingFile:
gap> n:=1001;;
gap> fn:=Concatenation( "myfile.", String(n){[2..4]} );;
gap> while IsExistingFile( fn ) do
> n:=n+1;
> fn:=Concatenation( "myfile.", String(n){[2..4]} );
> od;
gap> fn;
"myfile.017"
Most likely if you really want 999 output files, you will also want to
use the PrintTo function rather than LogTo. LogTo is more suited to
interactive sessions, and PrintTo is more suited to programming.
> 2. How does one trap errors? E.g., something like
>
> if defined NumberSmallgroups(n) then
> Print(.....);
> else
> Print("NumberSmallGroups(",n,") is not defined\n");
> fi;
There is no method in GAP to trap errors, but the list of orders covered
by the small groups library is at:
http://www.tu-bs.de:8080/~hubesche/small.html
If you would like, we would be happy to forward you this list as a
simple GAP function that returns true/false based on whether an integer
falls into one of these categories.
> 3. How does one convert a matrix with integer entries to a matrix
> with entries mod q for some prime q?
You can multiply it by the identity element from the appropriate
residue class ring or finite field:
gap> [[1,2],[8,4]]*ZmodnZObj(1,6);
[ [ ZmodnZObj( 1, 6 ), ZmodnZObj( 2, 6 ) ],
[ ZmodnZObj( 2, 6 ), ZmodnZObj( 4, 6 ) ] ]
gap> [[1,2],[8,4]]*ZmodnZObj(1,5);
[ [ ZmodpZObj( 1, 5 ), ZmodpZObj( 2, 5 ) ],
[ ZmodpZObj( 3, 5 ), ZmodpZObj( 4, 5 ) ] ]
gap> [[1,2],[8,4]]*One(GF(5));
[ [ Z(5)^0, Z(5) ], [ Z(5)^3, Z(5)^2 ] ]
Or if you prefer to have integer entries reduced to their least
nonnegative residue mod q, you can just use "mod q":
gap> [[1,2],[8,4]] mod 5;
[ [ 1, 2 ], [ 3, 4 ] ]
> 4. Is there any reason SubdirectProduct is called that instead of
> PullBack? It seems to me the name is wrong or at least misleading. I
> would have thought a SubdirectProduct would, for example, take
> information such as an nxm matrix of group elements where the list in
> the i-th row are elements from the group G_i, and the subdirect
> product is the subgroup of the direct product generated by the m
> (columns) (g11,g21,...,gn1), ... , (g1m,g2m,...,gnm) in the direct
> product G1 x ... Gn. To ensure it's a subdirect product one would
> need that elements in the i-th row generate Gi (but there would be no
> reason to ask unless one really needed surjection on the factors).
The definition in GAP corresponds to its main use in the construction of
small perfect groups. This definition is equivalent to the standard
definition for subdirect products of pairs of groups by Lemma 2.1.2.iii
of Holt&Plesken's book, "Perfect Groups." As noted in section 2.1.3 of
this book, the general case does not have an easy translation into this
pullback framework, but within GAP one can only form subdirect products
of two groups, so this issue does not arise.
> I have more, but will stop here.
Please do not hesitate to ask more questions! You can write to GAP Forum
with questions that you believe are of general interest, and to GAP
Support (support at gap-system.org) with more technical questions.
More information about the Forum
mailing list