GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* last change: 07.02.2001 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 <graph.h>11#include <gmp.h>12#include <zass.h>13#include <tools.h>14#include <longtools.h>151617extern int OANZ;18extern matrix_TYP **OMAT;19extern int OFLAG;20/* boolean GRAPH = FALSE; */2122232425/* -------------------------------------------------------------------- */26/* P < GL_n(Z) finite */27/* Returns the P-invariant maximal sublattices of Z^n */28/* (matrices in long_col_hnf - Form) */29/* with p_i-power-index, where p_i is a prime given in P->divisors. */30/* Returns the number of these sublattices via anz. */31/* set trivialflag[x] = TRUE iff lattices[x] = p_i * Z^n */32/* -------------------------------------------------------------------- */33matrix_TYP **max_sublattices(bravais_TYP *P,34int *anz,35int **trivialflag,36boolean debugflag)37{38matrix_TYP *F, *tmp, *std, **lattices;3940int p, X[100], i, j;4142bravais_TYP *PP;434445anz[0] = 0;46OFLAG = TRUE;47OANZ = 0;48memcpy(X, P->divisors, 100 * sizeof(int));49OMAT = (matrix_TYP **)calloc(1000, sizeof(matrix_TYP *));50trivialflag[0] = (boolean *)calloc(1000, sizeof(boolean));51F = init_mat(P->dim, P->dim, "1");5253for (p = 2; p < 100 ; p++){54if (X[p]){55PP = copy_bravais(P);56memset(PP->divisors, 0, 100 * sizeof(int));57PP->divisors[p] = 1;5859/* PP is changed in ZZ */60ZZ(PP, F, PP->divisors, NULL, "rbgl1", 0, 0, 0);61free_bravais(PP);6263if (OANZ == anz[0]){64/* trivial lattice isn't returned */65OMAT[OANZ] = init_mat(P->dim, P->dim, "");66for(i = 0; i < OMAT[OANZ]->rows; i++){67OMAT[OANZ]->array.SZ[i][i] = p;68}69Check_mat(OMAT[OANZ]);70trivialflag[0][OANZ] = TRUE;71OANZ++;72}73else{74for (i = anz[0]; i < OANZ; i++){75ZZ_transpose_array(OMAT[i]->array.SZ, OMAT[i]->cols);76long_col_hnf(OMAT[i]);77trivialflag[0][i] = FALSE;78}79}80cleanup_prime();81}82anz[0] = OANZ;83}8485OANZ = 0;86OFLAG = FALSE;87free_mat(F);88lattices = (matrix_TYP **)calloc(anz[0], sizeof(matrix_TYP *));8990for (i = 0; i < anz[0]; i++){9192/* paranoia test */93if (debugflag){94std = copy_mat(OMAT[i]);95long_col_hnf(std);96for (j = 0; j < P->gen_no; j++){97tmp = mat_mul(P->gen[j], OMAT[i]);98long_col_hnf(tmp);99if (cmp_mat(std, tmp)){100fprintf(stderr, "Not G-invariant!!!\n");101exit(2);102}103free_mat(tmp);104}105free_mat(std);106}107108lattices[i] = copy_mat(OMAT[i]);109free_mat(OMAT[i]);110}111free(OMAT);112memcpy(P->divisors, X, 100 * sizeof(int));113114return(lattices);115}116117118119