GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "getput.h"2#include "matrix.h"34/**************************************************************************\5@---------------------------------------------------------------------------6@---------------------------------------------------------------------------7@ FILE: get_bravais.c8@---------------------------------------------------------------------------9@---------------------------------------------------------------------------10@11\**************************************************************************/1213141516/**************************************************************************\17@---------------------------------------------------------------------------18@ bravais_TYP *get_bravais (file_name)19@ char *file_name;20@ reads a bravais_TYP from the file 'file_name'21@---------------------------------------------------------------------------22@23\**************************************************************************/24bravais_TYP *get_bravais (file_name)25char *file_name;2627{2829char string[1024];30char *str, *strin;31char merk[256];32bravais_TYP *grp;33boolean header = FALSE;34char st;35char **piece;36FILE *infile;37int anz, teile;38int i, j, k, l, m;39int gen_no, form_no, zentr_no, normal_no, cen_no;4041/*------------------------------------------------------------*\42| Open input file |43\*------------------------------------------------------------*/44if ( file_name == NULL )45infile = stdin;46else47if ( (infile = fopen (file_name, "r")) == NULL ) {48fprintf (stderr, "get_bravais: Could not open input-file %s\n", file_name);49exit (4);50}51gen_no = 0;52form_no = 0;53zentr_no = 0;54normal_no = 0;55cen_no = 0;5657/*--------------------------------------------------*\58| read header line |59\*--------------------------------------------------*/60fscanf (infile, "%*[ \t\n\r]");61st = getc(infile);62if ( st != '#' ) {63gen_no = 1;64ungetc(st,infile);65}66else67{6869fscanf (infile, "%[ \t\n]", string);70if (fscanf (infile, "%[^\n]",string) == EOF) {71*string = '\0';72}73strtok (string, "%");7475if ( (str = strpbrk (string, "gfznc")) == NULL )76sscanf(string, "%d", &gen_no);77else78{79while((str = strpbrk(str, "gfznc")) != NULL)80{81i = strcspn(str, "g");82j = strcspn(str, "f");83k = strcspn(str, "z");84l = strcspn(str, "n");85m = strcspn(str, "c");8687if(i< j && i<k &&i<l && i<m)88sscanf ( ++str, "%d", &gen_no);89if(j<i && j<k && j<l && j<m)90sscanf ( ++str, "%d", &form_no);91if(k<i && k<j && k<l && k<m)92sscanf ( ++str, "%d", &zentr_no);93if(l<i && l<j && l<k && l<m)94sscanf ( ++str, "%d", &normal_no);95if(m<i && m<j && m<k && m<l)96sscanf ( ++str, "%d", &cen_no);97}98}99}100101/*--------------------------------------------------*\102| read the matrices |103\*--------------------------------------------------*/104grp = (bravais_TYP *) malloc(sizeof(bravais_TYP));105grp->gen_no = gen_no;106grp->form_no = form_no;107grp->zentr_no = zentr_no;108grp->normal_no = normal_no;109grp->cen_no = cen_no;110if ( gen_no >0 ) {111grp->gen = (matrix_TYP **)malloc(gen_no *sizeof(matrix_TYP *));112} else {113grp->gen = NULL;114}115if ( form_no>0 ) {116grp->form = (matrix_TYP **)malloc(form_no *sizeof(matrix_TYP *));117} else {118grp->form = NULL;119}120if ( zentr_no >0 ) {121grp->zentr = (matrix_TYP **)malloc(zentr_no *sizeof(matrix_TYP *));122} else {123grp->zentr = NULL;124}125if ( normal_no>0 ) {126grp->normal = (matrix_TYP **)malloc(normal_no *sizeof(matrix_TYP *));127} else {128grp->normal = NULL;129}130if ( cen_no>0 ) {131grp->cen = (matrix_TYP **)malloc(cen_no *sizeof(matrix_TYP *));132} else {133grp->cen = NULL;134}135136for ( k = 0; k < gen_no; k++)137grp->gen[k] = fget_mat(infile);138for ( k = 0; k < form_no; k++)139grp->form[k] = fget_mat(infile);140for ( k = 0; k < zentr_no; k++)141grp->zentr[k] = fget_mat(infile);142for ( k = 0; k < normal_no; k++)143grp->normal[k] = fget_mat(infile);144for ( k = 0; k < cen_no; k++)145grp->cen[k] = fget_mat(infile);146147/*------------------------------------------------------------*\148| read group order |149\*------------------------------------------------------------*/150fscanf (infile, "%[ \t\n]", string);151if (fscanf (infile, "%[^\n]",string) == EOF) {152*string = '\0';153}154if ( *string == '%' )155strin= NULL;156else157strin= strtok (string, "%");158for(i=0; i<100; i++)159grp->divisors[i] = 0;160/* changed 15/5/97 tilman from161if( strin != NULL && (strlen(strin)) != 0 ) to */162if( strin != NULL && (strlen(strin)) != 1 )163{164i = strcspn(strin, "=");165while(i != 0)166{167while(strin[0] == ' ')168strin++;169if((strcspn(strin, "*")) == 0)170strin++;171while(strin[0] == ' ')172strin++;173sscanf(strin, "%d", &j);174itoa(j, merk);175k = strlen(merk);176strin = strin+k;177while(strin[0] == ' ')178strin++;179if((strcspn(strin, "^")) != 0)180grp->divisors[j] = 1;181else182{183strin++;184while(strin[0] == ' ')185strin++;186sscanf(strin, "%d", &k);187grp->divisors[j] = k;188itoa(k, merk);189k = strlen(merk);190strin = strin+k;191}192while(strin[0] == ' ')193strin++;194i = strcspn(strin, "=");195}196if ( (str = strpbrk (strin, "=")) != NULL )197sscanf ( ++str, "%d", &grp->order);198else199grp->order = 0;200}201else202{203grp->divisors[0] = 1;204grp->order = 0;205}206207/*------------------------------------------------------------*\208| close input file |209\*------------------------------------------------------------*/210if ( infile != stdin )211fclose (infile);212if(grp->gen_no != 0)213grp->dim = grp->gen[0]->cols;214return ( grp );215}216/*{{{}}}*/217218219