void interactive_pga(Logical group_present, FILE *StartFile, int group_nmr, int ***auts, struct pga_vars *pga, struct pcp_vars *pcp) { struct pga_vars flag; int option; Logical soluble_group = TRUE; FILE *OutputFile = 0; FILE *LINK_input = 0; char *StartName = 0; int t; int **perms = 0; int index; int **S = 0; int k; int K; int label; int *a = 0, *b = 0; char *c = 0; int *orbit_length = 0; int nmr_of_exponents; int *subset = 0; int alpha; int upper_step; int rep; int i; list_interactive_pga_menu(); do { option = read_option(MAX_INTERACTIVE_OPTION); switch (option) { case -1: list_interactive_pga_menu(); break; case SUPPLY_AUTS: auts = read_auts(PGA, &pga->m, &nmr_of_exponents, pcp); #ifdef HAVE_GMP autgp_order(pga, pcp); #endif pga->soluble = TRUE; start_group(&StartFile, auts, pga, pcp); break; case EXTEND_AUTS: extend_automorphisms(auts, pga->m, pcp); print_auts(pga->m, pcp->lastg, auts, pcp); break; case RESTORE_GP: StartName = GetString("Enter input file name: "); StartFile = OpenFileInput(StartName); if (StartFile != NULL) { read_value(TRUE, "Which group? ", &group_nmr, 0); auts = restore_group(TRUE, StartFile, group_nmr, pga, pcp); RESET(StartFile); } break; case DISPLAY_GP: print_presentation(FALSE, pcp); print_structure(1, pcp->lastg, pcp); print_pcp_relations(pcp); break; case SINGLE_STAGE: t = runTime(); if (group_present && pga->m == 0) start_group(&StartFile, auts, pga, pcp); assert(OutputFile); construct(1, &flag, SINGLE_STAGE, OutputFile, StartFile, 0, ALL, group_nmr, pga, pcp); t = runTime() - t; printf("Time for intermediate stage is %.2f seconds\n", t * CLK_SCALE); break; case DEGREE: read_step_size(pga, pcp); read_subgroup_rank(&k); query_exponent_law(pga); enforce_laws(pga, pga, pcp); extend_automorphisms(auts, pga->m, pcp); step_range(k, &pga->s, &upper_step, auts, pga, pcp); if (pga->s > upper_step) printf("Desired step size is invalid for current group\n"); else { if (pga->s < upper_step) { printf("The permitted relative step sizes range from %d to %d\n", pga->s, upper_step); read_value( TRUE, "Input the chosen relative step size: ", &pga->s, 0); } store_definition_sets(pga->r, pga->s, pga->s, pga); get_definition_sets(pga); pga->print_degree = TRUE; compute_degree(pga); pga->print_degree = FALSE; } break; case PERMUTATIONS: if (pga->Degree != 0) { t = runTime(); query_solubility(pga); pga->trace = FALSE; if (pga->soluble) query_space_efficiency(pga); else pga->space_efficient = FALSE; query_perm_information(pga); strip_identities(auts, pga, pcp); soluble_group = (pga->soluble || pga->Degree == 1 || pga->nmr_of_perms == 0); if (!soluble_group) { #if defined(GAP_LINK) StartGapFile(pga); #else #if defined(GAP_LINK_VIA_FILE) start_GAP_file(&LINK_input, auts, pga, pcp); #endif #endif } perms = permute_subgroups(LINK_input, &a, &b, &c, auts, pga, pcp); #if defined(GAP_LINK_VIA_FILE) if (!soluble_group) CloseFile(LINK_input); #endif t = runTime() - t; printf("Time to compute permutations is %.2f seconds\n", t * CLK_SCALE); } else printf("You must first select option %d\n", DEGREE); break; case ORBITS: orbit_option(option, perms, &a, &b, &c, &orbit_length, pga); break; case STABILISERS: case STABILISER: assert(perms); stabiliser_option( option, auts, perms, a, b, c, orbit_length, pga, pcp); /* free_space (pga->soluble, perms, orbit_length, a, b, c, pga); */ break; case MATRIX_TO_LABEL: S = allocate_matrix(pga->s, pga->q, 0, FALSE); subset = allocate_vector(pga->s, 0, FALSE); printf("Input the %d x %d subgroup matrix:\n", pga->s, pga->q); read_matrix(S, pga->s, pga->q); K = echelonise_matrix(S, pga->s, pga->q, pga->p, subset, pga); printf("The standard matrix is:\n"); print_matrix(S, pga->s, pga->q); printf("The label is %d\n", subgroup_to_label(S, K, subset, pga)); free_vector(subset, 0); break; case LABEL_TO_MATRIX: read_value(TRUE, "Input allowable subgroup label: ", &label, 1); S = label_to_subgroup(&index, &subset, label, pga); printf("The corresponding standard matrix is\n"); print_matrix(S, pga->s, pga->q); break; case IMAGE: t = runTime(); /* invert_automorphisms (auts, pga, pcp); print_auts (pga->m, pcp->lastg, auts, pcp); */ printf("Input the subgroup label and automorphism number: "); read_value(TRUE, "", &label, 1); read_value(FALSE, "", &alpha, 1); printf("Image is %d\n", find_image(label, auts[alpha], pga, pcp)); t = runTime() - t; printf("Computation time in seconds is %.2f\n", t * CLK_SCALE); break; case SUBGROUP_RANK: read_subgroup_rank(&k); printf("Closure of initial segment subgroup has rank %d\n", close_subgroup(k, auts, pga, pcp)); break; case ORBIT_REP: printf("Input label for subgroup: "); read_value(TRUE, "", &label, 1); rep = abs(a[label]); for (i = 1; i <= pga->nmr_orbits && pga->rep[i] != rep; ++i) ; printf("Subgroup with label %d has representative %d and is in orbit " "%d\n", label, rep, i); break; case COMPACT_DESCRIPTION: Compact_Description = TRUE; read_value(TRUE, "Lower bound for order (0 for all groups generated)? ", &Compact_Order, 0); break; case AUT_CLASSES: t = runTime(); permute_elements(); t = runTime() - t; printf("Time to compute orbits is %.2f seconds\n", t * CLK_SCALE); break; /* printf ("Input label: "); scanf ("%d", &l); process_complete_orbit (a, l, pga, pcp); break; case TEMP: printf ("Input label: "); scanf ("%d", &l); printf ("Input label: "); scanf ("%d", &u); for (i = l; i <= u; ++i) { x = IsValidAllowableSubgroup (i, pga); printf ("%d is %d\n", i, x); } StartName = GetString ("Enter output file name: "); OutputFile = OpenFileOutput (StartName); part_setup_reps (pga->rep, pga->nmr_orbits, orbit_length, perms, a, b, c, auts, OutputFile, OutputFile, pga, pcp); list_word (pga, pcp); read_value (TRUE, "Input the rank of the subgroup: ", &pga->q, 1); strip_identities (auts, pga, pcp); break; */ case EXIT: case MAX_INTERACTIVE_OPTION: printf("Exiting from interactive p-group generation menu\n"); break; } /* switch */ } while (option != 0 && option != MAX_INTERACTIVE_OPTION); #if defined(GAP_LINK) if (!soluble_group) QuitGap(); #endif }
void isom_options (int format, struct pcp_vars *pcp) { register int *y = y_address; FILE *Status; FILE *FileName; FILE *Subgroup; struct pga_vars pga; Logical user_supplied = FALSE; Logical group_present = FALSE; Logical identity_map; Logical finished; Logical valid; Logical equal; int output = DEFAULT_STANDARD_PRINT; int start_class, final_class; int option; int t; int status; int complete; int iteration; int *seq1; int *seq2; int len1, len2; int nmr_items; int ***auts; int x_dim, y_dim; FILE * GAP_library; char *name; int nmr_of_exponents; StandardPresentation = TRUE; pga.nmr_soluble = 0; list_isom_menu (); do { option = read_option (MAXOPTION); switch (option) { case -1: list_isom_menu (); break; case START_INFO: t = runTime (); group_present = setup_start_info (FALSE, 0, stdin, format, &pga, pcp); handle_error (group_present); user_supplied = TRUE; t = runTime () - t; /* it is possible that the p-quotient is trivial */ if (pcp->cc == 0) { group_present = FALSE; break; } printf ("Class %d %d-quotient and its %d-covering group computed in %.2f seconds\n", pcp->cc - 1, pcp->p, pcp->p, t * CLK_SCALE); break; case CONSTRUCT: if (!user_supplied) { name = GetString ("Enter input file name for group information: "); FileName = OpenFile (name, "r"); if (FileName == NULL) break; } name = GetString ("Enter output file name for group information: "); read_value (TRUE, "Standardise presentation to what class? ", &final_class, 0); if (user_supplied && final_class < pcp->cc) { printf ("Value supplied for end class must be at least %d\n", pcp->cc); } /* read in data from file and set up group to end of start_class and compute its p-covering group */ if (!user_supplied) { group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); if (final_class < pcp->cc) { CloseFile (FileName); printf ("Value supplied for end class must be at least %d\n", pcp->cc); } } if (pcp->cc == 0) { printf ("%d-quotient is trivial\n", pcp->p); break; } complete = (pcp->newgen == 0) ? TERMINAL : CAPABLE; iteration = 0; for (start_class = pcp->cc; start_class <= final_class && complete != TERMINAL; ++start_class) { t = runTime (); identity_map = FALSE; Subgroup = OpenFile ("ISOM_Subgroup", "w"); do { ++iteration; set_defaults (&pga); /* pga.space_efficient = TRUE; */ /* either prompt for information or read it from file */ if (user_supplied) { auts = read_auts (STANDARDISE, &pga.m, &nmr_of_exponents, pcp) ; pga.fixed = 0; query_solubility (&pga); user_supplied = FALSE; #ifdef HAVE_GMP autgp_order (&pga, pcp); #endif } else { auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); } x_dim = pga.m; y_dim = pcp->lastg; /* construct standard presentation relative to smallest permissible characteristic subgroup in p-multiplicator */ standard_presentation (&identity_map, output, auts, &pga, pcp); free_array (auts, x_dim, y_dim, 1); /* was the characteristic subgroup chosen in this iteration the whole of the p-multiplicator? */ Status = OpenFile ("ISOM_Status", "r"); fscanf (Status, "%d", &status); fscanf (Status, "%d", &complete); CloseFile (Status); /* have we finished the construction? */ finished = (status == END_OF_CLASS && (start_class == final_class || complete == TERMINAL)); /* organise to write modified presentation + automorphisms to file ISOM_PP */ if (!identity_map || finished) { copy_file( "ISOM_present", "ISOM_PP" ); append_file( "ISOM_NextClass", "ISOM_PP" ); } else copy_file( "ISOM_NextClass", "ISOM_PP" ); if (finished) break; /* if necessary, set up new presentation + other information */ FileName = OpenFile ("ISOM_PP", "r"); group_present = setup_start_info (identity_map, status, FileName, FILE_INPUT, &pga, pcp); handle_error (group_present); /* if appropriate, factor subgroup from p-multiplicator */ if (status != END_OF_CLASS) factor_subgroup (pcp); /* reinitialise pga structure */ initialise_pga (&pga, pcp); pga.m = 0; pga.ndgen = y[pcp->clend + 1]; set_values (&pga, pcp); } while (status != END_OF_CLASS && complete != TERMINAL); CloseFile (Subgroup); /* the group may have completed only when relations are enforced; this is an attempt to determine this case */ if (pga.nuclear_rank != 0 && pcp->complete) break; t = runTime () - t; printf ("Computing standard presentation for class %d took %.2f seconds\n", start_class, t * CLK_SCALE); } /* we currently may have presentation for p-covering group; or is the starting group terminal? if so, we may want to use last_class to revert to group presentation */ if (!user_supplied && iteration == 0 && !pcp->complete) last_class (pcp); /* is the group terminal? */ if (complete == TERMINAL) printf ("The largest %d-quotient of the group has class %d\n", pcp->p, pcp->cc); if (iteration == 0) break; /* rename file ISOM_PP containing iteration info to nominated file */ rename( "ISOM_PP", name ); break; case PRINT_PCP: if (group_present) print_presentation (TRUE, pcp); break; case SAVE_PRES: name = GetString ("Enter output file name: "); FileName = OpenFileOutput (name); if (group_present && FileName != NULL) { save_pcp (FileName, pcp); CloseFile (FileName); printf ("Presentation written to file\n"); } break; case COMPARE: valid = get_description ("Enter file name storing first presentation: ", &len1, &seq1, pcp); if (!valid) break; valid = get_description ("Enter file name storing second presentation: ", &len2, &seq2, pcp); if (!valid) break; equal = (len1 == len2) ? compare_sequences (seq1, seq2, len1): FALSE; printf ("Identical presentations? %s\n", equal == TRUE ? "True" : "False"); free_vector (seq1, 1); free_vector (seq2, 1); break; case STANDARD_PRINT_LEVEL: read_value (TRUE, "Input print level for construction (0-2): ", &output, 0); /* allow user to supply same max print level as for p-quotient calculations */ if (output == MAX_STANDARD_PRINT + 1) --output; if (output > MAX_STANDARD_PRINT) { printf ("Print level must lie between %d and %d\n", MIN_STANDARD_PRINT, MAX_STANDARD_PRINT); output = DEFAULT_STANDARD_PRINT; } break; case PQ_MENU: options (ISOM_MENU, format, pcp); break; case ISOM_OPTION: FileName = OpenFile (name, "r"); group_present = setup_start_info (FALSE, 0, FileName, FILE_INPUT, &pga, pcp); pcp->multiplicator_rank = pcp->lastg - y[pcp->clend + pcp->cc-1]; last_class (pcp); auts = read_auts_from_file (FileName, &pga.m, pcp); nmr_items = fscanf (FileName, "%d", &pga.fixed); verify_read (nmr_items, 1); nmr_items = fscanf (FileName, "%d", &pga.soluble); verify_read (nmr_items, 1); printf ("Images of user-supplied generators are listed last below\n"); print_map (pcp); #ifdef HAVE_GMP fscanf (FileName, "\n"); mpz_init (&pga.aut_order); mpz_inp_str (&pga.aut_order, FileName, 10); #endif CloseFile (FileName); GAP_library = OpenFile ("GAP_library", "a+"); write_GAP_library (GAP_library, pcp); pga.nmr_centrals = pga.m; pga.nmr_stabilisers = 0; GAP_auts (GAP_library, auts, auts, &pga, pcp); CloseFile (GAP_library); printf ("Presentation listing images of user-supplied generators written to GAP_library\n"); break; case EXIT: case MAXOPTION: unlink( "ISOM_present" ); unlink( "ISOM_Subgroup" ); unlink( "ISOM_cover_file" ); unlink( "ISOM_group_file" ); unlink( "ISOM_XX" ); unlink( "ISOM_NextClass" ); unlink( "ISOM_Status" ); printf ("Exiting from ANU p-Quotient Program\n"); break; } /* switch */ } while (option != 0 && option != MAXOPTION); }