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 (int argc, char *argv[])
7
{
8
int i,
9
j,
10
anz1,
11
anz2,
12
min;
13
14
matrix_TYP **A,
15
**B,
16
*tmp;
17
18
char comment[1000];
19
20
read_header(argc, argv);
21
if((FILEANZ < 2) || (is_option('h')))
22
{
23
printf("Usage: Kron 'file1' 'file2' [-x]\n");
24
printf("\n");
25
printf("file1: matrix_TYP.\n");
26
printf("file2: matrix_TYP.\n");
27
printf("\n");
28
printf("Calculates the Kronecker product of the matrices given\n");
29
printf("in file1 with those of file2.\n");
30
printf("\n");
31
printf("OPTIONS:\n");
32
printf("-x : Outputs every possible Kronecker product. If this option\n");
33
printf(" is not present, the Kronecker product of the i-th matrix\n");
34
printf(" of file1 with the i-th matrix of file2 is calculated.\n");
35
printf("\n");
36
if (is_option('h')){
37
exit(0);
38
}
39
else{
40
exit(31);
41
}
42
}
43
44
A = mget_mat(FILENAMES[0],&anz1);
45
B = mget_mat(FILENAMES[1],&anz2);
46
47
if (anz1<anz2){
48
min = anz1;
49
}
50
else{
51
min = anz2;
52
}
53
54
if (is_option('x')){
55
printf("#%d\n",anz1*anz2);
56
for (i=0;i<anz1;i++){
57
for (j=0;j<anz2;j++){
58
tmp = kron_mat(A[j],B[i]);
59
sprintf(comment,
60
"Kronecker product of %d-th matrix of %s with %d-th matrix of %s",
61
j+1,FILENAMES[0],i+1,FILENAMES[1]);
62
put_mat(tmp,NULL,comment,2);
63
free_mat(tmp);
64
}
65
}
66
}
67
else{
68
printf("#%d\n",min);
69
for (i=0;i<min;i++){
70
tmp = kron_mat(A[i],B[i]);
71
sprintf(comment,
72
"Kronecker product of %d-th matrix of %s with %d-th matrix of %s",
73
i+1,FILENAMES[0],i+1,FILENAMES[1]);
74
put_mat(tmp,NULL,comment,2);
75
free_mat(tmp);
76
}
77
}
78
79
80
exit(0);
81
}
82
83