Ejemplo n.º 1
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);      
}
Ejemplo n.º 2
0
int echelon(struct pcp_vars *pcp)
{
   register int *y = y_address;

   register int i;
   register int j;
   register int k;
   register int p1;
   register int exp;
   register int redgen = 0;
   register int count = 0;
   register int factor;
   register int bound;
   register int offset;
   register int temp;
   register int value;
   register int free;

   register Logical trivial;
   register Logical first;

   register int p = pcp->p;
   register int pm1 = pcp->pm1;

#include "access.h"

   pcp->redgen = 0;
   pcp->eliminate_flag = FALSE;

   /* check that the relation is homogeneous of class pcp->cc */
   if (pcp->cc != 1) {
      offset = pcp->lused - 1;
      temp = pcp->lastg;
      for (i = 2, bound = pcp->ccbeg; i <= bound; i++) {
         if (y[offset + i] != y[offset + temp + i]) {
            text(6, pcp->cc, 0, 0, 0);
            pcp->eliminate_flag = TRUE;
            return -1;
         }
      }
   }

   /* compute quotient of the relations and store quotient as an exponent
      vector in y[pcp->lused + pcp->ccbeg] to y[pcp->lused + pcp->lastg] */
   k = 0;
   offset = pcp->lused;
   for (i = pcp->ccbeg, bound = pcp->lastg; i <= bound; i++) {
      y[offset + i] -= y[offset + bound + i];
      if ((j = y[offset + i])) {
         if (j < 0)
            y[offset + i] += p;
         k = i;
      }
   }

   if (k <= 0)
      return -1;

   /* print out the quotient of the relations */
   if (pcp->diagn) {
      /* a call to compact is not permitted at this point */
      if (pcp->lused + 4 * pcp->lastg + 2 < pcp->structure) {
         /* first copy relevant entries to new position in y */
         free = pcp->lused + 2 * pcp->lastg + 1;
         for (i = 1; i < pcp->ccbeg; ++i)
            y[free + i] = 0;
         for (i = pcp->ccbeg; i <= pcp->lastg; ++i)
            y[free + i] = y[pcp->lused + i];
         setup_word_to_print(
             "quotient relation", free, free + pcp->lastg + 1, pcp);
      }
   }

   first = TRUE;

   while (first || --k >= pcp->ccbeg) {
      /* does generator k occur in the unechelonised relation? */
      if (!first && y[pcp->lused + k] <= 0)
         continue;

      /* yes */
      first = FALSE;
      exp = y[pcp->lused + k];
      if ((i = y[pcp->structure + k]) <= 0) {
         if (i < 0) {
            /* generator k was previously redundant, so eliminate it */
            p1 = -y[pcp->structure + k];
            count = y[p1 + 1];
            offset = pcp->lused;
            for (i = 1; i <= count; i++) {
               value = y[p1 + i + 1];
               j = FIELD2(value);
               /* integer overflow can occur here; see comments in collect */
               y[offset + j] = (y[offset + j] + exp * FIELD1(value)) % p;
            }
         }
         y[pcp->lused + k] = 0;
      } else {
         /* generator k was previously irredundant; have we already
            found a generator to eliminate using this relation? */
         if (redgen > 0) {
            /* yes, so multiply this term by the appropriate factor
               and note that the value of redgen is not trivial */
            trivial = FALSE;
            /* integer overflow can occur here; see comments in collect */
            y[pcp->lused + k] = (y[pcp->lused + k] * factor) % p;
         } else {
            /* no, we will eliminate k using this relation */
            redgen = k;
            trivial = TRUE;

            /* we want to compute the value of k so we will multiply the
               rest of the relation by the appropriate factor;
               integer overflow can occur here; see comments in collect */
            factor = pm1 * invert_modp(exp, p);

/* we carry out this mod computation to reduce possibility
   of integer overflow */
#if defined(CAREFUL)
            factor = factor % p;
#endif
            y[pcp->lused + k] = 0;
         }
      }
   }

   if (redgen <= 0)
      return -1;
   else
      pcp->redgen = redgen;

   /* the relation is nontrivial; redgen is either trivial or redundant */

   if (trivial) {
      /* mark redgen as trivial */
      y[pcp->structure + redgen] = 0;

      if (pcp->fullop)
         text(3, redgen, 0, 0, 0);

      complete_echelon(1, redgen, pcp);
   } else {
      /* redgen has value in exponent form in y[pcp->lused + pcp->ccbeg]
         to y[pcp->lused + redgen(-1)] */
      count = 0;
      offset = pcp->lused;
      for (i = pcp->ccbeg; i <= redgen; i++)
         if (y[offset + i] > 0) {
            count++;
            y[offset + count] = PACK2(y[offset + i], i);
         }
      offset = pcp->lused + count + 1;
      for (i = 1; i <= count; i++)
         y[offset + 2 - i] = y[offset - i];

      /* set up the relation for redgen */
      y[pcp->lused + 1] = pcp->structure + redgen;
      y[pcp->lused + 2] = count;
      y[pcp->structure + redgen] = -(pcp->lused + 1);

      pcp->lused += count + 2;

      if (pcp->fullop)
         text(4, redgen, 0, 0, 0);

      complete_echelon(0, redgen, pcp);
   }

   pcp->eliminate_flag = TRUE;
   if (redgen < pcp->first_pseudo)
      pcp->newgen--;
   if (pcp->newgen != 0 || pcp->multiplicator)
      return count;

   /* group is completed because all actual generators are redundant,
      so it is not necessary to continue calculation of this class */
   pcp->complete = 1;
   last_class(pcp);

   if (pcp->fullop || pcp->diagn)
      text(5, pcp->cc, p, pcp->lastg, 0);

   return -1;
}