GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include <typedef.h>1#include <getput.h>2#include <matrix.h>3#include <datei.h>4#include <gmp.h>5#include <zass.h>6#include <longtools.h>7#include <presentation.h>8#include <base.h>9#include <graph.h>1011#define DEBUG FALSE1213int INFO_LEVEL;14extern int SFLAG;151617static int is_trivial(bravais_TYP *G){1819int i;2021for (i=0;i<G->gen_no;Check_mat(G->gen[i]),i++);22for (i=0;i<G->gen_no &&23G->gen[i]->flags.Scalar &&24G->gen[i]->array.SZ[i][i] == 1;i++);2526return i == G->gen_no;2728}2930int main(int argc,char **argv){3132matrix_TYP **X,33*N,34**Y,35**TR,36**base,37*relator_input,38**matinv;3940word *relator;4142bravais_TYP *G, *R;4344int i,45anz,46*len;4748long dim;4950bahn **strong;515253MP_INT number,54*names;5556char comment[1000],57file[1000],58*NAME,59*FN;6061read_header(argc,argv);6263if ((is_option('h') && optionnumber('h')==0) || (FILEANZ < 1)64|| (is_option('i') && FILEANZ<2)){65printf("Usage: %s ['file1'] 'file2' ['file3'] [-n] [-i] [-t=n] [-v] [-C] [-H] [-F] [-S]\n",argv[0]);66printf("\n");67printf("file1: matrix_TYP containing a presentation of the group (cf. Presentation,\n");68printf(" Roundcor)\n");69printf("file2: bravais_TYP containing the group (and its normalizer).\n");70printf("file3: (OPTIONAL) containing cocycles for identification.\n");71printf("\n");72printf("Calculates representatives of the isomorphism classes of extension of\n");73printf("the group in file2 with presentation in file1 with the natural lattice.\n");74printf("Output lists representative vectorsystems. (Output can be used as input\n");75printf("for Extract). Also the isomorphism type of the extension group is given.\n");76printf("\n");77printf("Options:\n");78printf("\n");79printf(" -n: only calculates the number of extensions, without computing\n");80printf(" representatives. This option is much faster for big cohomology\n");81printf(" groups. WARNING: Try this option first for 2-groups in dimension\n");82printf(" greater than 4.\n");83printf(" -v: verbose mode. Give some echoing to stderr to\n");84printf(" indicate a little what the program is doing.\n");85printf(" -i: Identify the cozycles given in file3, ie. give\n");86printf(" the described space groups a name. CAUTION: The\n");87printf(" name will depend on the generating set of the group\n");88printf(" in file2 and the presentation in file1.\n");89printf(" Can be used to test isomorphism of space groups with equal\n");90printf(" point groups. The name is 0 iff the extension splits.\n");91printf(" -t=n: Has an effect only if given with -i. Outputs the\n");92printf(" isomophism needed to transform the space group\n");93printf(" By default, only the linear part is calculated. To\n");94printf(" get a full transformation matrix, use -t=2.\n");95printf(" -C: Ignore the operation of the normalizer, just work\n");96printf(" on the level of extensions.\n");97printf(" -H: echo the isomorphism type of the cohomology group\n");98printf(" H^1(G,Q^n/Z^n) to stderr.\n");99printf(" -F: Only construct those extensions which gie rise to\n");100printf(" torsion free space groups. Does not work in conjunction\n");101printf(" with -n.\n");102printf(" -S: write corresponding space groups in files\n");103printf("\n");104printf(" CAUTION: THE PROGRAM RELIES HEAVILY ON THE FOLLOWING TWO FACTS:\n");105printf(" - THE PRESENTATION GIVEN IN file1 IS INDEED A\n");106printf(" PRESENTATION. CHECKED IS ONLY THAT THE GIVEN\n");107printf(" GENERATORS FULFILL THE RELATIONS.\n");108printf(" - THE NORMALIZER IN GL_n(Z) FOR THE GROUP IN file2\n");109printf(" IS CORRECT. THE PROGRAM MIGHT NOT FINISH OR\n");110printf(" GIVE WRONG ANSWERS OTHERWISE.\n");111printf("\n");112printf("Cf. also Zass_main, Extract, Same_generators, Presentation.\n");113printf("Synonyms: Vectorsystems,Extensions\n");114if (is_option('h')){115exit(0);116}117else{118exit(31);119}120}121122INFO_LEVEL = optionnumber('h');123124if (INFO_LEVEL & 12){125SFLAG = 1;126}127128129if ((FILEANZ > 2)130|| (FILEANZ == 2 && ! is_option('i'))){131/* reading the group */132G = get_bravais(FILENAMES[1]);133134/* reading the presentation */135X = mget_mat(FILENAMES[0],&i);136if (i>1){137fprintf(stderr,"you should only give a single matrix as presentation\n");138exit(3);139}140141FN = FILENAMES[1];142}143else{144/* reading the group */145G = get_bravais(FILENAMES[0]);146147/* calculate a presentation */148base = get_base(G);149150strong = strong_generators(base,G,TRUE);151152if (DEBUG){153check_base(strong,G);154}155156X = (matrix_TYP **) malloc(sizeof(matrix_TYP *));157X[0] = pres(strong,G,NULL);158159for (i=0;i<G->dim;i++){160free_mat(base[i]);161free_bahn(strong[i]);162free(strong[i]);163}164free(strong);165free(base);166FN = FILENAMES[0];167}168169170relator_input = X[0];171free(X);172173/* if C is an option, completely forget the normalizer and centralizer */174if (is_option('C')){175for (i=0;i<G->normal_no;i++) free_mat(G->normal[i]);176if (G->normal_no > 0){177G->normal_no = 0;178free(G->normal);179}180for (i=0;i<G->cen_no;i++) free_mat(G->cen[i]);181if (G->cen_no > 0){182G->cen_no = 0;183free(G->cen);184}185}186187/* we have to have at least the identity to generate the normalizer */188if (G->normal_no == 0){189G->normal_no = 1;190G->normal = (matrix_TYP **) malloc(1 * sizeof(matrix_TYP *));191G->normal[0] = init_mat(G->dim,G->dim,"1");192}193194/* bereitstellen eines pointers fuer die inversen von mat */195matinv = (matrix_TYP **) calloc(G->gen_no,sizeof(matrix_TYP *));196197/* speicher fuer die worte */198relator = (word *) calloc(relator_input->rows,sizeof(word));199200/* konvertieren der inputmatrix in relator-format */201for (i=0;i<relator_input->rows;i++){202matrix_2_word(relator_input,relator+i,i);203}204205X = cohomology(&dim,G->gen,matinv,relator,G->gen_no,relator_input->rows);206207/* there is a special case to handle, which is the case that there208isn't a cohomology group at all */209if (X[0]->cols <1){210if (is_option('H')){211fprintf(stderr,"H^1(G,Q^n/Z^n) is trivial\n");212}213if (is_option('n')){214printf("number of extensions of group in %s with natural lattice %d\n",215FN,1);216}217else if(is_option('i')){218printf("There is only one extension of this group with the natural\n");219printf("lattice, and this splits.\n");220}221else if(is_option('F')){222if (is_trivial(G)){223X[0] = init_mat(G->gen_no * G->dim,1,"");224printf("#%d\n",1);225sprintf(comment,"%% the %d-th cozycle to the group of %s",2261,FN);227if (is_option('S')){228sprintf(file, "%s.%s", FN, "0");229R = extract_r(G, X[0]);230put_bravais(R, file, comment);231free_bravais(R);232}233else{234put_cocycle(X[0],G->dim,G->gen_no,NULL,comment);235}236free_mat(X[0]);237}238else{239/* only one extension, this splits and is not torsion free240for this reason */241printf("#0\n");242}243}244else{245X[0] = init_mat(G->gen_no * G->dim,1,"");246printf("#%d\n",1);247sprintf(comment,"%% the %d-th cozycle to the group of %s",2481,FN);249if (is_option('S')){250sprintf(file, "%s.%s", FN, "0");251R = extract_r(G, X[0]);252put_bravais(R, file, comment);253free_bravais(R);254}255else{256put_cocycle(X[0],G->dim,G->gen_no,NULL,comment);257}258}259exit(0);260}261262if (is_option('H')){263fprintf(stderr,"Isomorphism type of H^1(G,Q^n/Z^n): \n");264i=0;265while(X[1]->array.SZ[i][i] == 1) i++;266fprintf(stderr,"C_%d",X[1]->array.SZ[i][i]);267for (i=i+1;i<X[1]->cols;i++){268if (X[1]->array.SZ[i][i] != 0 &&269X[1]->array.SZ[i][i] != 1){270fprintf(stderr," X ");271fprintf(stderr,"C_%d",X[1]->array.SZ[i][i]);272}273}274fprintf(stderr,"\n");275}276277if (is_option('n')){278mpz_init(&number);279mpz_set_si(&number,0);280no_of_extensions(X[0],X[1],X[2],G,&number);281printf("number of extensions of group in %s with natural lattice ",282FN);283mpz_out_str(stdout,10,&number);284printf("\n");285mpz_clear(&number);286}287else if(is_option('i')){288289if (FILEANZ > 2){290Y = mget_mat(FILENAMES[2],&anz);291}292else{293Y = mget_mat(FILENAMES[1],&anz);294}295296convert_cocycle_to_column(Y,anz,G->dim,G->gen_no);297names = (MP_INT *) malloc(anz*sizeof(MP_INT));298for (i=0;i<anz;i++) mpz_init_set_si(names+i,0);299i = is_option('t');300if (i && optionnumber('t') == 2) i = 3;301TR = identify(X[0],X[1],X[2],G,Y,names,anz,i,NULL,NULL);302for (i=0;i<anz;i++){303printf("Name for the %d-th extension in %s: ",i+1,FN);304mpz_out_str(stdout,10,names+i);305printf("\n");306if (TR!=NULL){307sprintf(comment,"transformation matrix to extension %d of %s",308i+1,FN);309put_mat(TR[i],NULL,comment,2);310}311}312for (i=0;i<anz;i++){313mpz_clear(names+i);314free_mat(Y[i]);315if (TR != NULL) free_mat(TR[i]);316}317free(names);318free(Y);319if (TR != NULL) free(TR);320}321else{322Y = extensions(X[0],X[1],X[2],G,&len,&names,&anz,is_option('F'));323324printf("#%d\n",anz);325326for (i=0;i<anz;i++){327NAME = (char * ) malloc( mpz_sizeinbase( names + i , 10 ) + 2 );328mpz_get_str( NAME ,10,names+i);329sprintf(comment,330"%% the %d-th cozycle, length of orbit %d,name: %s",i+1,len[i],NAME);331if (is_option('S')){332sprintf(file, "%s.%s", FN, NAME);333R = extract_r(G, Y[i]);334put_bravais(R, file, comment);335free_bravais(R);336}337else{338put_cocycle(Y[i],G->dim,G->gen_no,NULL,comment);339}340free_mat(Y[i]);341mpz_clear(names+i);342free(NAME);343}344free(names);345free(Y);346Y = NULL;347free(len);348}349350for (i=0;i<3;i++) free_mat(X[i]);351for (i=0;i<G->gen_no;i++) if (matinv[i] != NULL) free_mat(matinv[i]);352free(matinv);353for (i=0;i<relator_input->rows;i++) wordfree(relator+i);354free(relator);355free_mat(relator_input);356free(X);357free_bravais(G);358359if (INFO_LEVEL & 12){360pointer_statistics(0,0);361}362363364exit(0);365} /* main */366367368369