CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/****************************************************************************
2
**
3
*A GAP_link_via_file.c ANUPQ source Eamonn O'Brien
4
*A & Frank Celler
5
*A & Benedikt Rothe
6
**
7
*Y Copyright 1995-1997, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany
8
*Y Copyright 1995-1997, School of Mathematical Sciences, ANU, Australia
9
**
10
*/
11
12
#include "pq_defs.h"
13
#include "pcp_vars.h"
14
#include "pga_vars.h"
15
#include "constants.h"
16
#include "global.h"
17
#include "pq_functions.h"
18
#include "menus.h"
19
20
#if defined(GAP_LINK_VIA_FILE)
21
22
/****************************************************************************
23
**
24
*F start_GAP_file
25
** write out initial information required for stabiliser calculation
26
**
27
*/
28
void start_GAP_file(FILE **GAP_input,
29
int ***auts,
30
struct pga_vars *pga,
31
struct pcp_vars *pcp)
32
{
33
register int i;
34
int nmr_soluble = pga->nmr_soluble;
35
36
/* open "GAP_input" file */
37
*GAP_input = OpenSystemFile("GAP_input", "w+");
38
39
if (!GAP4iostream) { /* this is necessary for GAP 4.2 compatibility */
40
fprintf(*GAP_input, "if not IsBound( PcGroupFpGroupNC ) then\n");
41
fprintf(*GAP_input, " PcGroupFpGroupNC := PcGroupFpGroup;\n");
42
fprintf(*GAP_input, "fi;\n");
43
}
44
45
GAP_presentation(*GAP_input, pcp, 1);
46
#ifdef HAVE_GMP
47
/* report the group and automorphism group order */
48
fprintf(*GAP_input, "ANUPQsize := ");
49
mpz_out_str(*GAP_input, 10, &(pga->aut_order));
50
fprintf(*GAP_input, ";\n");
51
fprintf(*GAP_input, "ANUPQagsize := ");
52
fprintf(*GAP_input, "%d;;\n", pga->nmr_soluble);
53
#else
54
fprintf(*GAP_input, "ANUPQsize := fail;;\nANUPQagsize := fail;;\n");
55
#endif
56
57
/* write global variables */
58
fprintf(*GAP_input, "ANUPQglb := rec();;\n");
59
fprintf(*GAP_input, "ANUPQglb.d := %d;;\n", pcp->ccbeg - 1);
60
fprintf(*GAP_input, "ANUPQglb.F := GF(%d);;\n", pga->p);
61
fprintf(*GAP_input, "ANUPQglb.one := One (ANUPQglb.F);;\n");
62
fprintf(*GAP_input, "ANUPQglb.q := %d;;\n", pga->q);
63
fprintf(*GAP_input, "ANUPQglb.s := %d;;\n", pga->s);
64
fprintf(*GAP_input, "ANUPQglb.r := %d;;\n", pga->r);
65
fprintf(*GAP_input, "ANUPQglb.agAutos := [];;\n");
66
fprintf(*GAP_input, "ANUPQglb.glAutos := [];;\n");
67
fprintf(*GAP_input, "ANUPQglb.genQ := [];;\n");
68
69
/* write the generators <gendp> to file */
70
for (i = 1; i <= nmr_soluble; ++i)
71
write_GAP_matrix(
72
*GAP_input, "ANUPQglb.agAutos", auts[i], pcp->ccbeg - 1, 1, i);
73
74
75
#ifdef DEBUG1
76
printf("The relative orders are ");
77
for (i = 1; i <= nmr_soluble; ++i)
78
printf("%d, ", pga->relative[i]);
79
printf("\n");
80
#endif
81
82
fprintf(*GAP_input, "relativeOrders := [");
83
if (nmr_soluble > 0) {
84
for (i = 1; i < nmr_soluble; ++i)
85
fprintf(*GAP_input, "%d, ", pga->relative[i]);
86
fprintf(*GAP_input, "%d", pga->relative[nmr_soluble]);
87
}
88
fprintf(*GAP_input, "];\n");
89
90
for (i = nmr_soluble + 1; i <= pga->m; ++i)
91
write_GAP_matrix(*GAP_input,
92
"ANUPQglb.glAutos",
93
auts[i],
94
pcp->ccbeg - 1,
95
1,
96
i - nmr_soluble);
97
}
98
99
100
/****************************************************************************
101
**
102
*F write_GAP_matrix
103
** write out a matrix in a GAP input form
104
**
105
*/
106
void write_GAP_matrix(
107
FILE *GAP_input, char *gen, int **A, int size, int start, int nr)
108
{
109
int i, j;
110
111
fprintf(GAP_input, "%s[%d] := [\n", gen, nr);
112
for (i = start; i < start + size; ++i) {
113
fprintf(GAP_input, "[");
114
for (j = start; j < start + size - 1; ++j)
115
fprintf(GAP_input, "%d, ", A[i][j]);
116
if (i != start + size - 1)
117
fprintf(GAP_input, "%d],\n", A[i][j]);
118
else
119
fprintf(GAP_input, "%d]] * ANUPQglb.one;;\n", A[i][j]);
120
}
121
}
122
123
124
/****************************************************************************
125
**
126
*F insoluble_stab_gens
127
** calculate the stabiliser of the supplied representative using GAP
128
**
129
*/
130
void insoluble_stab_gens(int rep,
131
int orbit_length,
132
struct pga_vars *pga,
133
struct pcp_vars *pcp)
134
{
135
FILE *GAP_rep;
136
char *path, *command;
137
char c;
138
int index;
139
int *subset;
140
int **S;
141
142
/* append the commands to compute the stabilizer */
143
GAP_rep = OpenFile("GAP_rep", "w+");
144
145
S = label_to_subgroup(&index, &subset, rep, pga);
146
GAP_factorise_subgroup(GAP_rep, S, index, subset, pga, pcp);
147
free_matrix(S, pga->s, 0);
148
free_vector(subset, 0);
149
if (!GAP4iostream) {
150
fprintf(GAP_rep, "LoadPackage(\"autpgrp\", \"1.5\");\n");
151
fprintf(GAP_rep, "if TestPackageAvailability(");
152
fprintf(GAP_rep, "\"anupq\", \"3.1\") <> true then\n");
153
fprintf(GAP_rep, " ANUPQData := rec(tmpdir := DirectoryCurrent());\n");
154
fprintf(GAP_rep, " DeclareInfoClass(\"InfoANUPQ\");\n");
155
fprintf(GAP_rep, " DeclareGlobalFunction(");
156
fprintf(GAP_rep, "\"PqStabiliserOfAllowableSubgroup\");\n");
157
fprintf(GAP_rep, " ReadPackage(\"anupq\", \"lib/anustab.gi\");\n");
158
fprintf(GAP_rep, "fi;\n");
159
fprintf(GAP_rep, "SetInfoLevel(InfoANUPQ, 2);\n");
160
}
161
fprintf(GAP_rep, "PqStabiliserOfAllowableSubgroup( ANUPQglb, F,\n");
162
fprintf(GAP_rep, " gens, relativeOrders, ANUPQsize, ANUPQagsize );\n");
163
164
CloseFile(GAP_rep);
165
166
if (GAP4iostream) {
167
printf("GAP, please compute stabiliser!\n");
168
169
/* skip a comment */
170
while ((c = getchar()) == ' ')
171
;
172
if (c == '#') {
173
while ((c = getchar()) != '\n')
174
;
175
}
176
177
/* we expect a line: "pq, stabiliser is ready.\n" */
178
if (c == 'p')
179
putchar(c);
180
while ((c = getchar()) != '\n')
181
putchar(c);
182
putchar(c);
183
} else {
184
/* try to find gap */
185
if ((path = (char *)getenv("ANUPQ_GAP_EXEC")) == NULL)
186
#if defined(ANUPQ_GAP_EXEC)
187
path = ANUPQ_GAP_EXEC;
188
#else
189
path = "gap";
190
#endif
191
command = (char *)malloc(strlen(path) + 200);
192
strcpy(command, path);
193
strcat(command, " -r -q -A GAP_input < GAP_rep");
194
195
/* inform the user that we are about to call GAP */
196
if (isatty(0))
197
printf("Now calling GAP to compute stabiliser...\n");
198
unlink("LINK_output");
199
200
/* compute the stabiliser of the orbit representative */
201
#ifdef HAVE_WORKING_VFORK
202
if (vsystem(command) != 0)
203
#else
204
if (system(command) != 0)
205
#endif
206
{
207
printf("Error in system call to GAP\n");
208
exit(FAILURE);
209
}
210
}
211
212
CloseFile(OpenFile("LINK_output", "r"));
213
214
unlink("GAP_rep");
215
}
216
217
#endif
218
219