GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "ZZ.h"1#include "typedef.h"2#include "getput.h"3#include "name.h"4#include "bravais.h"5#include "datei.h"6#include "matrix.h"7#include "voronoi.h"8#include "autgrp.h"9#include "symm.h"10#include "base.h"11#include "zass.h"12#include "gmp.h"13#include "longtools.h"1415#define DATABASE_NAME TOPDIR "/tables/qcatalog/data"16171819bravais_TYP *get_qclass_by_name(char *name,20matrix_TYP **PRES,21int dim)22{2324int found = FALSE,25i;2627database *database;2829char filename[1024];3031bravais_TYP *G;3233while (!found){34database = load_database (DATABASE_NAME,dim);3536i = 0;37while (!found && i<database->nr ){38found = (strcmp(database->entry[i].abbreviation,name) == 0);39i++;40}4142if (found){43i--;4445sprintf(filename,"%s/tables/qcatalog/dim%d/dir.%s/ordnung.%d/%s/%s",46TOPDIR,dim,database->entry[i].symbol,47database->entry[i].order,48database->entry[i].discriminant,name);49G = get_bravais(filename);5051sprintf(filename,"%s/tables/qcatalog/dim%d/dir.%s/ordnung.%d/%s/pres.%s",52TOPDIR,dim,database->entry[i].symbol,53database->entry[i].order,54database->entry[i].discriminant,name);55*PRES = get_mat(filename);56}57else if (dim == 6){58fprintf(stderr,"group with this name not in the catalog of Q-classes\n");59fprintf(stderr,"name was %s\n",name);60exit(4);61}6263free_database (database);64dim++;65}6667return G;6869}7071bravais_TYP *get_zclass_by_name(bravais_TYP *G,72int *first,73int *second,74int ignore)75{7677bravais_TYP **QCLASS,78*H,79*RES,80**TMP;8182int number,83i;848586/* calculate the space of invariant forms of G, we'll need it */87if (G->form_no == 0)88G->form = formspace(G->gen,G->gen_no,1,&G->form_no);8990QCLASS = q2z(G,&number,TRUE,NULL,TRUE);919293if (number < *first){94if (ignore){95*first = number;96}97else{98fprintf(stderr,"there is no zclass with this number this Q-class\n");99exit(4);100}101}102103for (i=0;i<number;i++){104if (i+1 != *first){105free_bravais(QCLASS[i]);106QCLASS[i] = NULL;107}108}109110H = QCLASS[*first - 1];111free(QCLASS);112113if (H->zentr_no < *second){114if (ignore){115*second = H->zentr_no;116}117else{118fprintf(stderr,"there is no zclass with this number this Q-class\n");119exit(4);120}121}122123for (i=0;i<H->zentr_no;i++){124if (i+1 != *second){125free_mat(H->zentr[i]);126H->zentr[i] = NULL;127}128}129130TMP = get_groups(&H,1,&i);131RES = TMP[*second - 1];132133free_bravais(H);134free(TMP);135136if (RES == NULL){137fprintf(stderr,"error in get_zclass_by_name\n");138exit(4);139}140141return RES;142143}144145146bravais_TYP *split_extension(bravais_TYP *G)147{148149int i;150151bravais_TYP *R;152153R = init_bravais(G->dim+1);154R->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));155for (i=0;i<G->gen_no;i++){156R->gen[i] = copy_mat(G->gen[i]);157extend(R->gen[i]);158}159R->gen_no = G->gen_no;160161return R;162163}164165bravais_TYP *get_affine_class_by_name(bravais_TYP *G,166matrix_TYP *PRES,167MP_INT *aff_name,168int check)169{170171bravais_TYP *R;172173matrix_TYP **COH,174*coz_mat,175**matinv,176**Y;177178word *relator;179180MP_INT standart_name,181coho_size;182183int i,184j,185den;186187long dim;188189190if (mpz_cmp_si(aff_name,0) == 0){191/* handle the split extension case seperately */192return split_extension(G);193}194195/* do the cohomology calculations */196relator = (word *) calloc(PRES->rows,sizeof(word));197for (i=0;i<PRES->rows;i++){198matrix_2_word(PRES,relator+i,i);199}200201202matinv = (matrix_TYP **) calloc(G->gen_no , sizeof(matrix_TYP *));203COH = cohomology(&dim,G->gen,matinv,relator,G->gen_no,PRES->rows);204205if (dim > 0){206fprintf(stderr,"error in get_affine_class_by_name\n");207exit(4);208}209210if (COH[0]->cols > 0){211212mpz_init(&coho_size);213mpz_set_si(&coho_size,1);214for (i=0;i<COH[1]->rows;i++)215if (COH[1]->array.SZ[i][i]){216mpz_mul_ui(&coho_size,&coho_size,217(unsigned long)COH[1]->array.SZ[i][i]);218}219220mpz_init(&standart_name);221mpz_mod(&standart_name,aff_name,&coho_size);222223coz_mat = reverse_valuation(&standart_name,COH[1]);224225R = space_group_from_matrix(G,coz_mat,COH[0],COH[1]);226227if (check == 1 || check == 3){228/* test whether the name we have got so far is the229name CARAT would give */230den = 1;231for (i=0;i<G->gen_no;i++)232den = KGV(R->gen[i]->kgv,den);233free_mat(coz_mat);234coz_mat = init_mat(G->dim*G->gen_no,1,"i");235for (i=0;i<G->gen_no;i++)236for (j=0;j<G->dim;j++)237coz_mat->array.SZ[j + G->dim * i][0] = den / R->gen[i]->kgv *238R->gen[i]->array.SZ[j][G->dim];239coz_mat->kgv = den;240241Y = identify(COH[0],COH[1],COH[2],G,&coz_mat,&standart_name,1,242TRUE,NULL,NULL);243244/* now standart_name will contain the name CARAT would assign245to this group. check ist now */246if (mpz_cmp(&standart_name,aff_name) != 0){247if (check == 3){248mpz_set(aff_name,&standart_name);249}250else{251fprintf(stderr,"the given name is not CARAT`s name\n");252exit(4);253}254}255256free_mat(Y[0]); free(Y);257}258259free_mat(coz_mat);260mpz_clear(&standart_name);261mpz_clear(&coho_size);262}263else{264/* things are easy here, there is only the split extension */265R = split_extension(G);266267if (check == 1 && mpz_cmp_si(aff_name,0) != 0){268fprintf(stderr,"wrong name for the space group\n");269exit(4);270}271else{272mpz_set_si(aff_name,0);273}274275}276277for (i=0;i<G->gen_no;i++){278if (matinv[i] != NULL)279free_mat(matinv[i]);280}281free(matinv);282for (i=0;i<3;i++) free_mat(COH[i]); free(COH);283for (i=0;i<PRES->rows;i++) wordfree(relator+i);284free(relator);285286287return R;288}289290291bravais_TYP *reverse_name(char qname[1024],292int zname[2],293MP_INT aff_name,294int i,295boolean iflag,296char **affstring)297{298bravais_TYP *R,299*DATAQ,300*DATAZ;301302matrix_TYP *PRES;303304305306DATAQ = get_qclass_by_name(qname, &PRES, 1);307DATAZ = get_zclass_by_name(DATAQ, zname, zname+1, iflag);308R = get_affine_class_by_name(DATAZ, PRES, &aff_name, i);309310affstring[0] = (char * ) malloc( mpz_sizeinbase( &aff_name , 10) + 2 );311mpz_get_str (affstring[0] , 10, &aff_name);312313314free_mat(PRES);315free_bravais(DATAZ);316free_bravais(DATAQ);317318cleanup_prime();319mpz_clear(&aff_name);320321return(R);322}323324325326327328