GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "idem.h"2#include "matrix.h"3#include "bravais.h"4#include "longtools.h"5#include "tools.h"67matrix_TYP *almost_decomposable_lattice(bravais_TYP *G)8{910int i,11j,12k,13dimc,14dimcc,15col,16den,17IDEM_NO;1819matrix_TYP *id,20*F,21**IDEM_SPACES,22**IDEM,23*new_base,24*tmp;252627id = init_mat(G->dim,G->dim,"1");2829/* we need a G-invariant, positive definite form for various reasons */30F = rform(G->gen,G->gen_no,id,101);313233/* get the idempotents of the group */34IDEM = idempotente(G->gen,G->gen_no,F,&IDEM_NO,&dimc,&dimcc,NULL);35IDEM_SPACES = (matrix_TYP **) malloc(IDEM_NO * sizeof(matrix_TYP *));36den = 1; for (i=0;i<IDEM_NO;i++) den = KGV(den,IDEM[i]->kgv);37for (i=0;i<IDEM_NO;i++){38/* tmp = tr_pose(IDEM[i]);39IDEM_SPACES[i] = long_rein_mat(tmp);40free_mat(tmp); */41tmp = tr_pose(IDEM[i]);42tmp->kgv = 1; iscal_mul(tmp,den / IDEM[i]->kgv);43j = long_row_gauss(tmp);44real_mat(tmp,j,tmp->cols);45IDEM_SPACES[i] = tmp;46}4748new_base = init_mat(G->dim,G->dim,"0");49col = -1;50for (i=0;i<IDEM_NO;i++){51for (j=0;j<IDEM_SPACES[i]->rows;j++){52col++;53for (k=0;k<G->dim;k++){54new_base->array.SZ[k][col] = IDEM_SPACES[i]->array.SZ[j][k];55}56}57}5859Check_mat(new_base);60tmp = mat_inv(new_base); tmp->kgv=1; Check_mat(tmp);61free_mat(new_base);62for (i=0;i<IDEM_NO;i++){63free_mat(IDEM_SPACES[i]);64}65for (i=0;i<IDEM_NO+dimc+dimcc;i++){66free_mat(IDEM[i]);67}68free(IDEM_SPACES);69free(IDEM);70free_mat(F);71free_mat(id);7273return tmp;7475}767778