CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418346
1
/****************************************************************************
2
**
3
*A commute_dgen.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 "constants.h"
13
#include "pq_functions.h"
14
#include "pretty_filterfns.h"
15
#include "word_types.h"
16
17
static void
18
collect_defining_generator_word(int ptr, int cp, struct pcp_vars *pcp);
19
20
/* calculate a power of a left-normed commutator of supplied depth
21
by repeated calls to find_commutator; set up the result as an
22
exponent vector with base address pcp->lused in order to permit
23
the result to be handed to echelon easily; each component
24
is a defining generator */
25
26
void commute_defining_generators(int format, struct pcp_vars *pcp)
27
{
28
register int *y = y_address;
29
30
register int ptr, cp1, cp2, cp3, cp4, result;
31
register int lastg = pcp->lastg;
32
register int total;
33
int disp = 0;
34
int type;
35
int depth;
36
int exp;
37
38
total = 6 * lastg + 6;
39
if (is_space_exhausted(total, pcp))
40
return;
41
42
cp1 = pcp->submlg - lastg - 2;
43
cp2 = cp1 - lastg;
44
cp3 = cp2 - lastg;
45
cp4 = cp3 - lastg;
46
result = cp4 - lastg;
47
ptr = pcp->lused + 1;
48
49
/* fudge the value of submlg because of possible call to power */
50
pcp->submlg -= total;
51
52
read_value(TRUE, "Input number of components of commutator: ", &depth, 2);
53
54
/* read in a and set it up at cp2 and cp3 */
55
type = FIRST_ENTRY;
56
57
if (format == BASIC)
58
read_word(stdin, disp, type, pcp);
59
else
60
pretty_read_word(stdin, disp, type, pcp);
61
62
collect_defining_generator_word(ptr, cp2, pcp);
63
copy(cp2, lastg, cp3, pcp);
64
65
type = NEXT_ENTRY;
66
disp = y[ptr] + 1;
67
68
while (--depth > 0) {
69
70
/* read in next component, b, and set it up at cp1 and cp4 */
71
if (format == BASIC)
72
read_word(stdin, disp, type, pcp);
73
else
74
pretty_read_word(stdin, disp, type, pcp);
75
76
collect_defining_generator_word(ptr + disp, cp1, pcp);
77
copy(cp1, lastg, cp4, pcp);
78
79
/* solve the equation (ba) * x = ab to obtain [a, b] */
80
find_commutator(cp1, cp2, cp3, cp4, result, pcp);
81
82
copy(result, lastg, cp2, pcp);
83
copy(result, lastg, cp3, pcp);
84
}
85
86
read_value(TRUE, "Input required power of this commutator: ", &exp, 1);
87
power(exp, result, pcp);
88
89
/* print the commutator */
90
setup_word_to_print("commutator", result, ptr, pcp);
91
92
/* copy result to pcp->lused */
93
copy(result, lastg, pcp->lused, pcp);
94
95
/* reset the value of submlg */
96
pcp->submlg += total;
97
}
98
99
/* collect word in defining generators stored as string at
100
y[ptr] and place the result as exponent vector at cp */
101
102
static void
103
collect_defining_generator_word(int ptr, int cp, struct pcp_vars *pcp)
104
{
105
register int *y = y_address;
106
107
int i, generator, genval;
108
#if defined(DEBUG)
109
int j, word_len;
110
#endif
111
int length, exp;
112
register int lastg = pcp->lastg;
113
114
/* zero out lastg entries in array in order to store result */
115
for (i = 1; i <= lastg; ++i)
116
y[cp + i] = 0;
117
118
length = y[ptr];
119
for (i = 1; i < length; ++i) {
120
generator = y[ptr + 1 + i];
121
genval = y[pcp->dgen + generator];
122
123
#if defined(DEBUG)
124
if (genval > 0)
125
printf("%d %d\n", generator, genval);
126
else if (genval < 0) {
127
printf("%d %d ", generator, y[-genval]);
128
word_len = y[-genval + 1];
129
for (j = 1; j <= word_len; ++j)
130
printf(" %d", y[-genval + 1 + j]);
131
};
132
if (genval == 0)
133
printf("No defining generator %d -- taken to be the identity\n",
134
generator);
135
#endif
136
137
collect(genval, cp, pcp);
138
}
139
140
/* calculate power of this word */
141
exp = y[ptr + 1];
142
power(exp, cp, pcp);
143
144
#if defined(DEBUG)
145
print_array(y, cp, cp + pcp->lastg + 1);
146
#endif
147
}
148
149
/* prepare to collect word in defining generators */
150
151
void setup_defgen_word_to_collect(
152
FILE *file, int format, int type, int cp, struct pcp_vars *pcp)
153
{
154
int disp = pcp->lastg + 2;
155
register int ptr;
156
157
ptr = pcp->lused + 1 + disp;
158
159
if (format == BASIC)
160
read_word(file, disp, type, pcp);
161
else
162
pretty_read_word(file, disp, type, pcp);
163
164
collect_defining_generator_word(ptr, cp, pcp);
165
166
if (type == ACTION || file != stdin)
167
return;
168
169
setup_word_to_print("result of collection", cp, ptr, pcp);
170
}
171
172