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

563516 views
1
#include"typedef.h"
2
#include"getput.h"
3
#include"bravais.h"
4
#include"matrix.h"
5
6
main (argc,argv)
7
int argc;
8
char *argv[];
9
{
10
int i,
11
j,
12
anz1,
13
anz2,
14
min,
15
l,
16
r,
17
z,
18
n;
19
20
matrix_TYP **A,
21
**B,
22
*tmp;
23
24
char comment[1000];
25
26
rational l_rat,
27
r_rat;
28
29
30
read_header(argc, argv);
31
if(FILEANZ < 2)
32
{
33
printf("usage: Add 'file1' 'file2' [-x] -l=n1 -r=n2 -n=n3\n");
34
printf(" where file1 and file2 contain a matrix_TYP .\n");
35
printf("\n");
36
printf(" Calculates the sums (n1 * A + n2 * B)/n3 with matrices A, B\n");
37
printf(" taken from file1, file2 respectively.\n");
38
printf("\n");
39
printf("-x: Calculates all possible sums of matrices of file1\n");
40
printf(" with file2.\n");
41
printf(" If this option is not present, the programm adds the\n");
42
printf(" i-th matrix of file1 to the i-th matrix of file2\n");
43
printf("\n");
44
if (is_option('h')){
45
exit(0);
46
}
47
else{
48
exit(31);
49
}
50
}
51
52
A = mget_mat(FILENAMES[0],&anz1);
53
B = mget_mat(FILENAMES[1],&anz2);
54
55
if (anz1<anz2){
56
min = anz1;
57
}
58
else{
59
min = anz2;
60
}
61
62
if (is_option('n')){
63
n = optionnumber('n');
64
}
65
else{
66
n = 1;
67
}
68
69
if (is_option('l')){
70
l = optionnumber('l');
71
}
72
else{
73
l = 1;
74
}
75
76
if (is_option('r')){
77
r = optionnumber('r');
78
}
79
else{
80
r = 1;
81
}
82
83
l_rat.z = l;
84
l_rat.n = n;
85
86
r_rat.z = r;
87
r_rat.n = n;
88
89
if (is_option('x')){
90
printf("#%d\n",anz1*anz2);
91
for (i=0;i<anz1;i++){
92
for (j=0;j<anz2;j++){
93
tmp = mat_add(A[i],B[j],l_rat,r_rat);
94
sprintf(comment,"sum of %d-th matrix of %s with %d-th matrix of %s",
95
i+1,FILENAMES[0],j+1,FILENAMES[1]);
96
put_mat(tmp,NULL,comment,2);
97
free_mat(tmp);
98
}
99
}
100
}
101
else{
102
printf("#%d\n",min);
103
for (i=0;i<min;i++){
104
tmp = mat_add(A[i],B[i],l_rat,r_rat);
105
sprintf(comment,"sum of %d-th matrix of %s with %d-th matrix of %s",
106
i+1,FILENAMES[0],i+1,FILENAMES[1]);
107
put_mat(tmp,NULL,comment,2);
108
free_mat(tmp);
109
}
110
}
111
112
}
113
114