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 exponent_auts.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"1213/* save description of automorphisms used in exponent checking to file */1415void save_auts(FILE *ofp, int *head, int *list, struct pcp_vars *pcp)16{17register int alpha;18register int offset;19register int required_offset;20register int prev = 0;2122register int m = pcp->m;23register int required_ptr, stored_ptr;24int required_length, stored_length;25register int original, diff;26register int j;27int list_length;28int retain;2930int nmr_items;31int *copy_head;3233/* the action on more than lastg generators may be stored in34list; if this is the case, establish how many entries from35the array list must be stored in order to retain the36description of the automorphisms on lastg generators */3738original = head[0];3940if (head[0] > pcp->lastg) {41copy_head = allocate_vector(pcp->lastg * m + 1, 0, FALSE);42list_length = 0;43retain = pcp->lastg;44diff = 0;45for (alpha = 1; alpha <= m; ++alpha) {46offset = (alpha - 1) * original;47required_offset = (alpha - 1) * retain;48for (j = 1; j <= retain; ++j)49copy_head[required_offset + j] = head[offset + j] - diff;5051required_ptr = head[offset + retain];52stored_ptr = head[offset + original];53stored_length = stored_ptr + list[stored_ptr + 1] + 1 - prev;54required_length = required_ptr + list[required_ptr + 1] + 1 - prev;5556diff += stored_length - required_length;5758list_length += required_length;59prev += stored_length;60}61} else {62copy_head = head;63retain = head[0];64list_length = list[0];65}6667prev = 0;6869nmr_items = fwrite(&retain, sizeof(int), 1, ofp);70verify_read(nmr_items, 1);71nmr_items = fwrite(&list_length, sizeof(int), 1, ofp);72verify_read(nmr_items, 1);7374for (alpha = 1; alpha <= m; ++alpha) {75offset = (alpha - 1) * original;76required_offset = (alpha - 1) * retain;77nmr_items =78fwrite(copy_head + required_offset + 1, sizeof(int), retain, ofp);79verify_read(nmr_items, retain);80required_ptr = head[offset + retain];81stored_ptr = head[offset + original];82stored_length = stored_ptr + list[stored_ptr + 1] + 1 - prev;83required_length = required_ptr + list[required_ptr + 1] + 1 - prev;84nmr_items = fwrite(&required_length, sizeof(int), 1, ofp);85verify_read(nmr_items, 1);86nmr_items = fwrite(list + prev + 1, sizeof(int), required_length, ofp);87verify_read(nmr_items, required_length);88prev += stored_length;89}9091if (original != retain)92free_vector(copy_head, 0);9394RESET(ofp);95}9697/* restore automorphisms used in exponent checking from file ifp;98nmr_saved = nmr of generators whose images have been saved to file;99retain = nmr of generators whose images are to be retained;100new_index = index of last used position in array list */101102int restore_auts(FILE *ifp,103int offset,104int nmr_saved,105int retain,106int *new_index,107int *head,108int *list)109{110int alpha_length; /* length of the automorphism description */111int i, add;112int nmr_items;113114nmr_items = fread(head + offset + 1, sizeof(int), nmr_saved, ifp);115verify_read(nmr_items, nmr_saved);116117add = *new_index - head[offset + 1];118for (i = 1; i <= nmr_saved; ++i)119head[offset + i] += add;120121nmr_items = fread(&alpha_length, sizeof(int), 1, ifp);122verify_read(nmr_items, 1);123nmr_items = fread(list + *new_index + 1, sizeof(int), alpha_length, ifp);124verify_read(nmr_items, alpha_length);125126*new_index = head[offset + retain] + list[head[offset + retain] + 1] + 1;127128return alpha_length;129}130131/* restore automorphisms used in exponent checking from file */132133void134restore_automorphisms(FILE *ifp, int **head, int **list, struct pcp_vars *pcp)135{136int new_index = 0;137int offset;138register int alpha;139int nmr_saved;140int list_length;141int retain;142int nmr_items;143144nmr_items = fread(&nmr_saved, sizeof(int), 1, ifp);145verify_read(nmr_items, 1);146nmr_items = fread(&list_length, sizeof(int), 1, ifp);147verify_read(nmr_items, 1);148149*head = allocate_vector(nmr_saved * pcp->m + 1, 0, FALSE);150(*head)[0] = nmr_saved;151152*list = allocate_vector(list_length + 1, 0, FALSE);153(*list)[0] = list_length;154155retain = MIN(pcp->lastg, nmr_saved);156for (alpha = 1; alpha <= pcp->m; ++alpha) {157offset = (alpha - 1) * retain;158restore_auts(ifp, offset, nmr_saved, retain, &new_index, *head, *list);159}160(*head)[0] = retain;161162printf("Automorphisms read from file\n");163}164165166