GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "tools.h"2#include "matrix.h"3#include "voronoi.h"4#include "ZZ_P.h"5#include "ZZ_gen_vs_P.h"67/*8* Determine the image of the generators in Mn(GF(p),n).9*/1011matrix_TYP **ZZ_mod_gen (matrix_TYP **gen, int num)12{13int i, j, k, dim;14matrix_TYP **p_gen;1516dim = gen[0]->rows;17p_gen = (matrix_TYP **) malloc (num * sizeof (matrix_TYP *));18for (k = 0; k < num; k++) {19p_gen[k] = init_mat (dim, dim, "p");20for (i = 0; i < dim; i++) {21for (j = 0; j < dim; j++) {22p_gen[k]->array.SZ[i][j] =23gen[k]->array.SZ[i][j] % act_prime;24if (p_gen[k]->array.SZ[i][j] < 0) {25p_gen[k]->array.SZ[i][j] += act_prime;26}27}28}29}30return (p_gen);31}323334/*35* Determine the rank and a basis for the image of a vector36* under the operation of an order (given by its Z-basis).\37*/3839matrix_TYP *ZZ_vec_bahn (int *vec, matrix_TYP **gen, int num)40{41matrix_TYP *basis;42int **B, **T, *v, new_flag;43int i, j, k, dim, act, new, rank, flag;4445dim = gen[0]->rows;4647basis = init_mat ((num + 1) * dim, dim, "p");48basis->prime = gen[0]->prime;49B = basis->array.SZ;50memcpy (B[0], vec, dim * sizeof (int));51rank = 1;52new = 1;53flag = 1;54while (flag) {55for (act = 0; act < rank; act++) {56v = B[act];57for (i = 0; i < num; i++) {58if (save_null_mat (gen[i]))59continue;60T = gen[i]->array.SZ;61new_flag = 0;62for (j = 0; j < dim; j++) {63B[new][j] = P (v[0], T[0][j]);64for (k = 1; k < dim; k++) {65B[new][j] = S(B[new][j], P(v[k], T[k][j]));66}67if (B[new][j])68new_flag++;69}70if (new_flag)71new++;72}73}74basis->rows = new;75i = p_gauss (basis);76flag = ((i == rank) || (i == dim)) ? 0 : 1;77rank = i;78new = i;79}80for (i = rank; i < (num + 1) * dim; i++) {81free (basis->array.SZ[i]);82}83basis->array.SZ = (int **) realloc (basis->array.SZ, rank * sizeof (int *));84basis->rows = rank;8586Check_mat (basis);87return (basis);88}899091/*92* Generate the vector space of given dimension over the93* prim field GF(p) up to a skalar factor (the leading94* coordinate unequal to zero is one).95*/9697matrix_TYP *ZZ_gen_vs (int prim, int dim)98{99int act, i, j, n;100matrix_TYP *VS;101int **M;102103104/* calculate number of vectors */105n = 1;106j = prim;107for (i = 1; i < dim; i++) {108n += j;109j *= prim;110}111112/* alloc space and generated vector space */113114VS = init_mat (n, dim, "");115M = VS->array.SZ;116i = 1;117act = dim - 1;118M[0][act] = 1;119while (i < n) {120j = dim - 1;121while ((j > 0) && ((M[i][j] = (M[i - 1][j] + 1) % prim) == 0))122j--;123if (j <= act) {124M[i][act--] = 0;125M[i][act] = 1;126} else {127while (--j >= act)128M[i][j] = M[i - 1][j];129}130i++;131}132return (VS);133}134135136