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 "gmp.h"4#include "name.h"5#include "bravais.h"6#include "datei.h"7#include "matrix.h"8#include "voronoi.h"9#include "autgrp.h"10#include "symm.h"11#include "base.h"12#include "zass.h"13#include "longtools.h"1415#define DATABASE_NAME TOPDIR "/tables/qcatalog/data"161718void extend(matrix_TYP *T)19{2021real_mat(T,T->rows,T->cols+1);22real_mat(T,T->rows+1,T->cols);2324T->array.SZ[T->rows-1][T->cols-1] = T->kgv;2526return;27}282930static matrix_TYP *get_cocycle(bravais_TYP *R,31bravais_TYP *P)32{333435matrix_TYP **RG,36*coz;3738int k,39j,40denominator,41**words;4243RG = (matrix_TYP **) malloc( R->gen_no * sizeof(matrix_TYP*));44words = (int **) malloc(P->gen_no * sizeof(int *));45denominator = 1;46for (j=0;j<R->gen_no;j++){47RG[j] = copy_mat(R->gen[j]);48RG[j]->cols--;49RG[j]->rows--;50Check_mat(RG[j]);51if (!RG[j]->flags.Integral){52fprintf(stderr,"The point group has to be integral\n");53exit(3);54}55rat2kgv(R->gen[j]);56denominator *= (R->gen[j]->kgv / GGT(R->gen[j]->kgv,denominator));57}5859/* stick the rigth INTEGRAL cozycle at the end of the RG[j] */60for (j=0;j<R->gen_no;j++){61RG[j]->cols++;62RG[j]->rows++;63for (k=0;k<RG[j]->rows-1;k++)64RG[j]->array.SZ[k][R->dim-1] = (denominator / R->gen[j]->kgv) *65R->gen[j]->array.SZ[k][R->dim-1];66RG[j]->array.SZ[R->dim-1][R->dim-1] = 1;67Check_mat(RG[j]);68}6970/* get the cozycle on the right generators */71coz = reget_gen(RG,R->gen_no,P,words,TRUE);7273/* the cozykle has to become the right denominator */74coz->kgv = denominator;75Check_mat(coz);7677for (j=0;j<R->gen_no;j++){78free_mat(RG[j]);79}80for (j=0;j<P->gen_no;j++){81free(words[j]);82}83free(words);84free(RG);8586return coz;8788}899091bravais_TYP *space_group_from_matrix(bravais_TYP *G,92matrix_TYP *x,93matrix_TYP *cocycle,94matrix_TYP *D)95{9697bravais_TYP *R;9899matrix_TYP *C;100101int i,102j,103k;104105R = init_bravais(G->dim+1);106C = convert_to_cozycle(x,cocycle,D);107108R->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));109R->gen_no = G->gen_no;110for (i=0;i<G->gen_no;i++){111R->gen[i] = copy_mat(G->gen[i]);112real_mat(R->gen[i],G->dim+1,G->dim+1);113R->gen[i]->array.SZ[G->dim][G->dim] = 1;114iscal_mul(R->gen[i],C->kgv);115R->gen[i]->kgv = C->kgv;116}117118/* stick the cocycle in the last column of the matrices generating R */119k = 0;120for (i=0;i<R->gen_no;i++){121for (j=0;j<G->dim;j++){122R->gen[i]->array.SZ[j][G->dim] = C->array.SZ[k][0];123k++;124}125Check_mat(R->gen[i]);126}127128free_mat(C);129130return R;131132}133134matrix_TYP *aff_class_inf(bravais_TYP *R,135bravais_TYP *DATAZ,136matrix_TYP *PRES,137MP_INT *aff_name,138bravais_TYP **RC)139{140141matrix_TYP *cozycle,142**X,143**Y,144*coz_mat,145**matinv,146*RES;147148word *relator;149150int i;151152long dim;153154/* first thing to do is to find the generators of DATAZ in the155point group of R */156cozycle = get_cocycle(R,DATAZ);157158/* do the cohomology calculations */159relator = (word *) calloc(PRES->rows,sizeof(word));160for (i=0;i<PRES->rows;i++){161matrix_2_word(PRES,relator+i,i);162}163164165matinv = (matrix_TYP **) calloc(DATAZ->gen_no , sizeof(matrix_TYP *));166X = cohomology(&dim,DATAZ->gen,matinv,relator,DATAZ->gen_no,PRES->rows);167168if (X[0]->cols > 0){169/* give the group a name */170Y = identify(X[0],X[1],X[2],DATAZ,&cozycle,aff_name,1,3,NULL,NULL);171RES=Y[0]; free(Y);172173if (RC){174/* construct our representative */175coz_mat = reverse_valuation(aff_name,X[1]);176*RC = space_group_from_matrix(DATAZ,coz_mat,X[0],X[1]);177free_mat(coz_mat);178}179180}181else{182mpz_set_si(aff_name,0);183RES = init_mat(DATAZ->dim+1,DATAZ->dim+1,"1");184coboundary(DATAZ,cozycle,RES);185186if (RC){187/* construct the split extension */188RC[0] = init_bravais(DATAZ->dim + 1);189RC[0]->gen = (matrix_TYP **) malloc(DATAZ->gen_no*sizeof(matrix_TYP*));190RC[0]->gen_no = DATAZ->gen_no;191for (i=0;i<DATAZ->gen_no;i++){192RC[0]->gen[i] = copy_mat(DATAZ->gen[i]);193extend(RC[0]->gen[i]);194}195free_mat(coz_mat);196}197}198199/* clean up and return */200for (i=0;i<3;i++) free_mat(X[i]); free(X);201free_mat(cozycle);202for (i=0;i<PRES->rows;i++) wordfree(relator+i);203free(relator);204for (i=0;i<DATAZ->gen_no;i++)205if (matinv[i] != NULL) free_mat(matinv[i]);206free(matinv);207208return RES;209}210211212213214