GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "gmp.h"2/* #include "gmp-impl.h" */3#include "longtools.h"4#include "matrix.h"5/**************************************************************************\6@---------------------------------------------------------------------------7@---------------------------------------------------------------------------8@ FILE: long_kernel_mat.c9@---------------------------------------------------------------------------10@---------------------------------------------------------------------------11@12\**************************************************************************/1314/************************************************************************\15@ matrix_TYP *long_kernel_mat(A)16@ matrix_TYP *A;17@18@ long_kernel_mat(A) calculates Matrix X with AX = 019@ the cols of X are a Z-basis of the solution space.20@ The functions uses GNU MP21\************************************************************************/22matrix_TYP *long_kernel_mat(A)23matrix_TYP *A;24{25MP_INT ***E, **MA;26MP_INT Ekgv;27int Ecols, i,j;28matrix_TYP *erg, *ergt;293031MA = matrix_to_MP_mat(A);32mpz_init(&Ekgv);33E = MP_solve_mat(MA, A->rows, A->cols, NULL, 0, &Ecols, &Ekgv);34for(i=0;i<A->rows;i++)35{36for(j=0;j<A->cols;j++)37mpz_clear(&MA[i][j]);38free(MA[i]);39}40free(MA);414243if(E[1] != NULL)44{45erg = MP_mat_to_matrix(E[1], Ecols, A->cols);46for(i=0;i<Ecols;i++)47{48for(j=0;j<A->cols;j++)49mpz_clear(&E[1][i][j]);50free(E[1][i]);51}52free(E[1]);53}54else55erg = NULL;56free(E);57mpz_clear(&Ekgv);5859if (erg){60ergt = tr_pose(erg);61}62else{63ergt = NULL;64}6566/* inserted the if 28/1/97 tilman, problems with a matrix having670 rows */68if (erg != NULL){69free_mat(erg);70}71return(ergt);72}737475