withappropriateinitialvalues,thisproceduremaybe usedtocalculateacommutator;thealgorithmfindsa
solution generator by generator */
void find_commutator(
int cp1, int cp2, int cp3, int cp4, int result, struct pcp_vars *pcp)
{ register int *y = y_address;
int r;
int exp; register int i;
int str = pcp->lused + 1; register int p = pcp->p; register int lastg = pcp->lastg;
#include"access.h"
y[str] = 1;
for (i = 1; i <= lastg; ++i) {
/* compute r and adjust its value mod p */
r = (y[cp3 + i] + y[cp4 + i]) - (y[cp1 + i] + y[cp2 + i]); while (r < 0)
r += p; while (r >= p)
r -= p;
/* store the exponent of generator i in x */
y[result + i] = r;
/* now compute the new u_2 */
if (y[cp4 + i] != 0) {
y[str + 1] = PACK2(y[cp4 + i], i);
collect(-str + 1, cp3, pcp);
y[cp3 + i] = 0;
}
/* compute the residue mod p */
exp = y[cp2 + i] + r; while (exp < 0)
exp += p;
exp %= p;
/* now compute the new v_1 */
if (y[cp2 + i] + r >= p)
y[cp2 + i] = p - r;
if (r != 0) {
y[str + 1] = PACK2(r, i);
collect(-str + 1, cp2, pcp);
}
/* now compute the new u_1 */
if (y[cp1 + i] + exp >= p)
y[cp2 + i] = p - exp;
if (exp != 0) {
y[str + 1] = PACK2(exp, i);
collect(-str + 1, cp1, pcp);
}
}
}
/* copy a section of the array, y, to another part of y */
void copy(int old, int length, int new, struct pcp_vars *pcp)
{ register int *y = y_address;
/* calculate a power of a left-normed commutator of supplied depth byrepeatedcallstofind_commutator;setuptheresultasan exponentvectorwithbaseaddresspcp->lusedinordertopermit
the result to be handed to echelon easily */
void calculate_commutator(int format, struct pcp_vars *pcp)
{ register int *y = y_address;
register int ptr, cp1, cp2, cp3, cp4, result; register int lastg = pcp->lastg; register int total;
int disp = 0;
int type;
int depth;
int exp;
total = 6 * lastg + 6;
if (is_space_exhausted(total, pcp)) return;
/* read in next component, b, and set it up at cp1 and cp4 */
if (format == BASIC)
read_word(stdin, disp, type, pcp); else
pretty_read_word(stdin, disp, type, pcp);