Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
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
Project: cocalc-sagemath-dev-slelievre
Views: 418346/****************************************************************************1**2*A GAP_link_via_file.c ANUPQ source Eamonn O'Brien3*A & Frank Celler4*A & Benedikt Rothe5**6*Y Copyright 1995-1997, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany7*Y Copyright 1995-1997, School of Mathematical Sciences, ANU, Australia8**9*/1011#include "pq_defs.h"12#include "pcp_vars.h"13#include "pga_vars.h"14#include "constants.h"15#include "global.h"16#include "pq_functions.h"17#include "menus.h"1819#if defined(GAP_LINK_VIA_FILE)2021/****************************************************************************22**23*F start_GAP_file24** write out initial information required for stabiliser calculation25**26*/27void start_GAP_file(FILE **GAP_input,28int ***auts,29struct pga_vars *pga,30struct pcp_vars *pcp)31{32register int i;33int nmr_soluble = pga->nmr_soluble;3435/* open "GAP_input" file */36*GAP_input = OpenSystemFile("GAP_input", "w+");3738if (!GAP4iostream) { /* this is necessary for GAP 4.2 compatibility */39fprintf(*GAP_input, "if not IsBound( PcGroupFpGroupNC ) then\n");40fprintf(*GAP_input, " PcGroupFpGroupNC := PcGroupFpGroup;\n");41fprintf(*GAP_input, "fi;\n");42}4344GAP_presentation(*GAP_input, pcp, 1);45#ifdef HAVE_GMP46/* report the group and automorphism group order */47fprintf(*GAP_input, "ANUPQsize := ");48mpz_out_str(*GAP_input, 10, &(pga->aut_order));49fprintf(*GAP_input, ";\n");50fprintf(*GAP_input, "ANUPQagsize := ");51fprintf(*GAP_input, "%d;;\n", pga->nmr_soluble);52#else53fprintf(*GAP_input, "ANUPQsize := fail;;\nANUPQagsize := fail;;\n");54#endif5556/* write global variables */57fprintf(*GAP_input, "ANUPQglb := rec();;\n");58fprintf(*GAP_input, "ANUPQglb.d := %d;;\n", pcp->ccbeg - 1);59fprintf(*GAP_input, "ANUPQglb.F := GF(%d);;\n", pga->p);60fprintf(*GAP_input, "ANUPQglb.one := One (ANUPQglb.F);;\n");61fprintf(*GAP_input, "ANUPQglb.q := %d;;\n", pga->q);62fprintf(*GAP_input, "ANUPQglb.s := %d;;\n", pga->s);63fprintf(*GAP_input, "ANUPQglb.r := %d;;\n", pga->r);64fprintf(*GAP_input, "ANUPQglb.agAutos := [];;\n");65fprintf(*GAP_input, "ANUPQglb.glAutos := [];;\n");66fprintf(*GAP_input, "ANUPQglb.genQ := [];;\n");6768/* write the generators <gendp> to file */69for (i = 1; i <= nmr_soluble; ++i)70write_GAP_matrix(71*GAP_input, "ANUPQglb.agAutos", auts[i], pcp->ccbeg - 1, 1, i);727374#ifdef DEBUG175printf("The relative orders are ");76for (i = 1; i <= nmr_soluble; ++i)77printf("%d, ", pga->relative[i]);78printf("\n");79#endif8081fprintf(*GAP_input, "relativeOrders := [");82if (nmr_soluble > 0) {83for (i = 1; i < nmr_soluble; ++i)84fprintf(*GAP_input, "%d, ", pga->relative[i]);85fprintf(*GAP_input, "%d", pga->relative[nmr_soluble]);86}87fprintf(*GAP_input, "];\n");8889for (i = nmr_soluble + 1; i <= pga->m; ++i)90write_GAP_matrix(*GAP_input,91"ANUPQglb.glAutos",92auts[i],93pcp->ccbeg - 1,941,95i - nmr_soluble);96}979899/****************************************************************************100**101*F write_GAP_matrix102** write out a matrix in a GAP input form103**104*/105void write_GAP_matrix(106FILE *GAP_input, char *gen, int **A, int size, int start, int nr)107{108int i, j;109110fprintf(GAP_input, "%s[%d] := [\n", gen, nr);111for (i = start; i < start + size; ++i) {112fprintf(GAP_input, "[");113for (j = start; j < start + size - 1; ++j)114fprintf(GAP_input, "%d, ", A[i][j]);115if (i != start + size - 1)116fprintf(GAP_input, "%d],\n", A[i][j]);117else118fprintf(GAP_input, "%d]] * ANUPQglb.one;;\n", A[i][j]);119}120}121122123/****************************************************************************124**125*F insoluble_stab_gens126** calculate the stabiliser of the supplied representative using GAP127**128*/129void insoluble_stab_gens(int rep,130int orbit_length,131struct pga_vars *pga,132struct pcp_vars *pcp)133{134FILE *GAP_rep;135char *path, *command;136char c;137int index;138int *subset;139int **S;140141/* append the commands to compute the stabilizer */142GAP_rep = OpenFile("GAP_rep", "w+");143144S = label_to_subgroup(&index, &subset, rep, pga);145GAP_factorise_subgroup(GAP_rep, S, index, subset, pga, pcp);146free_matrix(S, pga->s, 0);147free_vector(subset, 0);148if (!GAP4iostream) {149fprintf(GAP_rep, "LoadPackage(\"autpgrp\", \"1.5\");\n");150fprintf(GAP_rep, "if TestPackageAvailability(");151fprintf(GAP_rep, "\"anupq\", \"3.1\") <> true then\n");152fprintf(GAP_rep, " ANUPQData := rec(tmpdir := DirectoryCurrent());\n");153fprintf(GAP_rep, " DeclareInfoClass(\"InfoANUPQ\");\n");154fprintf(GAP_rep, " DeclareGlobalFunction(");155fprintf(GAP_rep, "\"PqStabiliserOfAllowableSubgroup\");\n");156fprintf(GAP_rep, " ReadPackage(\"anupq\", \"lib/anustab.gi\");\n");157fprintf(GAP_rep, "fi;\n");158fprintf(GAP_rep, "SetInfoLevel(InfoANUPQ, 2);\n");159}160fprintf(GAP_rep, "PqStabiliserOfAllowableSubgroup( ANUPQglb, F,\n");161fprintf(GAP_rep, " gens, relativeOrders, ANUPQsize, ANUPQagsize );\n");162163CloseFile(GAP_rep);164165if (GAP4iostream) {166printf("GAP, please compute stabiliser!\n");167168/* skip a comment */169while ((c = getchar()) == ' ')170;171if (c == '#') {172while ((c = getchar()) != '\n')173;174}175176/* we expect a line: "pq, stabiliser is ready.\n" */177if (c == 'p')178putchar(c);179while ((c = getchar()) != '\n')180putchar(c);181putchar(c);182} else {183/* try to find gap */184if ((path = (char *)getenv("ANUPQ_GAP_EXEC")) == NULL)185#if defined(ANUPQ_GAP_EXEC)186path = ANUPQ_GAP_EXEC;187#else188path = "gap";189#endif190command = (char *)malloc(strlen(path) + 200);191strcpy(command, path);192strcat(command, " -r -q -A GAP_input < GAP_rep");193194/* inform the user that we are about to call GAP */195if (isatty(0))196printf("Now calling GAP to compute stabiliser...\n");197unlink("LINK_output");198199/* compute the stabiliser of the orbit representative */200#ifdef HAVE_WORKING_VFORK201if (vsystem(command) != 0)202#else203if (system(command) != 0)204#endif205{206printf("Error in system call to GAP\n");207exit(FAILURE);208}209}210211CloseFile(OpenFile("LINK_output", "r"));212213unlink("GAP_rep");214}215216#endif217218219