GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include"typedef.h"1/**************************************************************************\2@---------------------------------------------------------------------------3@---------------------------------------------------------------------------4@ FILE: hyp_stabilizer.c5@---------------------------------------------------------------------------6@---------------------------------------------------------------------------7@8\**************************************************************************/91011/**************************************************************************\12@---------------------------------------------------------------------------13@ bravais_TYP *hyperbolic_stabilizer(x, S)14@ matrix_TYP *x, *S;15@16@ the functions 'hyperbolic_stabilizer' calculates generators17@ for a finite subgroup G of GL_n(Q) with18@ vg = v and gSg^{tr} = S for all g in G.19@ where v denotes the first row of x.20@ The group H of all integral matrices with this property is21@ a subgroup of H.22@---------------------------------------------------------------------------23@24\**************************************************************************/25bravais_TYP *hyperbolic_stabilizer(x, S)26matrix_TYP *x, *S;27{28matrix_TYP *xS, *xS0, **Sred, *T, *Ti, *W, *W1;29bravais_TYP *G1, *G;30int i,j,k, n;3132extern matrix_TYP *mat_mul();33extern matrix_TYP *mat_inv();34extern bravais_TYP *pr_aut();35extern matrix_TYP *solve_mat();36extern matrix_TYP *init_mat();37extern matrix_TYP *scal_pr();3839n = x->cols;40xS = mat_mul(x, S);41xS0 = solve_mat(xS);42if((Sred = (matrix_TYP **)malloc(1*sizeof(matrix_TYP *))) == NULL)43{44printf("malloc of 'Sred' in 'hyperbolic_stabilizer' failed\n");45exit(2);46}47Sred[0] = scal_pr(xS0, S, 1);48G1 = pr_aut(Sred, 1, NULL, 0, NULL);49if((G = (bravais_TYP *)malloc(sizeof(bravais_TYP))) == NULL)50{51printf("malloc of 'G' in 'hyperbolic_stabilizer' failed\n");52exit(2);53}54G->gen_no = G1->gen_no;55if((G->gen = (matrix_TYP **)malloc(G->gen_no *sizeof(matrix_TYP *))) == NULL)56{57printf("malloc of 'G->gen' in 'hyperbolic_stabilizer' failed\n");58exit(2);59}60G->zentr_no = G->form_no = G->normal_no = G->cen_no = 0;61for(i=0;i<100;i++)62G->divisors[i] = G1->divisors[i];63G->order = G1->order;64G->dim = n;65T = init_mat(n,n,"");66for(i=0;i<n-1;i++)67{68for(j=0;j<n;j++)69T->array.SZ[i][j] = xS0->array.SZ[i][j];70}71for(i=0;i<n;i++)72T->array.SZ[n-1][i] = x->array.SZ[0][i];73Ti = mat_inv(T);74W = init_mat(n,n,"");75W->array.SZ[n-1][n-1] = 1;76for(i=0;i<G->gen_no;i++)77{78for(j=0;j<n-1;j++)79for(k=0;k<n-1;k++)80W->array.SZ[j][k] = G1->gen[i]->array.SZ[j][k];81W1 = mat_mul(Ti, W);82G->gen[i] = mat_mul(W1, T);83free_mat(W1);84}85free_mat(W); free_mat(T); free_mat(Ti);86free_bravais(G1);87free_mat(xS); free_mat(xS0); free_mat(Sred[0]); free(Sred);88return(G);89}909192