/* This file constructs a PC presentation for a generalised Nottingham group in MAGMA format. It exports Mpres to interpret.c. */ #include "global.h" #include extern int prime, rank, total; /* Imports from group_elt.c */ void initgroupelt(group_elt g); void gpower(group_elt g, int n); void commutator(group_elt f, group_elt g, group_elt h); /* Imports from presentation.c */ void normalform(group_elt g, vector v); /* Prototypes */ void set_file(FILE **fp_ptr); void fprintvec(vector v, FILE *fp); void fpowers(FILE *fp); void fcommutators(FILE *fp); void Mpres(void); void set_file(FILE **fp_ptr) { char s[2], fname[20]; printf("Do you want to direct the presentation to a file? y/n.\n"); scanf("%1s", s); if (s[0] == 'y') { printf("Enter filename:\n"); scanf("%s", fname); *fp_ptr = fopen(fname, "w"); } else *fp_ptr = stdout; } void fprintvec(vector v, FILE *fp) { int i, id = 1; for(i = 0; i < (total - rank - 1) * rank; i++) if (v[i]) { if (!id) fprintf(fp, "* "); fprintf(fp, "a%d^%d ", i + 1, v[i]); id = 0; } if (id) fprintf(fp, " 1 "); } void fpowers(FILE *fp) { int i, j, k, t = 1; vector v; group_elt g; for(i = rank + 1; i < total; i++) for(j = 0; j < rank; j++) { initgroupelt(g); for(k = 0; k < rank; k++) g[k][rank - k] = 1; g[j][i] = 1; gpower(g, prime); normalform(g, v); fprintf(fp, "a%d^%d = ",t++ , prime); fprintvec(v, fp); fprintf(fp, ",\n"); } } void fcommutators(FILE *fp) { vector vec; group_elt g, h, c; int i, j, u, v, k, t, s = 0; for(i = rank + 1; i < total; i++) for(j = 0; j < rank; j++) { initgroupelt(g); for(k = 0; k < rank; k++) g[k][rank - k] = 1; g[j][i] = 1; s++; t = 0; for(u = rank + 1; u < total; u++) for(v = 0; v < rank; v++) { t++; if (t>s) { initgroupelt(h); for(k = 0; k < rank; k++) h[k][rank - k] = 1; h[v][u] = 1; commutator(h, g, c); fprintf(fp, "(a%d,a%d)=",t,s); normalform(c, vec); fprintvec(vec, fp); if (t != rank * (total - rank - 1) || s != t-1) fprintf(fp,","); fprintf(fp,"\n"); } } } } void Mpres(void) { int complength, i; FILE *fp; set_file(&fp); complength = rank * (total - rank - 1); fprintf(fp, "G<"); for (i = 0; i < complength; i++) { fprintf(fp, "a%d", i+1); if (i < complength - 1) fprintf(fp, ","); } fprintf(fp, "> := PolycyclicGroup<"); for (i = 0; i < complength; i++) { fprintf(fp, "a%d", i+1); if (i < complength - 1) fprintf(fp, ","); } fprintf(fp, "|\n"); fpowers(fp); fcommutators(fp); fprintf(fp, ">;\n"); }