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

563665 views
1
#include"typedef.h"
2
#include"matrix.h"
3
#include"bravais.h"
4
#include"longtools.h"
5
/**************************************************************************\
6
@---------------------------------------------------------------------------
7
@---------------------------------------------------------------------------
8
@ FILE: invar_space.c
9
@---------------------------------------------------------------------------
10
@---------------------------------------------------------------------------
11
@
12
\**************************************************************************/
13
14
/**************************************************************************\
15
@---------------------------------------------------------------------------
16
@ matrix_TYP **invar_space(B, Banz, fodim, symm_opt, epsilon, anz)
17
@ matrix_TYP **B;
18
@ int Banz, fodim, symm_opt, epsilon, *anz;
19
@
20
@ calculates a basis of the lattices of integral matrices X
21
@ with B[i]^{tr} * X * B[i] = X for 0<=i<Banz
22
@
23
@ the number of basis elements must be given to the function by the
24
@ integer 'fodim'
25
@ Then 'fodim'+1 random elements of the lattice are calculated with
26
@ the function 'rform' and
27
@ a basis of the integral matrices in the subspace generated by these
28
@ elements is constructed with 'long_rein_mat'.
29
@ This basis is the result and the number of elements is returned
30
@ via (int *anz)
31
@ The argument 'epsilon' is the only needed argument for 'rform', that
32
@ is called in the function.
33
@ the number of basis elements is returned via (int *anz).
34
@
35
@ 'symm_opt' must be 0, 1 or -1.
36
@ symm_opt = 0: the full lattice is calculated.
37
@ symm_opt = 1: a basis for the symmetric matrices is calculated
38
@ symm_opt =-1: a basis for the skewsymmetric matrices is calculated
39
@---------------------------------------------------------------------------
40
@
41
\**************************************************************************/
42
43
44
matrix_TYP **invar_space(B, Banz, fodim, symm_opt, epsilon, anz)
45
matrix_TYP **B;
46
int Banz, fodim, symm_opt, epsilon, *anz;
47
{
48
int i,j,k,l, dim, ff, dd;
49
matrix_TYP *pm, *pm1, **erg, *startmat, *invar;
50
int r;
51
52
dim = B[0]->cols;
53
if(B[0]->rows != dim)
54
{
55
printf("error in formspace: non-square matrix in group 'B'\n");
56
exit(3);
57
}
58
for(i=1;i<Banz;i++)
59
{
60
if(B[i]->rows != dim || B[i]->cols != dim)
61
{
62
printf("error in formspace: different dimesion of group elements\n");
63
exit(3);
64
}
65
}
66
if(symm_opt == 1)
67
dd = (dim *(dim+1))/2;
68
if(symm_opt == -1)
69
dd = (dim *(dim-1))/2;
70
if(symm_opt == 0)
71
dd = dim * dim;
72
73
if(fodim <= 0)
74
{ *anz = 0; return(NULL);}
75
76
if(fodim == 1)
77
{
78
if( (erg = (matrix_TYP **)malloc(1 *sizeof(matrix_TYP *))) == NULL)
79
{
80
printf("malloc of 'erg' in 'invar_space' failed\n");
81
exit(2);
82
}
83
erg[0] = init_mat(dim,dim,"");
84
startmat = init_mat(dim,dim,"");
85
if(symm_opt == -1 && dim > 1)
86
{ startmat->array.SZ[0][1] = -1;
87
startmat->array.SZ[1][0] = 1;
88
}
89
else
90
startmat->array.SZ[0][0] = 1;
91
erg[0] = rform(B, Banz, startmat, epsilon);
92
free_mat(startmat);
93
*anz = 1;
94
return(erg);
95
}
96
97
pm = init_mat(fodim+1, dd, "");
98
startmat = init_mat(dim, dim, "");
99
for(i=0;i<fodim+1;i++)
100
{
101
if(symm_opt == 0)
102
{
103
for(j=0;j<dim;j++)
104
for(k=0;k<dim;k++)
105
{
106
r = rand();
107
r %= 2;
108
startmat->array.SZ[j][k] = r;
109
}
110
}
111
if(symm_opt == 1)
112
{
113
for(j=0;j<dim;j++)
114
/* tilman: changed 14/5/97 from
115
for(k=0;k<=i;k++) to: */
116
for(k=0;k<=j;k++)
117
{
118
r = rand();
119
r %= 2;
120
startmat->array.SZ[j][k] = r;
121
startmat->array.SZ[k][j] = r;
122
}
123
}
124
if(symm_opt == -1)
125
{
126
for(j=0;j<dim;j++)
127
for(k=0;k<i;k++)
128
{
129
r = rand();
130
r %= 2;
131
startmat->array.SZ[j][k] = r;
132
startmat->array.SZ[k][j] = -r;
133
}
134
for(j=0;j<dim;j++)
135
startmat->array.SZ[j][j] = 0;
136
}
137
invar = rform(B, Banz, startmat, epsilon);
138
if(symm_opt == 0)
139
{
140
l = 0;
141
for(j=0;j<dim;j++)
142
for(k=0;k<dim;k++)
143
{ pm->array.SZ[i][l] = invar->array.SZ[j][k]; l++;}
144
}
145
if(symm_opt == 1)
146
{
147
l = 0;
148
for(j=0;j<dim;j++)
149
for(k=0;k<=j;k++)
150
{ pm->array.SZ[i][l] = invar->array.SZ[j][k]; l++;}
151
}
152
153
/* changed 18/12/96 tilman from:
154
if(symm_opt == 1)
155
to: */
156
if(symm_opt == (-1))
157
{
158
l = 0;
159
for(j=0;j<dim;j++)
160
for(k=0;k<j;k++)
161
{ pm->array.SZ[i][l] = invar->array.SZ[j][k]; l++;}
162
}
163
free_mat(invar);
164
}
165
free_mat(startmat);
166
167
/* output for debugging purposes
168
put_mat(pm,NULL,"in invar_space, pm",2); */
169
170
pm1 = long_rein_mat(pm);
171
172
/* output for debugging purposes
173
put_mat(pm1,NULL,"in invar_space, pm1",2); */
174
175
free_mat(pm);
176
177
/* changed 18/12/96 tilman from
178
ff = pm->rows;
179
to */
180
ff = pm1->rows;
181
182
*anz = ff;
183
if( (erg = (matrix_TYP **)malloc(ff *sizeof(matrix_TYP *))) == NULL)
184
{
185
printf("malloc of 'erg' in 'invar_space' failed\n");
186
exit(2);
187
}
188
for(i=0; i<ff;i++)
189
{
190
erg[i] = init_mat(dim,dim,"");
191
l=0;
192
if(symm_opt == 0)
193
{
194
for(j=0;j<dim;j++)
195
for(k=0;k<dim;k++)
196
{ erg[i]->array.SZ[j][k] = pm1->array.SZ[i][l]; l++;}
197
}
198
if(symm_opt == 1)
199
{
200
for(j=0;j<dim;j++)
201
for(k=0;k<=j;k++)
202
{
203
erg[i]->array.SZ[j][k] = pm1->array.SZ[i][l];
204
erg[i]->array.SZ[k][j] = pm1->array.SZ[i][l];
205
l++;
206
}
207
}
208
if(symm_opt == -1)
209
{
210
for(j=0;j<dim;j++)
211
for(k=0;k<j;k++)
212
{
213
erg[i]->array.SZ[j][k] = pm1->array.SZ[i][l];
214
erg[i]->array.SZ[k][j] = pm1->array.SZ[i][l];
215
l++;
216
}
217
for(j=0;j<dim;j++)
218
erg[i]->array.SZ[j][j] = 0;
219
}
220
Check_mat(erg[i]);
221
}
222
for(i=0;i<ff;i++)
223
{
224
for(j=0;j<dim && erg[i]->array.SZ[j][j] == 0; j++);
225
if(j<dim && erg[i]->array.SZ[j][j] < 0)
226
{
227
for(k=0;k<dim;k++)
228
for(l=0;l<dim;l++)
229
erg[i]->array.SZ[k][l] = -erg[i]->array.SZ[k][l];
230
}
231
}
232
free_mat(pm1);
233
return(erg);
234
}
235
236