GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
1#include "typedef.h"2#include "tools.h"3#include "matrix.h"4#include "getput.h"5/**************************************************************************\6@---------------------------------------------------------------------------7@---------------------------------------------------------------------------8@ FILE: get_symbol.c9@---------------------------------------------------------------------------10@---------------------------------------------------------------------------11@12\**************************************************************************/1314/**************************************************************************\15@---------------------------------------------------------------------------16@ symbol_out *get_symbol (file_name)17@ char *file_name;18@19@ This is a function for the 'Datei' programm.20@ It reads a group (bravais_TYP) from 'file_name'21@ and additionally the name of another file stated in the22@ file 'file_name' beyond the group23@24@---------------------------------------------------------------------------25@26\**************************************************************************/2728symbol_out *get_symbol (file_name)29char *file_name;3031{3233char string[80];34char *str, *strin;35char merk[10];36char *fn;37symbol_out *sy;38boolean header = FALSE;39char st;40char **piece;41FILE *infile;42int anz, teile;43int i, j, k, l, m;44int gen_no, form_no, zentr_no, normal_no, cen_no;4546/*------------------------------------------------------------*\47| Open input file |48\*------------------------------------------------------------*/49if ( file_name == NULL )50infile = stdin;51else52if ( (infile = fopen (file_name, "r")) == NULL ) {53fprintf (stderr, "get_symbol: Could not open input-file %s\n", file_name);54exit (4);55}56gen_no = 0;57form_no = 0;58zentr_no = 0;59normal_no = 0;60cen_no = 0;6162/*--------------------------------------------------*\63| read header line |64\*--------------------------------------------------*/65fscanf (infile, "%*[ \t\n\r]");66st = getc(infile);67if ( st != '#' ) {68gen_no = 1;69ungetc(st,infile);70}71else72{7374fscanf (infile, "%[ \t\n]", string);75fscanf (infile, "%[^\n]",string);76strtok (string, "%");7778if ( (str = strpbrk (string, "gfznc")) == NULL )79sscanf(string, "%d", &gen_no);80else81{82while((str = strpbrk(str, "gfznc")) != NULL)83{84i = strcspn(str, "g");85j = strcspn(str, "f");86k = strcspn(str, "z");87l = strcspn(str, "n");88m = strcspn(str, "c");8990if(i< j && i<k &&i<l && i<m)91sscanf ( ++str, "%d", &gen_no);92if(j<i && j<k && j<l && j<m)93sscanf ( ++str, "%d", &form_no);94if(k<i && k<j && k<l && k<m)95sscanf ( ++str, "%d", &zentr_no);96if(l<i && l<j && l<k && l<m)97sscanf ( ++str, "%d", &normal_no);98if(m<i && m<j && m<k && m<l)99sscanf ( ++str, "%d", &cen_no);100}101}102}103104/*--------------------------------------------------*\105| read the matrices |106\*--------------------------------------------------*/107sy = (symbol_out *) malloc(sizeof(symbol_out));108sy->grp = (bravais_TYP *) malloc(sizeof(bravais_TYP));109sy->grp->gen_no = gen_no;110sy->grp->form_no = form_no;111sy->grp->zentr_no = zentr_no;112sy->grp->normal_no = normal_no;113sy->grp->cen_no = cen_no;114sy->grp->gen = (matrix_TYP **)malloc(gen_no *sizeof(matrix_TYP *));115sy->grp->form = (matrix_TYP **)malloc(form_no *sizeof(matrix_TYP *));116if (zentr_no > 0)117sy->grp->zentr = (matrix_TYP **)malloc(zentr_no *sizeof(matrix_TYP *));118if (normal_no > 0)119sy->grp->normal = (matrix_TYP **)malloc(normal_no *sizeof(matrix_TYP *));120if (cen_no > 0)121sy->grp->cen = (matrix_TYP **)malloc(cen_no *sizeof(matrix_TYP *));122123for ( k = 0; k < gen_no; k++)124sy->grp->gen[k] = fget_mat(infile);125for ( k = 0; k < form_no; k++)126sy->grp->form[k] = fget_mat(infile);127for ( k = 0; k < zentr_no; k++)128sy->grp->zentr[k] = fget_mat(infile);129for ( k = 0; k < normal_no; k++)130sy->grp->normal[k] = fget_mat(infile);131for ( k = 0; k < cen_no; k++)132sy->grp->cen[k] = fget_mat(infile);133134/*------------------------------------------------------------*\135| read group order |136\*------------------------------------------------------------*/137fscanf (infile, "%[ \t\n]", string);138fscanf (infile, "%[^\n]",string);139if ( *string == '%' )140strin= NULL;141else142strin = strtok (string, "%");143for(i=0; i<100; i++)144sy->grp->divisors[i] = 0;145if( (strlen(strin)) != 0 && strin != NULL)146{147i = strcspn(strin, "=");148while(i != 0)149{150while(strin[0] == ' ')151strin++;152if((strcspn(strin, "*")) == 0)153strin++;154while(strin[0] == ' ')155strin++;156sscanf(strin, "%d", &j);157itoa(j, merk);158k = strlen(merk);159strin = strin+k;160while(strin[0] == ' ')161strin++;162if((strcspn(strin, "^")) != 0)163sy->grp->divisors[j] = 1;164else165{166strin++;167while(strin[0] == ' ')168strin++;169sscanf(strin, "%d", &k);170sy->grp->divisors[j] = k;171itoa(k, merk);172k = strlen(merk);173strin = strin+k;174}175while(strin[0] == ' ')176strin++;177i = strcspn(strin, "=");178}179if ( (str = strpbrk (strin, "=")) != NULL )180sscanf ( ++str, "%d", &sy->grp->order);181else182sy->grp->order = 0;183}184else185{186sy->grp->divisors[0] = 1;187sy->grp->order = 0;188}189190/*------------------------------------------------------------*\191| read file-reference |192\*------------------------------------------------------------*/193sy->fn = (char *) malloc(80 *sizeof(char));194fn = (char *) malloc(80 *sizeof(char));195fscanf (infile, "%[ \t\n]", fn);196fscanf (infile, "%[^\n]", fn);197while(fn != NULL && fn[0] == ' ')198fn++;199if(fn[0] == '\n' ||200fn[0] == '0' ||201fn[0] == EOF ||202fn[0] == '%' ||203fn[0] == '\f' ||204fn[0] == '\r' ||205fn[0] == '\v' ||206fn[0] == '\t'){207/* added the free: tilman 7/5/97 */208free(fn);209fn = NULL;210}211212if(fn != NULL)213strtok (fn, "%");214if(fn != NULL)215{216strcpy(sy->fn, TABLES);217/************218strcpy(sy->fn, TOPDIR "/lib/");219***********/220strcat(sy->fn, fn);221}222else{223/* added the free: tilman 7/5/97 */224free(sy->fn);225sy->fn = NULL;226}227/*------------------------------------------------------------*\228| close input file |229\*------------------------------------------------------------*/230if ( infile != stdin )231fclose (infile);232if(sy->grp->gen_no != 0)233sy->grp->dim = sy->grp->gen[0]->cols;234235/* inserted 7/5/97 tilman (untill return (sy)) */236long_rein_formspace(sy->grp->form,sy->grp->form_no,1);237for (i=0;i<sy->grp->gen_no;i++) Check_mat(sy->grp->gen[i]);238for (i=0;i<sy->grp->form_no;i++) Check_mat(sy->grp->form[i]);239for (i=0;i<sy->grp->zentr_no;i++) Check_mat(sy->grp->zentr[i]);240for (i=0;i<sy->grp->normal_no;i++) Check_mat(sy->grp->normal[i]);241if (fn != NULL) free(fn);242243return ( sy );244}245/*{{{}}}*/246247248