GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include"typedef.h"1#include"polyeder.h"2#include"matrix.h"3#include"longtools.h"4/**************************************************************************\5@---------------------------------------------------------------------------6@---------------------------------------------------------------------------7@ FILE: first_polyeder.c8@---------------------------------------------------------------------------9@---------------------------------------------------------------------------10@11\**************************************************************************/1213141516/**************************************************************************\17@---------------------------------------------------------------------------18@ polyeder_TYP *first_polyeder(mauern, anz)19@ wall_TYP **mauern;20@ int anz;21@22@ The arguments of 'first_polyeder' are linear inequalities23@ representent by 'mauern'.24@ 'anz' is the number of these equalities.25@ 'first_polyeder' returns NULL if there are not n = mauern[0]->dim26@ independent inequalities among the walls.27@ Otherwise, 'first_polyeder' selects n linear independent inequalities28@ and calculates the linear simplex defined by them.29@---------------------------------------------------------------------------30@31\**************************************************************************/32polyeder_TYP *first_polyeder(mauern, anz)33wall_TYP **mauern;34int anz;35{36int i,j,k,n;37int s, rrang, test, *take;38matrix_TYP *M, *Mi;39polyeder_TYP *erg;404142n = mauern[0]->dim;43M = init_mat(anz, n, "");44take = (int *)malloc(anz *sizeof(int));45for(i=0;i<anz;i++)46take[i] = 0;47for(i=0;i<anz;i++)48for(j=0; j<n; j++)49M->array.SZ[i][j] = mauern[i]->gl[j];50/******************************51put_mat(M, NULL, "matrix in first_polyeder", 0);52******************************/5354M->rows = 1;55rrang = n;56while(rrang != 0 && M->rows <= anz)57{5859/* changed 19/8/97 tilman from:60s = long_row_gauss(M); to: */61s = long_row_basis(M,FALSE);6263s = n - s;64if(s == rrang)65take[M->rows-1] = FALSE;66else67take[M->rows-1] = TRUE;68rrang = s;69if(rrang != 0)70M->rows++;71}72if(rrang != 0)73{74M->rows = anz;75free_mat(M);76free(take);77return(NULL);78}7980erg = init_polyeder(n, n);81erg->is_closed = FALSE;82erg->is_degenerate = FALSE;83for(i=0; i<n;i++)84{85erg->vert[i] = init_vertex(n, n-1);86erg->wall[i] = init_wall(n);87}88k = 0;89M->rows = n;90for(i=0; i<anz;i++)91{92if(take[i] == TRUE)93{94for(j=0;j<n;j++)95{96M->array.SZ[k][j] = mauern[i]->gl[j];97erg->wall[k]->gl[j] = mauern[i]->gl[j];98}99erg->wall[k]->next_no = mauern[i]->next_no; /* 7 lines anne 8/10/97 */100erg->wall[k]->next = NULL;101if(mauern[i]->next != NULL){102erg->wall[k]->next = (int**)malloc(mauern[i]->next_no*sizeof(int*));103memcpy(erg->wall[k]->next, mauern[i]->next,104mauern[i]->next_no * sizeof(int));105}106erg->wall[k]->mat = copy_mat(mauern[i]->mat); /*anne, 4.3.97(2 Zeile)*/107erg->wall[k]->neu = mauern[i]->neu;108/* inserted next 5 lines to correspond to first_fuber */109erg->wall[k]->nproduct = mauern[i]->nproduct;110erg->wall[k]->product = (int *) malloc(erg->wall[k]->nproduct *111sizeof(int));112for (j=0;j<erg->wall[k]->nproduct;j++)113erg->wall[k]->product[j] = mauern[i]->product[j];114115k++;116}117}118/******************************119put_mat(M, NULL, "matrix in first_polyeder", 0);120******************************/121Mi = long_mat_inv(M);122M->rows = anz;123free_mat(M);124free(take);125for(i=0;i<n;i++)126{127k = 0;128for(j=0;j<n;j++)129{130erg->vert[i]->v[j] = Mi->array.SZ[j][i];131if(i!=j)132{ erg->vert[i]->wall[k] = j; k++;}133}134}135free_mat(Mi);136for(i=0;i<n;i++)137normal_vertex(erg->vert[i]);138return(erg);139}140141142