GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include <typedef.h>1#include <getput.h>2#include <matrix.h>3#include <base.h>45#include <longtools.h>6#include <bravais.h>7#include <idem.h>89int INFO_LEVEL;10extern int SFLAG;1112main(int argc,char **argv){1314matrix_TYP **x,15*y,16*z;1718char comment[1000];1920int i,21j,22anz;2324read_header(argc,argv);2526if ((is_option('h') && optionnumber('h')==0) || (FILEANZ < 1)){27printf("Usage: %s file [-r]\n",argv[0]);28printf("\n");29printf("file: matrix_TYP containing a set of integral square matrices.\n");30printf("\n");31printf("Calculates the minimal polynomial of each matrix in file.\n");32printf("WARNING: If a given matrix is not integral, the result will be incorrect.\n");33printf("\n");34printf("-r : calculate the integral roots of the given polynomials.\n");35printf("\n");36if (is_option('h')){37exit(0);38}39else{40exit(31);41}42}4344INFO_LEVEL = optionnumber('h');4546if (INFO_LEVEL & 12){47SFLAG = 1;48}4950x = mget_mat(FILENAMES[0],&anz);5152for (j=0;j<anz;j++){53y = min_pol(x[j]);5455printf("The minimal polynomial to the %d matrix of %s\n",j+1,FILENAMES[0]);5657if (y->array.SZ[0][y->cols-1] == 1)58printf(" X^%d",y->cols-1);59else60printf(" %d * X^%d",y->array.SZ[0][y->cols-1],y->cols-1);6162for (i=y->cols-2;i>0;i--)63if (y->array.SZ[0][i] > 1)64printf(" + %d * X^%d",y->array.SZ[0][i],i);65else if (y->array.SZ[0][i] < -1)66printf(" - %d * X^%d",-(y->array.SZ[0][i]),i);67else if (y->array.SZ[0][i] == -1)68printf(" - X^%d",i);69else if (y->array.SZ[0][i] == 1)70printf(" + X^%d",i);7172if (y->array.SZ[0][0]>0)73printf(" + %d \n",y->array.SZ[0][0]);74else if (y->array.SZ[0][0]<0)75printf(" - %d \n",-(y->array.SZ[0][0]));7677printf("\n");78/* put_mat(y,NULL,NULL,2); */7980if (is_option('r')){81z = zeros(y);82printf("Integral roots of the polynomial\n");83put_mat(z,NULL,NULL,2);84free_mat(z);85}8687free_mat(y);88free_mat(x[j]);89}9091free(x);9293if (INFO_LEVEL & 12){94pointer_statistics(0,0);95}9697exit(1);9899} /* main */100101102