GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* last change: 19.01.01 by Oliver Heidbuechel */123#include <ZZ.h>4#include <typedef.h>5#include <presentation.h>6#include <matrix.h>7#include <bravais.h>8#include <base.h>9#include <datei.h>10#include <longtools.h>11#include <graph.h>12#include <tsubgroups.h>13141516extern int OANZ;17extern matrix_TYP **OMAT;18extern int OFLAG;19/* boolean GRAPH = FALSE; */20212223/* -------------------------------------------------------------------- */24/* R: spacegroup in standard affine form without translations */25/* calculate all minimal k-supergroups of R */26/* T(R) has to be Z^n */27/* P is the point group of R with correct normalizer */28/* return the number of these groups via anz */29/* if bahnflag representatives under the operation of N_Aff_n (R) */30/* are returned */31/* debugflag == TRUE: do paranoia test */32/* -------------------------------------------------------------------- */33bravais_TYP **min_k_super(bravais_TYP *P,34bravais_TYP *R,35matrix_TYP *pres,36int *anz,37boolean bahnflag,38boolean debugflag,39int **length)40{41bravais_TYP **S,42*TR;4344matrix_TYP *F, *std, *tmp2,45**gitter, **allgitter,46**N;4748int p, i, j, Nanz, anzalt,49*list, *smallest, *kopiert;505152anz[0] = 0;53OFLAG = TRUE;54OANZ = 0;55OMAT = (matrix_TYP **)malloc(1000 * sizeof(matrix_TYP *));56F = init_mat(P->dim, P->dim, "1");5758/* calculate the superlattices */59for (p = 2; p < 100 ; p++){60if (P->divisors[p]){61TR = tr_bravais(P, 1, 0);62memset(TR->divisors, 0, 100 * sizeof(int));63TR->divisors[p] = 1;6465/* TR ist changed in ZZ */66ZZ(TR, F, TR->divisors, NULL, "rbgl1", 0, 0, 0);67free_bravais(TR);6869if (OANZ == anz[0]){70OMAT[OANZ] = init_mat(P->dim, P->dim, "");71for(i = 0; i < OMAT[OANZ]->rows; i++){72OMAT[OANZ]->array.SZ[i][i] = p;73}74Check_mat(OMAT[OANZ]);75OANZ++;76}77cleanup_prime();78}79anz[0] = OANZ;80}8182OANZ = 0;83OFLAG = FALSE;84free_mat(F);8586/* calculate the correct lattices */87allgitter = (matrix_TYP **)calloc(anz[0], sizeof(matrix_TYP *));88for (i = 0; i < anz[0]; i++){89allgitter[i] = mat_inv(OMAT[i]);90long_col_hnf(allgitter[i]);91free_mat(OMAT[i]);92}93free(OMAT);9495if (bahnflag){96/* calculate the point group of the affine normalizer of R */97cen_to_norm(P);98N = PoaN(R, P, pres, &Nanz);99100/* calculate orbit on lattices */101list = (int *)calloc(anz[0], sizeof(int));102length[0] = (int *)calloc(anz[0] + 1, sizeof(int));103smallest = (int *)calloc(anz[0] + 1, sizeof(int));104anzalt = anz[0];105anz[0] = orbit_on_lattices(allgitter, anzalt, N, Nanz, list,106length[0], smallest, NULL);107108/* get representatives */109gitter = (matrix_TYP **)calloc(anz[0], sizeof(matrix_TYP *));110kopiert = (int *)calloc(anzalt, sizeof(int));111for (i = 1; i <= anz[0]; i++){112gitter[i - 1] = allgitter[smallest[i]];113kopiert[smallest[i]] = 1;114}115116/* clean */117for (i = 0; i < Nanz; i++){118free_mat(N[i]);119}120for (i = 0; i < anzalt; i++){121if (kopiert[i] == 0)122free_mat(allgitter[i]);123}124free(kopiert);125free(N);126free(allgitter);127}128else{129gitter = allgitter;130}131132/* calculate the groups */133S = (bravais_TYP **)calloc(anz[0], sizeof(bravais_TYP *));134for (i = 0; i < anz[0]; i++){135S[i] = copy_bravais(R);136plus_translationen(S[i], gitter[i]);137138/* paranoia test */139if (debugflag){140std = copy_mat(gitter[i]);141long_col_hnf(std);142for (j = 0; j < P->gen_no; j++){143tmp2 = mat_mul(P->gen[j], gitter[i]);144long_col_hnf(tmp2);145if (cmp_mat(std, tmp2)){146fprintf(stderr, "Not G-invariant!!!\n");147exit(2);148}149free_mat(tmp2);150}151free_mat(std);152}153}154155/* clean */156for (i = 0; i < anz[0]; i++){157free_mat(gitter[i]);158}159free(gitter);160if (bahnflag){161free(list);162free(smallest);163}164165return(S);166}167168169170171172173174175176177178179180181182183184185186187188189190191192193