1 /****************************************************************************
2 **
3 *A  check_exponent.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 "exp_vars.h"
15 
16 /* determine whether trial value is upper bound on exponent of the
17    group; do this by checking that all test words are trivial */
18 
check_exponent(int trial_exponent,struct exp_vars * exp_flag,struct pcp_vars * pcp)19 Logical check_exponent(int trial_exponent,
20                        struct exp_vars *exp_flag,
21                        struct pcp_vars *pcp)
22 {
23    int known_exponent;
24 
25    initialise_exponent(exp_flag, pcp);
26    exp_flag->check_exponent = TRUE;
27    exp_flag->all_trivial = TRUE;
28 
29    known_exponent = pcp->extra_relations;
30    if (known_exponent)
31       return known_exponent == trial_exponent;
32    pcp->extra_relations = trial_exponent;
33 
34    /* now generate and power all test words */
35    extra_relations(exp_flag, pcp);
36 
37    /* restore existing exponent law */
38    pcp->extra_relations = known_exponent;
39 
40    /* if trivial flag is true, we have (upper bound on) exponent */
41    return exp_flag->all_trivial;
42 }
43