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 compact_description.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 "pq_functions.h"12#include "constants.h"1314/******************************************************************************15** AUTHOR: C. Rhodes16** DATE: 21/1/9317** REVISION: 1.0 (Release)18** STATUS: This code is designed to be an extension to the pq program19** by E.A. O'Brien. It encodes the pc-presentation into a20** sequence of integers and then appends that sequence to a21** file called gps<order>, where <order> is the order of the22** group. Note that existing files of this name are updated.23****************************************************************************/2425#ifdef HAVE_GMP2627MP_INT Encode(int p, int length, int *list)28{29MP_INT powers, code;30int i;3132mpz_init_set_ui(&code, 0);3334for (i = 1; i <= length; ++i) {35mpz_init_set_si(&powers, 0);36if (list[i] != 0)37mpz_ui_pow_ui(&powers, p, i - 1);38mpz_add(&code, &code, &powers);39}40/*41if (list[i] != 0) {42MP_INT factor;43mpz_init_set_si (&factor, list[i]);44mpz_ui_pow_ui (&powers, p, i);45mpz_mul (&powers, &powers, &factor);46mpz_add (&code, &code, &powers);47}48}49*/50return code;51}52#endif5354/* construct a compact description of the group as a sequence;55if write_to_file TRUE, then write the compact description,56sequence, to file and also return it */5758int *compact_description(Logical write_to_file, struct pcp_vars *pcp)59{60register int *y = y_address;6162register int p1;63register int p2;64int *sequence;65int nmr_of_exponents;66int weight_g, weight_h;67int g, h;68int generator;69int offset;70int index; /* used to count current position in sequence of exponents */71int n;72#include "access.h"7374n = pcp->lastg;75nmr_of_exponents = choose(n + 1, 3);76sequence = allocate_vector(nmr_of_exponents, 1, TRUE);7778offset = 0;79index = 0;8081if (pcp->cc == 1) {82/* write the sequence to a file */83output_information(sequence, nmr_of_exponents, pcp);84return sequence;85}8687for (generator = 2; generator <= n; ++generator) {8889/* examine all power relations g^p where g < generator and store90all exponents of generator which occur in these relations */9192for (g = 1; g < generator; ++g) {93p1 = y[pcp->ppower + g];9495trace_relation(sequence, &index, p1, generator, pcp);9697/* examine all commutator relations [h, g] where g < h < generator98and store exponents of generator which occur in such relations */99100weight_g = WT(y[pcp->structure + g]);101102/* is the relation [h, g] stored? */103for (h = g + 1; h < generator; ++h) {104weight_h = WT(y[pcp->structure + h]);105if (weight_g + weight_h <= pcp->cc) {106p1 = y[pcp->ppcomm + h];107p2 = y[p1 + g];108trace_relation(sequence, &index, p2, generator, pcp);109} else110++index;111}112}113114offset += (generator - 1) * (generator - 2) / 2 + (generator - 1);115index = offset;116}117118#if defined(DEBUG)119print_array(sequence, 1, nmr_of_exponents);120#endif121122/* write the sequence to a file */123if (write_to_file)124output_information(sequence, nmr_of_exponents, pcp);125126return sequence;127}128129/* find all occurences of generator in relation with address ptr */130131void trace_relation(132int *sequence, int *index, int ptr, int generator, struct pcp_vars *pcp)133{134register int *y = y_address;135136int i, gen, exp, count;137#include "access.h"138139++(*index);140if (ptr == generator)141sequence[*index] = 1;142else if (ptr < 0) {143ptr = -ptr + 1;144count = y[ptr];145for (i = 1; i <= count; i++) {146gen = FIELD2(y[ptr + i]);147if (gen == generator) {148exp = FIELD1(y[ptr + i]);149sequence[*index] = exp;150}151}152}153}154155/* append the sequence of length nmr_of_exponents to file with name156formed by concatenating "gps" and "p^n" */157158void159output_information(int *sequence, int nmr_of_exponents, struct pcp_vars *pcp)160{161register int *y = y_address;162163FILE *output_file;164char *file_name;165#ifdef HAVE_GMP166MP_INT code;167#else168register int count;169#endif170171file_name = allocate_char_vector(MAXWORD + 1, 0, FALSE);172173sprintf(file_name, "gps%d^%d", pcp->p, pcp->lastg);174175/* open the file in update mode */176output_file = OpenFile(file_name, "a+");177178/* write rank of Frattini quotient, number of pcp generators, prime,179and exponent-p class to file */180181#ifdef HAVE_GMP182fprintf(183output_file, "[%d, %d, %d, ", y[pcp->clend + 1], pcp->lastg, pcp->cc);184code = Encode(pcp->p, nmr_of_exponents, sequence);185mpz_out_str(output_file, 10, &code);186fprintf(output_file, "],\n");187#else188fprintf(output_file,189"%d %d %d %d ",190y[pcp->clend + 1],191pcp->lastg,192pcp->p,193pcp->cc);194/* now write out the sequence of exponents */195for (count = 1; count <= nmr_of_exponents - 1; count++)196fprintf(output_file, "%d,", sequence[count]);197fprintf(output_file, "%d\n", sequence[nmr_of_exponents]);198#endif199200CloseFile(output_file);201202free(file_name);203}204205206