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"4#include"datei.h"567/* ---------------------------------------- */8/* Convert a single matrix in MAPLE format. */9/* ---------------------------------------- */10static void conv_mat_to_maple(matrix_TYP *A,11int i,12char *name){13int j, k;141516Check_mat(A);17if (!A->flags.Integral){18rat2kgv(A);19}20printf("%s%d := array(1..%d,1..%d,[\n", name, i+1, A->rows, A->cols);21for (j=0;j<A->rows;j++){22printf("[");23for (k=0;k<A->cols;k++){24printf(" %d",A->array.SZ[j][k]);25if (!A->flags.Integral){26printf("/%d",A->kgv);27}28if (k!=(A->cols-1)){29printf(",");30}31}32if (j != (A->rows-1)){33printf("],\n");34}35else{36printf("]");37}38}39printf("]):\n");40}41424344/* ---------------------------------------- */45/* Convert a single matrix in GAP format. */46/* ---------------------------------------- */47static void conv_mat_to_gap(matrix_TYP *A,48int i,49char *name){50int j, k;515253Check_mat(A);54if (!A->flags.Integral){55rat2kgv(A);56}57printf("%s%d := [", name, i+1);58for (j=0;j<A->rows;j++){59printf("[");60for (k=0;k<A->cols;k++){61printf(" %d",A->array.SZ[j][k]);62if (!A->flags.Integral){63printf("/%d",A->kgv);64}65if (k!=(A->cols-1)){66printf(",");67}68}69if (j != (A->rows-1)){70printf("],\n");71}72else{73printf("]");74}75}76printf("];;\n");77}78798081/* ---------------------------------------- */82/* Convert a single matrix in TeX format. */83/* ---------------------------------------- */84static void conv_mat_to_tex(matrix_TYP *A){8586int j, k;878889Check_mat(A);90if (!A->flags.Integral){91rat2kgv(A);92}93printf("\\left(\\begin{array}{");94for (j = 0; j < A->cols; j++)95printf("c");96printf("}\n");97for (j = 0; j < A->rows; j++){98for (k = 0;k < A->cols; k++){99if (A->array.SZ[j][k] % A->kgv == 0)100printf("%d ", A->array.SZ[j][k]/ A->kgv);101else102printf("%d/%d ", A->array.SZ[j][k], A->kgv);103if (k != A->cols - 1)104printf("& ");105}106printf("\\\\\n");107}108printf("\\end{array}\\right)\n");109}110111112113/* ---------------------------------------- */114/* Main function. */115/* ---------------------------------------- */116int main (int argc, char *argv[])117{118int i,119anz,120flag;121122matrix_TYP **A;123124bravais_TYP *G;125126char *name;127128129read_header(argc, argv);130if(FILEANZ < 1 || (is_option('h') && optionnumber('h') == 0) )131{132printf("Usage: Conv 'file' ['name'] -g -G -m -M -t -T\n");133printf("\n");134printf("file: matrix_TYP or bravais_TYP (only generators are converted).\n");135printf("name: (optional) a word\n");136printf("\n");137printf("Converts the matrix_TYP into the format of other\n");138printf("programs available. The options specify the program,\n");139printf("and only one of them is allowed at one time.\n");140printf("First of all the number of matrices is printed.\n");141printf("The matrices are called 'name.1', 'name.2', ... or\n");142printf("if name isn't given 'a.1', 'a.2', ...\n");143printf("\n");144printf("-g or -G: GAP-format\n");145printf("-m or -M: MAPLE-format\n");146printf("-t or -T: TeX-format (the matrices aren't named and\n");147printf(" the number of matrices isn't given)\n");148printf("\n");149if (is_option('h')){150exit(0);151}152else{153exit(31);154}155}156157G = get_bravais(FILENAMES[0]);158anz = G->gen_no;159A = G->gen;160161if (FILEANZ < 2)162name = "a";163else164name = FILENAMES[1];165166flag = 0;167if (is_option('t') || is_option('T'))168flag = 3;169if (is_option('m') || is_option('M'))170flag = 2;171if (is_option('g') || is_option('G'))172flag = 1;173174if (flag > 0 && flag < 3)175printf("%sNo := %i", name, anz);176177switch(flag){178case 2:179printf(":\n");180for (i = 0; i < anz; i++)181conv_mat_to_maple(A[i], i, name);182break;183184case 1:185printf(";;\n");186for (i = 0; i < anz; i++)187conv_mat_to_gap(A[i], i, name);188break;189190case 3:191for (i = 0; i < anz; i++)192conv_mat_to_tex(A[i]);193break;194195default:196printf("\nYou must specify at least one option. Try -h first.\n");197}198199A = NULL;200free_bravais(G);201202exit(0);203}204205206207208209210211212213214215216