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

563642 views
1
#include "typedef.h"
2
#include "matrix.h"
3
#include "voronoi.h"
4
#include "polyeder.h"
5
#include "tools.h"
6
#include "bravais.h"
7
8
/**********************************************************************\
9
@
10
@--------------------------------------------------------------------
11
@ FILE: all_vor_neighbours.c
12
@--------------------------------------------------------------------
13
@
14
\**********************************************************************/
15
16
17
18
/**********************************************************************\
19
@ matrix_TYP *all_voronoi_neighbours(P, G, Ftr, tr_bifo)
20
@ matrix_TYP *P, **Ftr, *tr_bifo;
21
@ bravais_TYP *G;
22
@--------------------------------------------------------------------
23
@
24
@ The arguments of 'all_voronoi_neighbours' are:
25
@ P: a G-perfect form
26
@ G: the group for which P is G-perfect
27
@ Ftr: a basis for the integral forms in the formspace of G^{tr}
28
@ trbifo: The matrix of the bilinear form
29
@ F(G)xF(G^{tr})--> R: (A,B)---> trace(AB)
30
@ with respect to the Z-bases given by G->form and Ftr
31
@ Let Fdim be the dimension of the formspace of G and m be the number of
32
@ G-perfect forms that are neighbours of P.
33
@ Then the result of 'all_perfect_neighbours' is a matrix N with m rows
34
@ and Fdim+3 columns.
35
@ For 0 < i< m let R[i] be the form in F(G) represented by the
36
@ first Fdim entries of the i-th row of N, t.m.
37
@ R[i] = N[i][0] * G->form[0] + ..... + N[i][Fdim-1] * G->form[Fdim-1]
38
@ Further let
39
@ p[i] := N[i][Fdim], r[i] := N[i][Fdim+1], c[i] := N[i][Fdim+2]
40
@ Then P[i] := (p[i]*P + r[i]*R[i]) / c[i]
41
@ is a G-perfect form neighboured to P.
42
@--------------------------------------------------------------------
43
@
44
\**********************************************************************/
45
matrix_TYP *all_voronoi_neighbours(P, G, Ftr, tr_bifo)
46
matrix_TYP *P, **Ftr, *tr_bifo;
47
bravais_TYP *G;
48
{
49
int i,j,k,l, Fdim, Gdim;
50
int Pmin, Vanz, Wanz;
51
matrix_TYP *erg;
52
matrix_TYP **V, *N, *X;
53
polyeder_TYP *pol;
54
wall_TYP **W;
55
int *ww, *pw;
56
int pos, lc, rc, g;
57
58
59
Fdim = G->form_no;
60
Gdim = G->form[0]->cols;
61
/**********************************************************************\
62
| calculate the vertices of the Voronoidomain in F(G^{tr})
63
| and the forms in F(G) corresponding to the walls of the Voronoidomain.
64
| The coordinates of these forms with respect to the basis given in G->form
65
| are obtained as the coordinates of the vetrices of the polyeder_TYP *pol.
66
\**********************************************************************/
67
V = voronoi_vertices(P, G, &Vanz, &Pmin, &i);
68
Wanz = Vanz;
69
if( (W = (wall_TYP **)malloc(Wanz *sizeof(wall_TYP *))) == NULL)
70
{
71
printf("malloc of W failed in all_perfect_neighbours\n");
72
exit(2);
73
}
74
if( (ww = (int *)malloc(Fdim *sizeof(int))) == NULL)
75
{
76
printf("malloc of ww failed in all_perfect_neighbours\n");
77
exit(2);
78
}
79
if( (pw = (int *)malloc(Fdim *sizeof(int))) == NULL)
80
{
81
printf("malloc of pw failed in all_perfect_neighbours\n");
82
exit(2);
83
}
84
for(i=0;i<Vanz;i++)
85
{
86
W[i] = init_wall(Fdim);
87
form_to_vec(ww, V[i], Ftr, Fdim, &k);
88
for(j=0;j<Fdim; j++)
89
for(k=0;k<Fdim; k++)
90
W[i]->gl[j] += ww[k] * tr_bifo->array.SZ[j][k];
91
normal_wall(W[i]);
92
free_mat(V[i]);
93
}
94
free(V);
95
pol = first_polyeder(W, Wanz);
96
if(pol == NULL)
97
{
98
printf("Error in all_perfect_neighbours: P not G-perfekt\n");
99
exit(3);
100
}
101
for(i=0;i<Wanz;i++)
102
{
103
refine_polyeder(pol, W[i]);
104
free_wall(&W[i]);
105
}
106
free(W);
107
108
/*
109
put_polyeder(pol);
110
*/
111
112
/******************************************************************\
113
| Each G-perfect form A, that is a neighbour of P, is (up to
114
| multiplication with a positive scalar) given by
115
| N = lc *P + rc * X,
116
| where X is a form defined by a vertex of the polyeder pol.
117
| The coefficients are calculated with the function 'voronoi_neighbour'.
118
\******************************************************************/
119
form_to_vec(pw, P, G->form, Fdim, &k);
120
erg = init_mat(pol->vert_no, (Fdim+3), "");
121
X = init_mat(Gdim, Gdim, "");
122
X->flags.Integral = X->flags.Symmetric = TRUE;
123
X->flags.Diagonal = FALSE;
124
pos = 0;
125
for(i=0;i<pol->vert_no;i++)
126
{
127
/******************************************************\
128
| Calculate X
129
\******************************************************/
130
for(j=0;j<Gdim;j++)
131
for(k=0;k<=j;k++)
132
{
133
X->array.SZ[j][k] = 0;
134
for(l=0;l<Fdim;l++)
135
X->array.SZ[j][k] +=pol->vert[i]->v[l] * G->form[l]->array.SZ[j][k];
136
X->array.SZ[k][j] = X->array.SZ[j][k];
137
}
138
N = voronoi_neighbour(P, X, Pmin, &lc, &rc);
139
/******************************************************\
140
| Divide N by the greatest common divisor of its entries
141
\******************************************************/
142
if(N != NULL)
143
{
144
for(j=0;j<Fdim;j++)
145
erg->array.SZ[pos][j] = pol->vert[i]->v[j];
146
erg->array.SZ[pos][Fdim] = lc;
147
erg->array.SZ[pos][Fdim+1] = rc;
148
for(j=0;j<Fdim;j++)
149
ww[j] = lc * pw[j] + rc * erg->array.SZ[pos][j];
150
k = 0;
151
while(k<Fdim && ww[k] == 0)
152
k++;
153
g = ww[k];
154
for(j=k+1;j<Fdim;j++)
155
{
156
if(ww[j] != 0)
157
{
158
l = GGT(g, ww[j]);
159
g = l;
160
}
161
}
162
erg->array.SZ[pos][Fdim+2] = g;
163
free_mat(N);
164
pos++;
165
}
166
}
167
168
/* changed on 14/1/97 tilman from
169
erg->rows = pos;
170
to: */
171
real_mat(erg,pos,erg->cols);
172
173
free_mat(X);
174
free(pw); free(ww);
175
/*********************************
176
put_polyeder(pol);
177
***********************************/
178
free_polyeder(pol);
179
return(erg);
180
}
181
182