GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include"typedef.h"1#include"idem.h"2#include"longtools.h"3#include"getput.h"4#include"voronoi.h"5#include"bravais.h"6#include"datei.h"7#include"matrix.h"8#include"orbit.h"9#include"tools.h"1011extern int INFO_LEVEL;12/*****************************************************************************13@14@-----------------------------------------------------------------------------15@ FILE: symbol.c16@-----------------------------------------------------------------------------17@18*****************************************************************************/1920/*****************************************************************************21@22@-----------------------------------------------------------------------------23@24@ static constituent *homogenous(bravais_TYP *G,matrix_TYP *F,int *anz)25@26@-----------------------------------------------------------------------------27@28*****************************************************************************/29static constituent *homogenous(bravais_TYP *G,matrix_TYP *F,int *anz)30{31int i,32j,33rang,34dimc,35dimcc;3637matrix_TYP **idem,38**solution,39*colspace,40*tmp;4142constituent *result;4344/* calculate the central primitive idempotents */45idem = idempotente(G->gen,G->gen_no,F,anz,&dimc,&dimcc,FALSE);4647/* now we know allmost everything, just calculate a bit */48result = (constituent *)malloc(anz[0] * sizeof(constituent));4950if (anz[0] > 1){51for (i=0;i<anz[0];i++){5253/* calculate the dimension of the module the constiuent is acting on,54and a basis of it */55colspace = tr_pose(idem[i]);56rang = tgauss(colspace);57result[i].group = init_bravais(rang);58real_mat(colspace,rang,colspace->cols);59tmp = tr_pose(colspace);60free_mat(colspace);61colspace = tmp;62tmp = NULL;6364result[i].group->gen = (matrix_TYP **) malloc(G->gen_no *65sizeof(matrix_TYP *));66result[i].group->gen_no = G->gen_no;6768/* transform the generators */69for (j=0;j<G->gen_no;j++){70tmp = mat_mul(G->gen[j],colspace);71solution = long_solve_mat(tmp,colspace);7273if (solution[1] != NULL){74fprintf(stderr,"error in homogenous: there shoudn't be\n");75fprintf(stderr,"an homogenous solutio\n");76exit(3);77}78result[i].group->gen[j] = solution[0];79free(solution);80free_mat(tmp);81}8283/* now deal with the rest (not implemented yet) */84result[i].centralizer = NULL;85result[i].dimc=0;86result[i].ccentralizer = NULL;87result[i].dimcc=0;8889/* and calculate the formspace */90result[i].group->form = formspace(result[i].group->gen,91result[i].group->gen_no,1,&result[i].group->form_no);9293free_mat(colspace);94}9596/* clean up the result returned by idem */97for (i=0;i<anz[0]+dimc+dimcc;i++) free_mat(idem[i]);98}99else{100/* just copy the result */101result[0].group = copy_bravais(G);102103result[0].dimc = dimc;104result[0].dimcc = dimcc;105result[0].centralizer = (matrix_TYP **) malloc(dimc106* sizeof(matrix_TYP*));107result[0].ccentralizer = (matrix_TYP **) malloc(dimcc108* sizeof(matrix_TYP*));109for (i=0;i<dimc;i++)110result[0].centralizer[i] = idem[i+1];111for (i=0;i<dimcc;i++)112result[0].ccentralizer[i] = idem[i+1+dimc];113114/* we promised the user that there will be a formspace */115if (G->form_no ==0)116result[0].group->form = formspace(result[0].group->gen,117result[0].group->gen_no,1,&result[0].group->form_no);118119free_mat(idem[0]);120}121122free(idem);123124return result;125126}127128/*****************************************************************************129@130@-----------------------------------------------------------------------------131@132@ static char *identify_hom(bravais_TYP *G,int clear)133@134@-----------------------------------------------------------------------------135@136*****************************************************************************/137static char *identify_hom(bravais_TYP *G,int clear)138{139int i,140found=0,141flag,142multiplicity,143*list;144145static int atom_no;146147FILE *atom_file;148149char *result,150tmp[20],151*pp,152bravais_file[1000];153154static symbol_out *Atoms;155156/* this program does only work for groups up to dimension 6157(it may even give wrong results otherwise), so tell the user */158if (G->dim > 6){159fprintf(stderr,"Error (in identify_hom), this program does only work\n");160fprintf(stderr,"in dimension up to 6.\n");161exit(3);162}163164if (atom_no == 0){165/* read the file with all atoms */166sprintf(bravais_file,"%s%s",TOPDIR,"/tables/symbol/atom_list");167atom_file = fopen(bravais_file,"r");168169if (atom_file == NULL){170fprintf(stderr,"I didn't find my library file. exiting.\n");171exit(4);172}173174fscanf(atom_file,"%d\n",&atom_no);175176/* now read the symbols */177Atoms = (symbol_out *) malloc(atom_no * sizeof(symbol_out));178for (i=0;i<atom_no;i++){179Atoms[i].fn = (char *) calloc(20,sizeof(char));180fscanf(atom_file,"%s\n",Atoms[i].fn);181}182fclose(atom_file);183184/* and their respective groups */185for (i=0;i<atom_no;i++){186sprintf(bravais_file,"%s/tables/symbol/%s",TOPDIR,Atoms[i].fn);187Atoms[i].grp = get_bravais(bravais_file);188long_rein_formspace(G->form,G->form_no,1);189}190191if (INFO_LEVEL & 4){192for (i=0;i<atom_no;i++){193printf("%s\n",Atoms[i].fn);194put_bravais(Atoms[i].grp,NULL,NULL);195}196}197}198199if (G->order == 0){200fprintf(stderr,"this feature hasn't been implemented yet,\n");201fprintf(stderr,"must specify a group order in identify_hom\n");202exit(3);203}204205list = (int *) malloc(atom_no * sizeof(int));206207/* check up the cheap stuff, ie. order, dimension ... */208/* bare in mind that this is sufficient up to dimension 6 */209for (i=0;i<atom_no;i++){210flag = (Atoms[i].grp->order == G->order);211flag = flag && ((G->dim % Atoms[i].grp->dim)==0);212if (flag){213list[found] = i;214found++;215}216}217218/* just look whether these bravais groups really do give219different families, or they look like (ie look for a,b,c's..)*/220if (found > 1){221/* to be implemented, it doesn't matter for dimensions up to 6 */222}223224/* now list contains a list of representatives which are possible.225now rule out the rest */226if (found == 1){227multiplicity = G->dim / Atoms[list[0]].grp->dim;228}229else{230fprintf(stderr,"this feature hasn't been implemeneted yet\n");231fprintf(stdout,"please report this to [email protected]\n");232fprintf(stdout,"together with the output:\n");233put_bravais(G,NULL,"ERROR IN: identify_hom");234exit(3);235}236237/* now we know the Q-Class of this homogenous module */238result = (char *) malloc(20*multiplicity*sizeof(char));239/* bare in mind to remove a,b,c and stuff from the end of the type */240pp = strchr(Atoms[list[0]].fn,'a');241if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'b');242if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'c');243if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'d');244if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'e');245if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'f');246if (pp == NULL) pp = strchr(Atoms[list[0]].fn,'g');247if (pp == NULL){248sprintf(result,"%s",Atoms[list[0]].fn);249}250else{251strncpy(result,Atoms[list[0]].fn,pp - Atoms[list[0]].fn);252result[pp-Atoms[list[0]].fn] = 0;253}254sprintf(tmp,"%s",result);255for (i=1;i<multiplicity;i++){256sprintf(result,"%s,%s",result,tmp);257}258259/* if we got the order, clean up the static allocated memory */260if (clear){261for (i=0;i<atom_no;i++){262free_bravais(Atoms[i].grp);263free(Atoms[i].fn);264}265free(Atoms);266atom_no = 0;267Atoms = NULL;268}269270free(list);271272return result;273}274275static void bubblesort(char **S,int n)276{277int i=1;278279char *tmp;280281while (i<n){282if (strcmp(S[i-1],S[i])<0){283tmp = S[i-1];284S[i-1] = S[i];285S[i] = tmp;286bubblesort(S,n);287}288i++;289}290291return;292}293294/*****************************************************************************295@296@-----------------------------------------------------------------------------297@298@ char *symbol(bravais_TYP *G,matrix_TYP *F)299@300@ bravais_TYP *G: the group in question301@ matrix_TYP *F : a positive definite G-invariant form302@303@ Calculates the symbol of the FINITE INTEGRAL group in G.304@ F is assumed to be a positive definite G-invariant form.305@ The information needed from G are the records G->gen & G->gen_no,306@ and G->form & G->form_no.307@308@ Sideefects: The matrices in G->gen and G->form might be checked via309@ Check_mat310@-----------------------------------------------------------------------------311@312*****************************************************************************/313char *symbol(bravais_TYP *G,matrix_TYP *F)314{315int i,316j,317len=0,318hom_no; /* the number of homogenous constituents of this repr */319320constituent *hom;321322bravais_TYP *brav; /* holds the bravais group of a homogenous323representation */324325char *result,326**symb;327328/* firstly split the representation into homogenous parts */329hom = homogenous(G,F,&hom_no);330331if (INFO_LEVEL & 4){332for (i=0;i<hom_no;i++){333put_bravais(hom[i].group,NULL,NULL);334}335}336337symb = (char **) calloc(hom_no , sizeof(char *));338/* calculate the bravais group for each homogenous module,339and search it in the list */340for (i=0;i<hom_no;i++){341brav = bravais_group(hom[i].group,FALSE);342symb[i] = identify_hom(brav,i==(hom_no-1));343free_bravais(brav);344len += strlen(symb[i]);345}346347/* swap the symbols in the right order */348bubblesort(symb,hom_no);349350result = (char *) calloc((len + hom_no + 10),sizeof(char));351sprintf(result,"%s",symb[0]);352for (i=1;i<hom_no;i++){353sprintf(result,"%s;%s",result,symb[i]);354}355356for (i=0;i<hom_no;i++){357free(symb[i]);358free_bravais(hom[i].group);359for (j=0;j<hom[i].dimc;j++)360free_mat(hom[i].centralizer[j]);361for (j=0;j<hom[i].dimcc;j++)362free_mat(hom[i].ccentralizer[j]);363364if (hom[i].centralizer != NULL){365free(hom[i].centralizer);366hom[i].centralizer = NULL;367}368if (hom[i].ccentralizer != NULL){369free(hom[i].ccentralizer);370hom[i].ccentralizer = NULL;371}372373}374free(symb);375free(hom);376377return result;378379}380381382383