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 (argc,argv)6int argc;7char *argv[];8{9int i,10j,11anz1,12anz2,13min,14l,15r,16z,17n;1819matrix_TYP **A,20**B,21*tmp;2223char comment[1000];2425rational l_rat,26r_rat;272829read_header(argc, argv);30if(FILEANZ < 2)31{32printf("usage: Add 'file1' 'file2' [-x] -l=n1 -r=n2 -n=n3\n");33printf(" where file1 and file2 contain a matrix_TYP .\n");34printf("\n");35printf(" Calculates the sums (n1 * A + n2 * B)/n3 with matrices A, B\n");36printf(" taken from file1, file2 respectively.\n");37printf("\n");38printf("-x: Calculates all possible sums of matrices of file1\n");39printf(" with file2.\n");40printf(" If this option is not present, the programm adds the\n");41printf(" i-th matrix of file1 to the i-th matrix of file2\n");42printf("\n");43if (is_option('h')){44exit(0);45}46else{47exit(31);48}49}5051A = mget_mat(FILENAMES[0],&anz1);52B = mget_mat(FILENAMES[1],&anz2);5354if (anz1<anz2){55min = anz1;56}57else{58min = anz2;59}6061if (is_option('n')){62n = optionnumber('n');63}64else{65n = 1;66}6768if (is_option('l')){69l = optionnumber('l');70}71else{72l = 1;73}7475if (is_option('r')){76r = optionnumber('r');77}78else{79r = 1;80}8182l_rat.z = l;83l_rat.n = n;8485r_rat.z = r;86r_rat.n = n;8788if (is_option('x')){89printf("#%d\n",anz1*anz2);90for (i=0;i<anz1;i++){91for (j=0;j<anz2;j++){92tmp = mat_add(A[i],B[j],l_rat,r_rat);93sprintf(comment,"sum of %d-th matrix of %s with %d-th matrix of %s",94i+1,FILENAMES[0],j+1,FILENAMES[1]);95put_mat(tmp,NULL,comment,2);96free_mat(tmp);97}98}99}100else{101printf("#%d\n",min);102for (i=0;i<min;i++){103tmp = mat_add(A[i],B[i],l_rat,r_rat);104sprintf(comment,"sum of %d-th matrix of %s with %d-th matrix of %s",105i+1,FILENAMES[0],i+1,FILENAMES[1]);106put_mat(tmp,NULL,comment,2);107free_mat(tmp);108}109}110111}112113114