GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "matrix.h"2#include "getput.h"3#include "datei.h"4#include "orbit.h"5#include "longtools.h"6#include "sort.h"7#include "bravais.h"8/**************************************************************************\9@---------------------------------------------------------------------------10@---------------------------------------------------------------------------11@ FILE: gittstabneu.c12@---------------------------------------------------------------------------13@---------------------------------------------------------------------------14@15\**************************************************************************/161718/**************************************************************************\19@---------------------------------------------------------------------------20@ bravais_TYP *gittstab(grp, X)21@ bravais_TYP *grp;22@ matrix_TYP *X;23@24@ gittstab calculates the stabilizer of a lattice X under the |25@ operation of the group 'grp' acting via left-multiplication |26@---------------------------------------------------------------------------27@28\**************************************************************************/29bravais_TYP *gittstabneu(grp, X)30bravais_TYP *grp;31matrix_TYP *X;32{33int i,34j,35search,36length,37options[6];3839bravais_TYP *stab;4041matrix_TYP **orbit,42*INV,43*Y;4445/* make the options for orbit */46for (i=0;i<6;i++) options[i] = 0;47options[1] = 4;48options[3] = 1;4950/* gauss reduce a copy of X */51Y = copy_mat(X);52long_col_hnf(Y);5354/* reserve memory as asked for in orbit_alg */55stab = init_bravais(grp->dim);5657orbit = orbit_alg(Y,grp,stab,options,&length);5859/* throw away the orbit */60for (i=0;i<length;i++){61free_mat(orbit[i]);62}63free(orbit);64free_mat(Y);6566/* try to reduce the number of generators */67/* firstly sort them */68mat_quicksort(stab->gen,0,stab->gen_no-1,mat_comp);69for (i=0;i<stab->gen_no-1;i++){70if (mat_comp(stab->gen[i],stab->gen[i+1]) == 0){71free_mat(stab->gen[i+1]);72stab->gen_no--;73for (j=i+1;j<stab->gen_no;j++){74stab->gen[j] = stab->gen[j+1];75}76i--;77}78}7980/* second pass, use the inverses */81/* bare in mind that the generator list is sorted and does not have82duplicates */83for (i=0;i<stab->gen_no;i++){84INV = mat_inv(stab->gen[i]);85search = mat_search(INV,stab->gen,stab->gen_no,mat_comp);86free_mat(INV);87/* watch for elements of order 2 !!! */88if (search != -1 && search != i){89if (search<i){90fprintf(stderr,"Error in gittstabneu\n");91exit(3);92}93free_mat(stab->gen[search]);94stab->gen_no--;95for (j=search;j<stab->gen_no;j++){96stab->gen[j] = stab->gen[j+1];97}98}99}100101/* reallocate the memory for stag->gen */102stab->gen = (matrix_TYP **) realloc(stab->gen,103sizeof(matrix_TYP *)*stab->gen_no);104105/* calculate the order of the stabilizer (if possible) */106if (grp->order != 0){107stab->order = grp->order/length;108factorize_new(stab->order,stab->divisors);109}110else{111stab->order = 0;112for (i=0;i<100;i++) stab->divisors[i] = 0;113}114115return(stab);116}117118119