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"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
**Binv,
17
*tmp,
18
*tmp2;
19
20
char comment[1000];
21
22
read_header(argc, argv);
23
if(FILEANZ < 2)
24
{
25
printf("Usage: %s 'file1' 'file2' [-x]\n",argv[0]);
26
printf("\n");
27
printf("file1: matrix_TYP containing matrices A_i\n");
28
printf("file2: matrix_TYP containing matrices B_j\n");
29
printf("\n");
30
printf("Conjugates the i-th matrix of file1 with the i-th matrix of\n");
31
printf("file2, i.e. performs products of the form B_i * A_i * B_i^-1.\n");
32
printf("\n");
33
printf("Options:\n");
34
printf("-x: Conjugates all matrices of file1 with all matrices\n");
35
printf(" of file2, i.e. performs all products of the for B_j * A_i * B_j^-1.\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
Binv = (matrix_TYP **) malloc(anz2 * sizeof(matrix_TYP *));
48
49
for (i=0;i<anz2;i++){
50
Binv[i] = mat_inv(B[i]);
51
}
52
53
if (anz1<anz2){
54
min = anz1;
55
}
56
else{
57
min = anz2;
58
}
59
60
if (is_option('x')){
61
printf("#%d\n",anz1*anz2);
62
for (i=0;i<anz1;i++){
63
for (j=0;j<anz2;j++){
64
tmp2 = mat_mul(A[i],Binv[j]);
65
tmp = mat_mul(B[j],tmp2);
66
free_mat(tmp2);
67
sprintf(comment,
68
"B*A*B^{-1} for A = %d-th matrix of %s, B= %d-th matrix of %s",
69
i+1,FILENAMES[0],j+1,FILENAMES[1]);
70
put_mat(tmp,NULL,comment,2);
71
free_mat(tmp);
72
}
73
}
74
}
75
else{
76
printf("#%d\n",min);
77
for (i=0;i<min;i++){
78
tmp2 = mat_mul(A[i],Binv[i]);
79
tmp = mat_mul(B[i],tmp2);
80
free_mat(tmp2);
81
sprintf(comment,
82
"B*A*B^{-1} for A = %d-th matrix of %s, B= %d-th matrix of %s",
83
i+1,FILENAMES[0],i+1,FILENAMES[1]);
84
put_mat(tmp,NULL,comment,2);
85
free_mat(tmp);
86
}
87
}
88
89
exit(0);
90
}
91
92