GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "ZZ.h"1#include "bravais.h"23int INFO_LEVEL;4extern int SFLAG;5int IDEM_NO;6boolean GRAPH = FALSE;78extern char *optarg;9extern int optind;10FILE *outputfile;1112void ZZ_usage (progname)13char *progname;14{15printf("Usage: %s 'file1' ['file2'] [-b] [-g] [-h] [-l=<#level>] \n"16,progname);17printf(" [-m] [-n=<#number>] [-p] [-q] [-r] [-s] [-t=out] [-u]\n");18printf("\n");19printf("file1: bravais_TYP containing a finite unimodular group G,\n");20printf(" ending with the order of G.\n");21printf("file2: (OPTIONAL) matrix_TYP containing the Gram matrix of a symmetric \n");22printf(" positive definite G-invariant bilinear form. This form is\n");23printf(" used for reduction purposes only. If this file is not\n");24printf(" given, the program computes such a form. In particular\n");25printf(" the forms possibly given in 'file1' are ignored.\n");26printf("\n");27printf("Calculates the the G-sublattices of the natural lattice Z^n of\n");28printf("finite index, the prime divisors of which divide the order of G\n");29printf("as given in 'file1'. Sublattices of proper multiples of Z^n are\n");30printf("ignored.\n");31printf("\n");32printf("Options:\n");33printf("-b : Print only the matrices of change of base and their inverse.\n");34printf("-g : Do not compute elementary divisors of the gram matrix.\n");35printf("-l=# : Stop after reaching level #level (default #=500).\n");36printf("-n=# : Stop after computation of #number \"sublattices\" (default #=1000).\n");37printf("-q : Quiet mode. Suppress any messages to stderr.\n");38printf("-r : With LLL-reduction for the bases, cf. 'file2'.\n");39printf("-s : Print less information.\n");40printf("-t='out': Create an output file with additional information. The name \n");41printf(" of the output file defaults to stdout. Specifying \"none\" \n");42printf(" disables writing to the output file\n");43printf("-u : Do not compute elementary divisors of the basis\n");44printf(" transformations.\n");45printf("\n");46printf("Options for experts:\n");47printf("-p<N>/<d1>/<d2>...<dN> : treat the lattice as a direct sum of <N> \n");48printf(" sublattices of dimensions <d1>, <d2> etc. \n");49printf(" (1 <= N, di <= 6) and compute only those\n");50printf(" sublattices that have surjective projections \n");51printf(" onto each of the N component lattices.\n");52printf("\n");53printf("Cf. Order, QtoZ, Z_equiv, Q_equiv\n");5455}5657int parse_options(int argc,58char *argv[],59char *option)60{6162int i,63errflag = 0;6465*option++ = 't';66outputfile = stdout;6768if (is_option('b')){69*option='b';70option++;71}72if (is_option('g')){73*option='g';74option++;75}76if (is_option('q')){77*option='q';78option++;79}80if (is_option('r')){81*option='r';82option++;83}84if (is_option('s')){85*option='s';86option++;87}88if (is_option('m')){89*option='m';90option++;91}92if (is_option('u')){93*option='u';94option++;95}96if (is_option('z')){97*option='z';98option++;99}100if (is_option('Z')){101*option='Z';102option++;103}104105if (is_option('l')){106*option='l';107option++;108sprintf(option,"%d ",optionnumber('l'));109option=strchr(option,' ');110}111if (is_option('n')){112*option='n';113option++;114sprintf(option,"%d ",optionnumber('n'));115option=strchr(option,' ');116}117118if (is_option('p')){119*option='p';120option++;121for (i=1;i<argc && strstr(argv[i],"-p") != argv[i];i++);122sprintf(option,"%s ",argv[i]+2);123option=strchr(option,' ');124}125if (is_option('t')){126*option='t';127option++;128for (i=1;i<argc && strstr(argv[i],"-t") != argv[i];i++);129outputfile = fopen(argv[i]+3, "w+");130if (outputfile == NULL) {131fprintf(stderr,"ZZprog: Error, could not open temporary file %s\n",132argv[i]+3);133errflag = 1;134}135}136137return errflag == 0;138}139140int main (argc, argv)141int argc;142char *argv[];143{144bravais_TYP *group;145matrix_TYP *gram = NULL,146*ID;147char *prog_name = argv[0];148char options[256];149150/* for somewhat obscure carat option handling. Why not use the well151* ANSI standard, i.e. getopt() :-(152*/153read_header(argc, argv);154IDEM_NO = 0;155156if (is_option('D') && optionnumber('D') == 8){157SFLAG = 1;158INFO_LEVEL = optionnumber('D');159}160161if (!parse_options(argc, argv, options)) {162ZZ_usage (prog_name);163exit(31);164}165166#if DEBUG167printf("Options: %s\n", options);168{169int i;170171for ( i = optind; i < argc; i++) {172printf("argv[%d] = %s\n", i, argv[i]);173}174}175#endif176switch (FILEANZ) {177case 1:178group = get_bravais (FILENAMES[0]);179ID = init_mat(group->dim,group->dim,"i1");180gram = rform(group->gen,group->gen_no,ID,101);181free_mat(ID);182break;183case 2:184group = get_bravais (FILENAMES[0]);185gram = get_mat(FILENAMES[1]);186break;187default:188ZZ_usage (prog_name);189exit(0);190}191192193#if DEBUG194fput_mat( stderr, gram, "Form", 0);195#endif196197ZZ (group, gram, group->divisors, NULL, options, outputfile, 0, 0);198199#if DEBUG200fprintf (stderr, "num_zentr: %d\n", group->zentr_no);201#endif202/* the following is not exactly needed as we do an exit() anyways.203* It's useful, however, for debugging.204*/205cleanup_prime();206free_bravais(group);207if (gram != NULL) free_mat(gram);208209if (INFO_LEVEL == 8){210pointer_statistics(0,0);211}212213return 0;214}215216217