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

563477 views
1
/****************************************************************************
2
**
3
*A commutator.c ANUPQ source Eamonn O'Brien
4
**
5
*Y Copyright 1995-2001, Lehrstuhl D fuer Mathematik, RWTH Aachen, Germany
6
*Y Copyright 1995-2001, School of Mathematical Sciences, ANU, Australia
7
**
8
*/
9
10
#include "pq_defs.h"
11
#include "pcp_vars.h"
12
#include "pretty_filterfns.h"
13
#include "word_types.h"
14
#include "constants.h"
15
16
/* calculate a solution, x, to the equation
17
18
u_1 * v_1 * x = u_2 * v_2
19
20
where u_1, v_1, u_2, v_2 are exponent vectors with
21
base addresses cp1, cp2, cp3, cp4, respectively;
22
23
the result is stored as an exponent vector with address result;
24
25
with appropriate initial values, this procedure may be
26
used to calculate a commutator; the algorithm finds a
27
solution generator by generator */
28
29
void find_commutator(
30
int cp1, int cp2, int cp3, int cp4, int result, struct pcp_vars *pcp)
31
{
32
register int *y = y_address;
33
int r;
34
int exp;
35
register int i;
36
int str = pcp->lused + 1;
37
register int p = pcp->p;
38
register int lastg = pcp->lastg;
39
40
#include "access.h"
41
42
y[str] = 1;
43
44
for (i = 1; i <= lastg; ++i) {
45
46
/* compute r and adjust its value mod p */
47
r = (y[cp3 + i] + y[cp4 + i]) - (y[cp1 + i] + y[cp2 + i]);
48
while (r < 0)
49
r += p;
50
while (r >= p)
51
r -= p;
52
53
/* store the exponent of generator i in x */
54
y[result + i] = r;
55
56
/* now compute the new u_2 */
57
if (y[cp4 + i] != 0) {
58
y[str + 1] = PACK2(y[cp4 + i], i);
59
collect(-str + 1, cp3, pcp);
60
y[cp3 + i] = 0;
61
}
62
63
/* compute the residue mod p */
64
exp = y[cp2 + i] + r;
65
while (exp < 0)
66
exp += p;
67
exp %= p;
68
69
/* now compute the new v_1 */
70
if (y[cp2 + i] + r >= p)
71
y[cp2 + i] = p - r;
72
if (r != 0) {
73
y[str + 1] = PACK2(r, i);
74
collect(-str + 1, cp2, pcp);
75
}
76
77
/* now compute the new u_1 */
78
if (y[cp1 + i] + exp >= p)
79
y[cp2 + i] = p - exp;
80
if (exp != 0) {
81
y[str + 1] = PACK2(exp, i);
82
collect(-str + 1, cp1, pcp);
83
}
84
}
85
}
86
87
/* copy a section of the array, y, to another part of y */
88
89
void copy(int old, int length, int new, struct pcp_vars *pcp)
90
{
91
register int *y = y_address;
92
93
for (; length > 0; --length)
94
y[new + length] = y[old + length];
95
}
96
97
/* calculate a power of a left-normed commutator of supplied depth
98
by repeated calls to find_commutator; set up the result as an
99
exponent vector with base address pcp->lused in order to permit
100
the result to be handed to echelon easily */
101
102
void calculate_commutator(int format, struct pcp_vars *pcp)
103
{
104
register int *y = y_address;
105
106
register int ptr, cp1, cp2, cp3, cp4, result;
107
register int lastg = pcp->lastg;
108
register int total;
109
int disp = 0;
110
int type;
111
int depth;
112
int exp;
113
114
total = 6 * lastg + 6;
115
if (is_space_exhausted(total, pcp))
116
return;
117
118
cp1 = pcp->submlg - lastg - 2;
119
cp2 = cp1 - lastg;
120
cp3 = cp2 - lastg;
121
cp4 = cp3 - lastg;
122
result = cp4 - lastg;
123
ptr = pcp->lused + 1;
124
125
/* fudge the value of submlg because of possible call to power */
126
pcp->submlg -= total;
127
128
read_value(TRUE, "Input number of components of commutator: ", &depth, 2);
129
130
/* read in a and set it up at cp2 and cp3 */
131
type = FIRST_ENTRY;
132
133
if (format == BASIC)
134
read_word(stdin, disp, type, pcp);
135
else
136
pretty_read_word(stdin, disp, type, pcp);
137
138
collect_word(ptr, cp2, pcp);
139
copy(cp2, lastg, cp3, pcp);
140
141
type = NEXT_ENTRY;
142
disp = y[ptr] + 1;
143
144
while (--depth > 0) {
145
146
/* read in next component, b, and set it up at cp1 and cp4 */
147
if (format == BASIC)
148
read_word(stdin, disp, type, pcp);
149
else
150
pretty_read_word(stdin, disp, type, pcp);
151
152
collect_word(ptr + disp, cp1, pcp);
153
copy(cp1, lastg, cp4, pcp);
154
155
/* solve the equation (ba) * x = ab to obtain [a, b] */
156
find_commutator(cp1, cp2, cp3, cp4, result, pcp);
157
158
copy(result, lastg, cp2, pcp);
159
copy(result, lastg, cp3, pcp);
160
}
161
162
read_value(TRUE, "Input required power of this commutator: ", &exp, 1);
163
power(exp, result, pcp);
164
165
/* print the commutator */
166
setup_word_to_print("commutator", result, ptr, pcp);
167
168
/* copy result to pcp->lused */
169
copy(result, lastg, pcp->lused, pcp);
170
171
/* reset the value of submlg */
172
pcp->submlg += total;
173
}
174
175