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

563641 views
1
#include "ZZ.h"
2
#include "typedef.h"
3
#include "getput.h"
4
#include "gmp.h"
5
#include "name.h"
6
#include "bravais.h"
7
#include "datei.h"
8
#include "matrix.h"
9
#include "voronoi.h"
10
#include "autgrp.h"
11
#include "symm.h"
12
#include "base.h"
13
#include "zass.h"
14
#include "longtools.h"
15
16
#define DATABASE_NAME TOPDIR "/tables/qcatalog/data"
17
18
19
void extend(matrix_TYP *T)
20
{
21
22
real_mat(T,T->rows,T->cols+1);
23
real_mat(T,T->rows+1,T->cols);
24
25
T->array.SZ[T->rows-1][T->cols-1] = T->kgv;
26
27
return;
28
}
29
30
31
static matrix_TYP *get_cocycle(bravais_TYP *R,
32
bravais_TYP *P)
33
{
34
35
36
matrix_TYP **RG,
37
*coz;
38
39
int k,
40
j,
41
denominator,
42
**words;
43
44
RG = (matrix_TYP **) malloc( R->gen_no * sizeof(matrix_TYP*));
45
words = (int **) malloc(P->gen_no * sizeof(int *));
46
denominator = 1;
47
for (j=0;j<R->gen_no;j++){
48
RG[j] = copy_mat(R->gen[j]);
49
RG[j]->cols--;
50
RG[j]->rows--;
51
Check_mat(RG[j]);
52
if (!RG[j]->flags.Integral){
53
fprintf(stderr,"The point group has to be integral\n");
54
exit(3);
55
}
56
rat2kgv(R->gen[j]);
57
denominator *= (R->gen[j]->kgv / GGT(R->gen[j]->kgv,denominator));
58
}
59
60
/* stick the rigth INTEGRAL cozycle at the end of the RG[j] */
61
for (j=0;j<R->gen_no;j++){
62
RG[j]->cols++;
63
RG[j]->rows++;
64
for (k=0;k<RG[j]->rows-1;k++)
65
RG[j]->array.SZ[k][R->dim-1] = (denominator / R->gen[j]->kgv) *
66
R->gen[j]->array.SZ[k][R->dim-1];
67
RG[j]->array.SZ[R->dim-1][R->dim-1] = 1;
68
Check_mat(RG[j]);
69
}
70
71
/* get the cozycle on the right generators */
72
coz = reget_gen(RG,R->gen_no,P,words,TRUE);
73
74
/* the cozykle has to become the right denominator */
75
coz->kgv = denominator;
76
Check_mat(coz);
77
78
for (j=0;j<R->gen_no;j++){
79
free_mat(RG[j]);
80
}
81
for (j=0;j<P->gen_no;j++){
82
free(words[j]);
83
}
84
free(words);
85
free(RG);
86
87
return coz;
88
89
}
90
91
92
bravais_TYP *space_group_from_matrix(bravais_TYP *G,
93
matrix_TYP *x,
94
matrix_TYP *cocycle,
95
matrix_TYP *D)
96
{
97
98
bravais_TYP *R;
99
100
matrix_TYP *C;
101
102
int i,
103
j,
104
k;
105
106
R = init_bravais(G->dim+1);
107
C = convert_to_cozycle(x,cocycle,D);
108
109
R->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));
110
R->gen_no = G->gen_no;
111
for (i=0;i<G->gen_no;i++){
112
R->gen[i] = copy_mat(G->gen[i]);
113
real_mat(R->gen[i],G->dim+1,G->dim+1);
114
R->gen[i]->array.SZ[G->dim][G->dim] = 1;
115
iscal_mul(R->gen[i],C->kgv);
116
R->gen[i]->kgv = C->kgv;
117
}
118
119
/* stick the cocycle in the last column of the matrices generating R */
120
k = 0;
121
for (i=0;i<R->gen_no;i++){
122
for (j=0;j<G->dim;j++){
123
R->gen[i]->array.SZ[j][G->dim] = C->array.SZ[k][0];
124
k++;
125
}
126
Check_mat(R->gen[i]);
127
}
128
129
free_mat(C);
130
131
return R;
132
133
}
134
135
matrix_TYP *aff_class_inf(bravais_TYP *R,
136
bravais_TYP *DATAZ,
137
matrix_TYP *PRES,
138
MP_INT *aff_name,
139
bravais_TYP **RC)
140
{
141
142
matrix_TYP *cozycle,
143
**X,
144
**Y,
145
*coz_mat,
146
**matinv,
147
*RES;
148
149
word *relator;
150
151
int i;
152
153
long dim;
154
155
/* first thing to do is to find the generators of DATAZ in the
156
point group of R */
157
cozycle = get_cocycle(R,DATAZ);
158
159
/* do the cohomology calculations */
160
relator = (word *) calloc(PRES->rows,sizeof(word));
161
for (i=0;i<PRES->rows;i++){
162
matrix_2_word(PRES,relator+i,i);
163
}
164
165
166
matinv = (matrix_TYP **) calloc(DATAZ->gen_no , sizeof(matrix_TYP *));
167
X = cohomology(&dim,DATAZ->gen,matinv,relator,DATAZ->gen_no,PRES->rows);
168
169
if (X[0]->cols > 0){
170
/* give the group a name */
171
Y = identify(X[0],X[1],X[2],DATAZ,&cozycle,aff_name,1,3,NULL,NULL);
172
RES=Y[0]; free(Y);
173
174
if (RC){
175
/* construct our representative */
176
coz_mat = reverse_valuation(aff_name,X[1]);
177
*RC = space_group_from_matrix(DATAZ,coz_mat,X[0],X[1]);
178
free_mat(coz_mat);
179
}
180
181
}
182
else{
183
mpz_set_si(aff_name,0);
184
RES = init_mat(DATAZ->dim+1,DATAZ->dim+1,"1");
185
coboundary(DATAZ,cozycle,RES);
186
187
if (RC){
188
/* construct the split extension */
189
RC[0] = init_bravais(DATAZ->dim + 1);
190
RC[0]->gen = (matrix_TYP **) malloc(DATAZ->gen_no*sizeof(matrix_TYP*));
191
RC[0]->gen_no = DATAZ->gen_no;
192
for (i=0;i<DATAZ->gen_no;i++){
193
RC[0]->gen[i] = copy_mat(DATAZ->gen[i]);
194
extend(RC[0]->gen[i]);
195
}
196
free_mat(coz_mat);
197
}
198
}
199
200
/* clean up and return */
201
for (i=0;i<3;i++) free_mat(X[i]); free(X);
202
free_mat(cozycle);
203
for (i=0;i<PRES->rows;i++) wordfree(relator+i);
204
free(relator);
205
for (i=0;i<DATAZ->gen_no;i++)
206
if (matinv[i] != NULL) free_mat(matinv[i]);
207
free(matinv);
208
209
return RES;
210
}
211
212
213
214