GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/****************************************************************************1**2*A extend_representation.c ANUPQ source Eamonn O'Brien3**4*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany5*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia6**7*/89#include "pq_defs.h"10#include "pcp_vars.h"11#include "constants.h"12#include "pq_functions.h"1314/* compute a matrix which permits the extension of an existing15permutation representation for a group by a group of order16p^rank; the matrix rows are indexed from 0 .. p^rank - 1;17the matrix columns are indexed by the defining generators and18their inverses in the sequence 1, 1^-1, 2, 2^-1, etc.1920M[i][j] = k, where a = (a_1,.....a_rank) is the vector of21coefficients of the p-adic expansion of i, b is the vector of22coefficients of the p-adic expansion of k, and within the23p-group b = a * im(j) */2425void extend_representation(struct pcp_vars *pcp)26{27register int *y = y_address;2829int *expand; /* array to store p-adic expansion */30register int rank = y[pcp->clend + pcp->cc];31register int i, j, gen, sum;32int bound;33int **M;34int index;35int *powers; /* store powers of p to avoid recomputation */36register int p = pcp->p;37int cp = pcp->lused;38int ptr;3940bound = int_power(p, rank);4142/* set up room to store p-adic expansion and powers of p */43expand = allocate_vector(rank, 0, TRUE);44powers = allocate_vector(rank, 0, FALSE);4546for (i = 0; i < rank; ++i)47powers[i] = int_power(p, i);4849/* set up matrix to store results */50M = allocate_matrix(bound, 2 * pcp->ndgen, 0, FALSE);5152for (i = 0; i < bound; ++i) {5354/* find the p-adic expansion of i */55compute_padic(powers, i, rank - 1, p, expand);5657/* now process each defining generator and its inverse in turn */5859for (gen = -pcp->ndgen; gen <= pcp->ndgen; ++gen) {6061if (gen == 0)62continue;6364/* now copy p-adic expansion to y */65for (j = 0; j < rank; ++j)66y[cp + j + 1] = expand[j];6768#if defined(DEBUG)69printf("processing generator %d \n", gen);70printf("Stored p-adic expansion for %d in y is ", i);71for (j = 1; j <= pcp->lastg; ++j) {72printf("%d ", y[cp + j]);73}74printf("\n");75#endif7677/* look up image of gen which is stored as a generator-exponent78string in y; post-multiply the p-adic expansion by this image */7980ptr = y[pcp->dgen + gen];81if (ptr != 0)82collect(ptr, cp, pcp);8384#if defined(DEBUG)85printf("result of collection is ");86for (j = 1; j <= pcp->lastg; ++j) {87printf("%d ", y[cp + j]);88}89printf("\n");90#endif9192/* store the result of the multiplication */93sum = 0;94for (j = 1; j <= pcp->lastg; ++j)95sum += (y[cp + j] * powers[j - 1]);9697index = (gen < 0) ? 2 * (-gen) - 1 : 2 * gen - 2;98M[i][index] = sum;99}100101for (j = 0; j < rank; ++j)102expand[j] = 0;103}104105printf("The extension matrix is\n");106print_matrix(M, bound, 2 * pcp->ndgen);107108free_vector(expand, 0);109free_vector(powers, 0);110free_matrix(M, bound, 0);111}112113/* compute p-adic expansion of x, where x < p^(k + 1) */114115void compute_padic(int *powers, int x, int k, int p, int *expand)116{117register int alpha;118register int val;119120while (x > 0 && k >= 0) {121val = powers[k];122if (val <= x) {123/* find largest multiple of p^k < x */124alpha = p - 1;125while (alpha * val > x)126--alpha;127expand[k] = alpha;128x -= alpha * val;129}130--k;131}132}133134135