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"bravais.h"3#include"matrix.h"45main (int argc, char *argv[])6{7int anz,8i,9j,10k,11rows,12cols;1314char comment[1000];1516matrix_TYP **F,17*tmp;1819read_header(argc, argv);20if(FILEANZ < 1 || is_option('h'))21{22printf("Usage: %s 'file' [-c=n1] [-r=n2]\n",argv[0]);23printf("\n");24printf("file: matrix_TYP.\n");25printf("\n");26printf("Writes the lines of the matrices given in file in\n");27printf("seperate matrices. The default assumption is that\n");28printf("the resulting matrices should be square.\n");29printf("In case either option r or c are given, the matrices\n");30printf("are given as n2xn1 matrices, where n1*n2=#columns of the\n");31printf("matrices of file.\n");32printf("Note that this function does exactly the inverse of Mtl!\n");33printf("\n");34printf("OPTIONS:\n");35printf("\n");36printf("-c=n1: the matrices will have n1 columns.\n");37printf("-r=n2: the matrices will have n2 rows.\n");38printf("\n");39printf("Cf. Mtl\n");40if (is_option('h')){41exit(0);42}43else{44exit(31);45}46}4748F = mget_mat(FILENAMES[0],&anz);4950for (i=0;i<anz;i++){51rat2kgv(F[i]);52if ((F[i]->cols != F[0]->cols) || (F[i]->rows != F[0]->rows)){53printf("The matrices given in %s must have same dimensions\n",54FILENAMES[0]);55exit(3);56}57}5859if (is_option('r') && is_option('c')){60rows=optionnumber('r');61cols=optionnumber('c');62}63else if(is_option('r')){64rows = optionnumber('r');65cols = floor(F[0]->cols/rows + 0.5);66}67else if(is_option('c')){68cols = optionnumber('c');69rows = floor(F[0]->cols/cols + 0.5);70}71else{72cols = floor(sqrt(F[0]->cols)+0.5);73rows = floor(sqrt(F[0]->cols)+0.5);74}7576if ((rows*cols) != F[0]->cols){77printf("The specification is not suitable\n");78exit(3);79}8081printf("#%d\n",anz*F[0]->rows);8283tmp = init_mat(rows,cols,"");8485for (i=0;i<anz;i++){86for (j=0;j<F[0]->rows;j++){87tmp->kgv = F[i]->kgv;88for (k=0;k<F[0]->cols;k++){89tmp->array.SZ[(k - (k%cols))/cols][k % cols]=F[i]->array.SZ[j][k];90}91sprintf(comment,"Ltm on file %s",FILENAMES[0]);92Check_mat(tmp);93put_mat(tmp,NULL,comment,2);94}95}969798exit(0);99}100101102103