Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

563580 views
1
#include"typedef.h"
2
#include"getput.h"
3
#include"matrix.h"
4
5
6
7
main (int argc, char *argv[])
8
{
9
10
matrix_TYP **x, **S, *E;
11
int anz1,
12
anz2,
13
i,
14
j;
15
16
char comment[1000];
17
18
read_header(argc, argv);
19
if(FILEANZ != 2)
20
{
21
printf("Usage: Mul 'file1' 'file2' [-x]\n");
22
printf("\n");
23
printf("file1: matrix_TYP containing the matrices A_i for 1<= i <= n.\n");
24
printf("file2: matrix_TYP containing the matrices B_j for 1<= j <= m.\n");
25
printf("\n");
26
printf("Multiply the matrices in 'file1' with those in 'file2'.\n");
27
printf("Called without any option the program ouptputs the products\n");
28
printf("A_k * B_k for 1 <= k <= Min(n,m).\n");
29
printf("\n");
30
printf("Options:\n");
31
printf(" -x : perform all products of the form A_i * B_j for 1 <= i <=n,\n");
32
printf(" 1 <= j <= m.\n");
33
printf("\n");
34
printf("Cf. Add\n");
35
if (is_option('h')){
36
exit(0);
37
}
38
else{
39
exit(31);
40
}
41
}
42
x = mget_mat(FILENAMES[0], &anz1);
43
S = mget_mat(FILENAMES[1], &anz2);
44
45
if (is_option('x')){
46
printf("#%d\n",anz1*anz2);
47
for(i=0;i<anz1;i++){
48
for(j=0;j<anz2;j++){
49
sprintf(comment,"product of the %d-th matrix of %s with the %d-th matrix of %s",i+1,FILENAMES[0],j+1,FILENAMES[1]);
50
E = mat_mul(x[i], S[j]);
51
put_mat(E,NULL,comment,2);
52
free_mat(E);
53
}
54
}
55
}
56
else{
57
if (anz1>anz2) anz1 = anz2;
58
printf("#%d\n",anz1);
59
for(i=0;i<anz1;i++){
60
sprintf(comment,"product of the %d-th matrix of %s with the %d-th matrix of %s",i+1,FILENAMES[0],i+1,FILENAMES[1]);
61
E = mat_mul(x[i], S[i]);
62
put_mat(E,NULL,comment,2);
63
free_mat(E);
64
}
65
}
66
67
exit(0);
68
}
69
70