示例#1
0
void
restore_automorphisms(FILE *ifp, int **head, int **list, struct pcp_vars *pcp)
{
   int new_index = 0;
   int offset;
   register int alpha;
   int nmr_saved;
   int list_length;
   int retain;
   int nmr_items;

   nmr_items = fread(&nmr_saved, sizeof(int), 1, ifp);
   verify_read(nmr_items, 1);
   nmr_items = fread(&list_length, sizeof(int), 1, ifp);
   verify_read(nmr_items, 1);

   *head = allocate_vector(nmr_saved * pcp->m + 1, 0, FALSE);
   (*head)[0] = nmr_saved;

   *list = allocate_vector(list_length + 1, 0, FALSE);
   (*list)[0] = list_length;

   retain = MIN(pcp->lastg, nmr_saved);
   for (alpha = 1; alpha <= pcp->m; ++alpha) {
      offset = (alpha - 1) * retain;
      restore_auts(ifp, offset, nmr_saved, retain, &new_index, *head, *list);
   }
   (*head)[0] = retain;

   printf("Automorphisms read from file\n");
}
示例#2
0
int restore_auts(FILE *ifp,
                 int offset,
                 int nmr_saved,
                 int retain,
                 int *new_index,
                 int *head,
                 int *list)
{
   int alpha_length; /* length of the automorphism description */
   int i, add;
   int nmr_items;

   nmr_items = fread(head + offset + 1, sizeof(int), nmr_saved, ifp);
   verify_read(nmr_items, nmr_saved);

   add = *new_index - head[offset + 1];
   for (i = 1; i <= nmr_saved; ++i)
      head[offset + i] += add;

   nmr_items = fread(&alpha_length, sizeof(int), 1, ifp);
   verify_read(nmr_items, 1);
   nmr_items = fread(list + *new_index + 1, sizeof(int), alpha_length, ifp);
   verify_read(nmr_items, alpha_length);

   *new_index = head[offset + retain] + list[head[offset + retain] + 1] + 1;

   return alpha_length;
}
示例#3
0
void read_value (Logical newline, char *string, int *value, int lower_bound)
{
   char response[MAXWORD];
   Logical error;
   Logical reading = TRUE;
   int nmr_items;

   while (reading) {
      printf ("%s", string);
      nmr_items = scanf ("%s", response);
      verify_read (nmr_items, 1);

      /* read past any comments */
      while (response[0] == COMMENT) {
	 read_line ();
	 nmr_items = scanf ("%s", response);
	 verify_read (nmr_items, 1);
      }
      if (!isatty (0)) printf ("%s ", response);
      if (!isatty (0) && newline) printf ("\n");
      *value = string_to_int (response, &error);
      if (error) 
	 printf ("Error in input -- must be integer only\n");
      else if ((reading = (*value < lower_bound)))
	 printf ("Error: supplied value must be at least %d\n", lower_bound);

   }
}
示例#4
0
char* GetString (char *string)
{
   int nmr_items;
   char *s = (char *) malloc (MAXIDENT * sizeof (char));

   printf ("%s", string);

   nmr_items = scanf ("%s", s);
   verify_read (nmr_items, 1);
   while (s[0] == COMMENT) {
      read_line ();
      nmr_items = scanf ("%s", s);
      verify_read (nmr_items, 1);
   }
   if (!isatty (0)) printf ("%s\n", s);

   return s;
}
示例#5
0
void save_auts(FILE *ofp, int *head, int *list, struct pcp_vars *pcp)
{
   register int alpha;
   register int offset;
   register int required_offset;
   register int prev = 0;

   register int m = pcp->m;
   register int required_ptr, stored_ptr;
   int required_length, stored_length;
   register int original, diff;
   register int j;
   int list_length;
   int retain;

   int nmr_items;
   int *copy_head;

   /* the action on more than lastg generators may be stored in
      list; if this is the case, establish how many entries from
      the array list must be stored in order to retain the
      description of the automorphisms on lastg generators */

   original = head[0];

   if (head[0] > pcp->lastg) {
      copy_head = allocate_vector(pcp->lastg * m + 1, 0, FALSE);
      list_length = 0;
      retain = pcp->lastg;
      diff = 0;
      for (alpha = 1; alpha <= m; ++alpha) {
         offset = (alpha - 1) * original;
         required_offset = (alpha - 1) * retain;
         for (j = 1; j <= retain; ++j)
            copy_head[required_offset + j] = head[offset + j] - diff;

         required_ptr = head[offset + retain];
         stored_ptr = head[offset + original];
         stored_length = stored_ptr + list[stored_ptr + 1] + 1 - prev;
         required_length = required_ptr + list[required_ptr + 1] + 1 - prev;

         diff += stored_length - required_length;

         list_length += required_length;
         prev += stored_length;
      }
   } else {
      copy_head = head;
      retain = head[0];
      list_length = list[0];
   }

   prev = 0;

   nmr_items = fwrite(&retain, sizeof(int), 1, ofp);
   verify_read(nmr_items, 1);
   nmr_items = fwrite(&list_length, sizeof(int), 1, ofp);
   verify_read(nmr_items, 1);

   for (alpha = 1; alpha <= m; ++alpha) {
      offset = (alpha - 1) * original;
      required_offset = (alpha - 1) * retain;
      nmr_items =
          fwrite(copy_head + required_offset + 1, sizeof(int), retain, ofp);
      verify_read(nmr_items, retain);
      required_ptr = head[offset + retain];
      stored_ptr = head[offset + original];
      stored_length = stored_ptr + list[stored_ptr + 1] + 1 - prev;
      required_length = required_ptr + list[required_ptr + 1] + 1 - prev;
      nmr_items = fwrite(&required_length, sizeof(int), 1, ofp);
      verify_read(nmr_items, 1);
      nmr_items = fwrite(list + prev + 1, sizeof(int), required_length, ofp);
      verify_read(nmr_items, required_length);
      prev += stored_length;
   }

   if (original != retain)
      free_vector(copy_head, 0);

   RESET(ofp);
}
示例#6
0
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);      
}