GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include "typedef.h"1#include "voronoi.h"2#include "symm.h"3#include "autgrp.h"4#include "bravais.h"5#include "base.h"6#include "idem.h"7#include "longtools.h"8#include "reduction.h"9#include "ZZ_P.h"10#include "ZZ_zclass_P.h"11#include "ZZ_cen_fun_P.h"12#include "graph.h"131415int IDEM_NO;16extern int INFO_LEVEL;17ZZ_super_TYP **SUPER_info, *SUPER_INFO;181920/* -------------------------------------------------------------------- */21static matrix_TYP *good_initial_basis(matrix_TYP *B,22matrix_TYP *F)23{2425int i;2627matrix_TYP *NEW,28*C,29*D;3031NEW = scal_pr(B,F,TRUE);3233/* reduce */34C = init_mat(NEW->rows,NEW->rows,"i1");35D = pair_red(NEW,C);3637free_mat(D);38free_mat(NEW);3940NEW = mat_mul(C,B);4142free_mat(C);43free_mat(B);4445return NEW;46}474849/* free konst50if (flag == 1){51for (i = 0; i < super->konst->k; i++){52for (j = 0; j < super->konst->s[i]; j++){53for (k = 0; k < super->konst->r; k++){54free_mat(super->konst->Delta[i][j][k]);55}56free(super->konst->Delta[i][j]);57}58free(super->konst->Delta[i]);59}60free(super->konst->Delta);61free(super->konst->s);62free(super->konst);63}64*/6566/* ------------------------------------------------------------------ */67static void free_ZZ_super(ZZ_super_TYP *super)68{69int i, j, k;7071ZZ_node_t *n, *t;727374n = super->tree->root;75do {76t = n->next;77ZZ_free_node (super->data, n);78} while ((n = t) != NULL);79free(super->tree);8081ZZ_free_data(super->data);82free(super->data);8384free(super);85}8687888990/* ------------------------------------------------------------------ */91void free_QtoZ(QtoZ_TYP *inz,92int flag)93{94int i, j, k;959697if (inz->zoogitter != NULL){98for (i = 0; i < inz->anz; i++){99for (j = 0; j < inz->entry[i][0].anz; j++){100if (inz->zoogitter[i][j] != NULL)101free_mat(inz->zoogitter[i][j]);102}103if (inz->zoogitter[i] != NULL)104free(inz->zoogitter[i]);105}106free(inz->zoogitter);107}108for (i = 0; i < inz->anz; i++){109if (flag == 1 && inz->gitter[i] != NULL){110free_mat(inz->gitter[i]);111free_mat(inz->tr_gitter[i]);112free_mat(inz->inv_tr_gitter[i]);113}114for (j = 0; j < inz->anz + flag; j++){115if (inz->entry[i][j].anz != 0){116free(inz->entry[i][j].I);117free(inz->entry[i][j].J);118free(inz->entry[i][j].flag);119if (flag == 0){120for (k = 0; k < inz->entry[i][j].anz; k++){121free_mat(inz->entry[i][j].lattice[k]);122}123}124free(inz->entry[i][j].lattice);125if (flag == 0){126for (k = 0; k < inz->entry[i][j].anz; k++){127free_mat(inz->entry[i][j].lsf[k]);128}129free(inz->entry[i][j].lsf);130}131}132}133free(inz->entry[i]);134}135free(inz->entry);136137if (flag == 1){138free(inz->gitter);139free(inz->inv_tr_gitter);140free(inz->tr_gitter);141}142143free(inz);144}145146147148/*------------------------------------------------------------------------------- */149static int suche_mat(matrix_TYP *mat,150matrix_TYP **liste,151int anz)152{153int i;154155for (i = 0; i < anz; i++){156if (cmp_mat(mat, liste[i]) == 0)157return(i);158}159return(-1);160}161162163164/* ------------------------------------------------------------------------------- */165static matrix_TYP *hom_de_super(bravais_TYP *group,166matrix_TYP *id,167matrix_TYP **idem,168int idem_no)169{170matrix_TYP *F,171*tmp,172*new_basis,173**idem_spaces;174175int i, j, k,176col, kgv,177mult;178179180181F = rform(group->gen, group->gen_no, id, 101);182idem_spaces = (matrix_TYP **)calloc(idem_no, sizeof(matrix_TYP *));183184for (i = 0; i < idem_no; i++){185tmp = tr_pose(idem[i]);186idem_spaces[i] = ggauss(tmp);187idem_spaces[i] = good_initial_basis(idem_spaces[i], F);188free_mat(tmp);189}190191kgv = 1;192for (i = 0; i < idem_no; i++){193kgv = KGV(kgv, idem_spaces[i]->kgv);194}195196for (i = 0; i < idem_no; i++){197mult = kgv/idem_spaces[i]->kgv;198if (mult != 1){199for (j = 0; j < idem_spaces[i]->rows; j++){200for (k = 0; k < idem_spaces[i]->cols; k++)201idem_spaces[i]->array.SZ[j][k] *= mult;202}203idem_spaces[i]->kgv = kgv;204}205}206207new_basis = init_mat(group->dim, group->dim, "1");208col = -1;209for (i = 0; i < idem_no; i++){210for (j = 0; j < idem_spaces[i]->rows; j++){211col++;212for (k = 0; k < group->dim; k++){213new_basis->array.SZ[k][col] = idem_spaces[i]->array.SZ[j][k];214}215}216}217new_basis->kgv = kgv;218Check_mat(new_basis);219220/* clean */221for (i = 0; i < idem_no; i++){222free_mat(idem_spaces[i]);223}224free(idem_spaces);225free_mat(F);226227return(new_basis);228}229230231232/* ------------------------------------------------------------------ */233static void get_normalizer(bravais_TYP *H)234{235236matrix_TYP *ID,237*F,238*PF,239**N,240**forms,241*trbifo;242243bravais_TYP *Htr,244*HB;245246int i,247j,248vno;249250voronoi_TYP **V;251252Htr = tr_bravais(H,1,FALSE);253ID = init_mat(H->dim,H->dim,"1");254F = rform(H->gen,H->gen_no,ID,101);255trbifo = trace_bifo(H->form,Htr->form,H->form_no);256PF = first_perfect(F,H,Htr->form,trbifo,&i);257258/* calculate the normalizer of the bravais group */259HB = bravais_group(H,TRUE);260V = normalizer(PF,HB,Htr,1949,&vno);261H->normal = HB->normal ; H->normal_no = HB->normal_no;262HB->normal = NULL; HB->normal_no = 0;263free_bravais(HB);264265/* calculate the bravais group itself */266free_bravais(Htr);267forms = (matrix_TYP **) malloc( (1+H->form_no) * sizeof(matrix_TYP *));268for (i=0;i<H->form_no;i++)269forms[i+1] = H->form[i];270forms[0] = PF; /* a H-perfect form is especially good */271272273/* replaced the following two statements by a better one274tilman 06.05.98:275SV = short_vectors(PF,max_diagonal_entry(PF),0,0,0,&i);276Htr = autgrp(forms,H->form_no+1,SV,NULL,0,NULL); */277Htr = pr_aut(forms,H->form_no+1,NULL,0,NULL);278279Htr->normal = H->normal;280Htr->normal_no = H->normal_no;281H->normal = NULL;282H->normal_no = 0;283284H->normal = normalizer_in_N(H,Htr,&H->normal_no,FALSE);285286/* clean up */287free_mat(ID);288free_mat(F);289free_mat(PF);290free_mat(trbifo);291free_bravais(Htr);292for (i=0;i<vno;i++){293clear_voronoi(V[i]);294free(V[i]);295}296free(V);297/* free_mat(SV); */298free(forms);299300return;301}302303304305/* ------------------------------------------------------------------ */306static bravais_TYP **almost(bravais_TYP *H)307{308int i,309j,310zentr_no,311normal_no,312cen_no;313314matrix_TYP *tmp;315316bravais_TYP **RES;317318RES = (bravais_TYP **) malloc((1+H->zentr_no) * sizeof(bravais_TYP *));319320H->gen_no -= IDEM_NO;321normal_no = H->normal_no;322H->normal_no = 0;323cen_no = H->cen_no;324H->cen_no = 0;325zentr_no = H->zentr_no;326H->zentr_no = 0;327for (i=0;i<zentr_no;i++){328if (i==0){329RES[i] = copy_bravais(H);330}331else{332tmp = mat_inv(H->zentr[i]);333RES[i] = konj_bravais(H,tmp);334free_mat(tmp);335}336for (j=0;j<H->form_no;j++){337RES[i]->form[j]->kgv = 1;338}339long_rein_formspace(RES[i]->form,RES[i]->form_no,1);340get_normalizer(RES[i]);341}342343H->gen_no += IDEM_NO;344H->cen_no = cen_no;345H->normal_no = normal_no;346347/* changed by oliver:348for (i=0;i<zentr_no;i++){349free_mat(H->zentr[i]);350}351free(H->zentr);352H->zentr = NULL;353*/354H->zentr_no = zentr_no;355356return RES;357}358359360361/* ------------------------------------------------------------------ */362/* this function was for test purposes only363static matrix_TYP *better_base2(matrix_TYP *B,364int number,365matrix_TYP **SP)366{367368int i,369j,370k,371offset = 0;372373matrix_TYP *NEW,374*C;375376put_mat(B,NULL,"B",0);377NEW = init_mat(B->rows,B->cols,"i");378379for (i=0;i<number;i++){380C = init_mat(SP[i]->rows,B->rows,"i");381for (j=0;j<SP[i]->rows;j++){382for (k=0;k<B->rows;k++){383C->array.SZ[j][k] = B->array.SZ[k][j+offset];384}385}386387long_row_basis(C,TRUE);388389for (j=0;j<SP[i]->rows;j++){390for (k=0;k<B->rows;k++){391NEW->array.SZ[k][j+offset] = C->array.SZ[j][k];392}393}394free_mat(C);395396offset += SP[i]->rows;397}398399free_mat(B);400401return NEW;402} */403404405406/* ------------------------------------------------------------------ */407static matrix_TYP *better_base(matrix_TYP *B,408matrix_TYP *F,409int number,410matrix_TYP **SP)411{412413int i,414j,415k,416offset = 0;417418419matrix_TYP *NEW,420*TR,421*C,422*D;423424/* put_mat(B,NULL,"B",0); */425426TR = init_mat(B->cols,B->cols,"i");427for (i=0;i<number;i++){428C = init_mat(SP[i]->rows,B->rows,"i");429for (j=0;j<B->rows;j++){430for (k=0;k<SP[i]->rows;k++){431C->array.SZ[k][j] = B->array.SZ[j][k+offset];432}433}434435/* calculate the form on this subspace */436NEW = scal_pr(C,F,TRUE);437free_mat(C);438439/* reduce the form */440C = init_mat(NEW->rows,NEW->rows,"i1");441D = pair_red(NEW,C);442free_mat(D);443444/* store the transformation */445for (j=0;j<C->rows;j++){446for (k=0;k<C->cols;k++){447TR->array.SZ[offset+k][offset+j] = C->array.SZ[j][k];448}449}450451free_mat(C);452free_mat(NEW);453offset += SP[i]->rows;454}455456/* put_mat(TR,0,"TR",0); */457mat_muleq(B, TR);458459return(TR);460}461462463static matrix_TYP **get_better_base(bravais_TYP *H,464matrix_TYP *F,465int number,466matrix_TYP **SPACES)467{468469int i;470471matrix_TYP *id = NULL,472**better,473*tmp;474475476if (F == NULL){477id = init_mat(H->dim,H->dim,"i1");478F = rform(H->gen,H->gen_no,id,101);479}480better = (matrix_TYP **)calloc(H->zentr_no, sizeof(matrix_TYP *));481482for (i = 1; i < H->zentr_no; i++){483better[i] = better_base(H->zentr[i],F,number,SPACES);484}485486if (id){487free_mat(F);488free_mat(id);489}490491return(better);492493}494495496497498static matrix_TYP **GL_n_Z(int dim,int *no)499{500501int i;502503matrix_TYP **RES;504505if (dim == 1){506*no = 1;507RES = (matrix_TYP **) malloc(1*sizeof(matrix_TYP *));508RES[0] = init_mat(1,1,"i0");509RES[0]->array.SZ[0][0] = -1;510}511else{512*no = 4;513RES = (matrix_TYP **) malloc(4*sizeof(matrix_TYP *));514RES[0] = init_mat(dim,dim,"i1");515RES[0]->array.SZ[0][0] = -1;516RES[1] = init_mat(dim,dim,"i1");517RES[1]->array.SZ[0][1] = 1;518RES[2] = init_mat(dim,dim,"i1");519RES[2]->array.SZ[0][1] = 1;520RES[2]->array.SZ[1][0] = 1;521RES[2]->array.SZ[0][0] = 0;522RES[2]->array.SZ[1][1] = 0;523RES[3] = init_mat(dim,dim,"i0");524for (i=0;i<dim;i++)525RES[3]->array.SZ[i][(i+1)%dim] = 1;526for (i=0;i<4;i++)527Check_mat(RES[i]);528}529530return RES;531532}533534/* -------------------------------------------------------------------- */535/* -------------------------------------------------------------------- */536/* -------------------------------------------------------------------- */537bravais_TYP **q2z(bravais_TYP *G,538int *number,539int ADFLAG,540QtoZ_TYP *INZ,541int quiet)542{543bravais_TYP **GROUPS,544**ADGROUPS,545*H,546*group,547*ggg;548549matrix_TYP **IDEM,550**IDEM_SPACES,551**idem_spaces,552*F,553*tmp,554*new_base,555*id,556*X,557/* *test, */558**conj_idem,559**real_idem,560*zoo_kon,561*lattice,562*zoolattice,563*zoolattice_hnf,564*zoolattice_inv,565*zoo_inv,566*elementar,567**better,568**trash,569*zwischen,570*ttt,571**zentr_inv;572573char zzoptions[128],574string[128];575576int i,577j,578k,579l,580m,581f,582kgv, mult,583aa, bb,584counter,585ganzzahlig,586help,587idem_no,588ad_no,589col,590dimc,591dimcc,592zen_nr, cen_nr, normal_nr,593zoo, bahnnummer,594samezoo, yeah,595*liste;596597QtoZ_TYP **inzidenz;598599ZZ_node_t *node, *Knoten;600601ZZ_couple_t *laeufer;602603604/* handle the case of the groups G=<I> and G=<-I> differently,605because the first one couldn't be handled by this anyway,606and the second one trivial is but computationaly hard in dim 5 & 6 */607k = TRUE; l = TRUE;608for (i=0;i<G->gen_no && k;i++){609Check_mat(G->gen[i]);610k = k && G->gen[i]->flags.Scalar;611l = l && G->gen[i]->array.SZ[1][1] == 1;612}613if (l && k && G->order == 1)614for (i = 0;i<100 ; l = l && G->divisors[i] == 0, i++);615if ((k && G->dim > 4) ||616(k && l )){617GROUPS = (bravais_TYP **) malloc(1 * sizeof(bravais_TYP *));618GROUPS[0] = copy_bravais(G);619if (GROUPS[0]->normal && GROUPS[0]->normal_no > 0){620for (k=0;k<GROUPS[0]->normal_no;k++) free_mat(GROUPS[0]->normal[i]);621free(GROUPS[0]->normal);622}623GROUPS[0]->normal = GL_n_Z(G->dim,&GROUPS[0]->normal_no);624*number = 1;625if (ADFLAG){626GROUPS[0]->zentr = (matrix_TYP **) malloc(1 * sizeof(matrix_TYP));627GROUPS[0]->zentr[0] = init_mat(G->dim,G->dim,"1");628GROUPS[0]->zentr_no = 1;629}630return GROUPS;631}632633/* avoid silly mistakes */634if (G->form == NULL ||635G->form_no == 0 ||636G->order == 0 ){637fprintf(stderr,"You didn't specify G in an accurate way\n");638exit(3);639}640641id = init_mat(G->dim,G->dim,"1");642643/* we need a G-invariant, positive definite form for various reasons */644F = rform(G->gen,G->gen_no,id,101);645646/* get the idempotents of the group */647IDEM = idempotente(G->gen,G->gen_no,F,&IDEM_NO,&dimc,&dimcc,NULL);648G->gen = (matrix_TYP **) realloc(G->gen,(G->gen_no+IDEM_NO)649* sizeof(matrix_TYP*));650IDEM_SPACES = (matrix_TYP **) malloc(IDEM_NO * sizeof(matrix_TYP *));651for (i=0;i<IDEM_NO;i++){652G->gen[i+G->gen_no] = IDEM[i];653tmp = tr_pose(IDEM[i]);654IDEM_SPACES[i] = long_rein_mat(tmp);655IDEM_SPACES[i] = good_initial_basis(IDEM_SPACES[i],F);656free_mat(tmp);657}658G->gen_no += IDEM_NO;659kgv = 1;660for (i = 0; i < IDEM_NO; i++){661kgv = KGV(kgv, IDEM_SPACES[i]->kgv);662}663664for (i = 0; i < IDEM_NO; i++){665mult = kgv/IDEM_SPACES[i]->kgv;666if (mult != 1){667for (j = 0; j < IDEM_SPACES[i]->rows; j++){668for (k = 0; k < IDEM_SPACES[i]->cols; k++)669IDEM_SPACES[i]->array.SZ[j][k] *= mult;670}671IDEM_SPACES[i]->kgv = kgv;672}673}674675/* transform G to H which is an almost decomposable group */676new_base = init_mat(G->dim,G->dim,"1");677col = -1;678for (i=0;i<IDEM_NO;i++){679for (j=0;j<IDEM_SPACES[i]->rows;j++){680col++;681for (k=0;k<G->dim;k++){682new_base->array.SZ[k][col] = IDEM_SPACES[i]->array.SZ[j][k];683}684}685}686687new_base->kgv = kgv;688Check_mat(new_base);689tmp = mat_inv(new_base);690i = G->zentr_no;691G->zentr_no = 0;692H = konj_bravais(G,tmp);693for (m = 0; m < H->form_no; m++){694H->form[m]->kgv = 1;695}696long_rein_formspace(H->form, H->form_no, 0);697real_idem = &H->gen[H->gen_no - IDEM_NO];698G->zentr_no = i;699free_mat(tmp);700701/* make the ZZ options for the first call of ZZ */702if (quiet)703sprintf(zzoptions,"qtugZ");704else705sprintf(zzoptions,"tugZ");706707if (INFO_LEVEL & 4){708put_mat(new_base,NULL,"new_base",2);709put_bravais(H,NULL,"H");710printf("zzoptions: %s\n",zzoptions);711}712713/* call the ZZ to get all almost decomposable groups in this Q-class */714free_mat(F);715F = rform(H->gen,H->gen_no- IDEM_NO,id,101);716ZZ(H,F,NULL,NULL,zzoptions,NULL,0,-1);717718if (INFO_LEVEL & 4){719put_bravais(H,NULL,"H");720}721722/* apply a base reduction algorithm to the found new basises723BASISES ARE CHANGED !!!!!!!!!!!!!!!!!!!!!!!!!!! */724if (GRAPH){725better = get_better_base(H,F,IDEM_NO,IDEM_SPACES);726better[0] = init_mat(G->dim,G->dim,"1");727}728else{729trash = get_better_base(H,F,IDEM_NO,IDEM_SPACES);730for (j = 1; j < H->zentr_no; j++){731free_mat(trash[j]);732}733free(trash);734}735736/* get all almost decomposable groups */737ad_no = H->zentr_no;738ADGROUPS = almost(H);739740if (INFO_LEVEL & 4){741fprintf(stderr,"=== Number of almost decomposable groups %d\n",ad_no);742}743744/* make the ZZ options for the second call of ZZ */745if (quiet)746sprintf(zzoptions,"tuqzgp%d",IDEM_NO);747else748sprintf(zzoptions,"tuzgp%d",IDEM_NO);749750for (i = 0; i < IDEM_NO; i++){751sprintf(string,"%s/%d",zzoptions,IDEM_SPACES[i]->rows);752sprintf(zzoptions,"%s",string);753}754755/* call the ZZ again to get all sublattices which fullfill the projection756property (for each group in ADGROUPS) */757idem_no = IDEM_NO;758IDEM_NO = 0;759760if (GRAPH){761inzidenz = (QtoZ_TYP **)calloc(ad_no, sizeof(QtoZ_TYP *));762SUPER_info = (ZZ_super_TYP **)calloc(ad_no, sizeof(ZZ_super_TYP *));763for (i = 0; i < ad_no; i++){764inzidenz[i] = (QtoZ_TYP *)calloc(1, sizeof(QtoZ_TYP));765inzidenz[i]->gitter = (matrix_TYP **)calloc(1024, sizeof(matrix_TYP *));766inzidenz[i]->inv_tr_gitter = (matrix_TYP **)calloc(1024, sizeof(matrix_TYP *));767inzidenz[i]->tr_gitter = (matrix_TYP **)calloc(1024, sizeof(matrix_TYP *));768inzidenz[i]->zoogitter = (matrix_TYP ***)calloc(1024, sizeof(matrix_TYP **));769inzidenz[i]->entry = (QtoZ_entry_TYP **)calloc(1024, sizeof(QtoZ_entry_TYP *));770ZZ(ADGROUPS[i],F,NULL,inzidenz[i],zzoptions,NULL,i,(i == 0));771}772}773else{774for (i = 0; i < ad_no; i++){775ZZ(ADGROUPS[i],F,NULL,NULL,zzoptions,NULL,i,0);776777/* apply a base reduction algorithm to the found new basises */778trash = get_better_base(ADGROUPS[i],NULL,1,ADGROUPS[i]->gen);779for (j = 1; j < ADGROUPS[i]->zentr_no; j++){780free_mat(trash[j]);781}782free(trash);783}784}785786/* apply a base reduction algorithm to the found new basises */787/*788for (i = 0; i < ad_no; i++){789trash = get_better_base(ADGROUPS[i],NULL,1,ADGROUPS[i]->gen);790for (j = 1; j < inzidenz[i]->anz; j++){791free_mat(trash[j]);792}793free(trash);794}795*/796797if (GRAPH){798zentr_inv = (matrix_TYP **)calloc(ad_no, sizeof(matrix_TYP *));799for (i = 0; i < ad_no; i++){800zentr_inv[i] = mat_inv(H->zentr[i]);801INZ->anz += inzidenz[i]->anz;802}803INZ->entry = (QtoZ_entry_TYP **)calloc(INZ->anz, sizeof(QtoZ_entry_TYP *));804for (i = 0; i < INZ->anz; i++){805INZ->entry[i] = (QtoZ_entry_TYP *)calloc(INZ->anz, sizeof(QtoZ_entry_TYP));806}807liste = (int *)calloc(ad_no + 1, sizeof(int));808liste[0] = counter = 0;809for (i = 0; i < ad_no; i++){810for (j = 0; j < inzidenz[i]->anz; j++){811for (l = 0 ; l < inzidenz[i]->anz; l++){812help = INZ->entry[j + counter][l + counter].anz = inzidenz[i]->entry[j][l + 1].anz;813if (help != 0){814INZ->entry[j + counter][l + counter].I = (int *)calloc(1024, sizeof(int));815INZ->entry[j + counter][l + counter].J = (int *)calloc(1024, sizeof(int));816INZ->entry[j + counter][l + counter].flag = (int *)calloc(1024, sizeof(int));817INZ->entry[j + counter][l + counter].lattice =818(matrix_TYP **)calloc(1024, sizeof(matrix_TYP *));819for (m = 0; m < help; m++){820INZ->entry[j + counter][l + counter].I[m] = inzidenz[i]->entry[j][l + 1].I[m];821INZ->entry[j + counter][l + counter].J[m] = inzidenz[i]->entry[j][l + 1].J[m];822INZ->entry[j + counter][l + counter].flag[m] =823inzidenz[i]->entry[j][l + 1].flag[m];824INZ->entry[j + counter][l + counter].lattice[m] =825inzidenz[i]->entry[j][l + 1].lattice[m];826Check_mat(INZ->entry[j + counter][l + counter].lattice[m]);827}828}829}830}831counter += inzidenz[i]->anz;832liste[i+1] = counter;833}834835/* handle the lattices, which might be in another zoo */836for (i = 0; i < ad_no; i++){837zen_nr = ADGROUPS[i]->zentr_no;838normal_nr = ADGROUPS[i]->normal_no;839cen_nr = ADGROUPS[i]->cen_no;840ADGROUPS[i]->zentr_no = 0;841ADGROUPS[i]->normal_no = 0;842ADGROUPS[i]->cen_no = 0;843for (j = 0; j < inzidenz[i]->anz; j++){844for (l = 0; l < inzidenz[i]->entry[j][0].anz; l++){845samezoo = 0;846847/* calculate group */848zoo_inv = mat_inv(inzidenz[i]->zoogitter[j][l]);849ggg = konj_bravais(ADGROUPS[i], zoo_inv);850for (m = 0; m < ggg->form_no; m++){851ggg->form[m]->kgv = 1;852}853long_rein_formspace(ggg->form, ggg->form_no, 0);854855/* conjugate idempotents (the idempotents are equal for all856homogeneously decomposable lattices) */857conj_idem = (matrix_TYP **)calloc(idem_no, sizeof(matrix_TYP *));858ganzzahlig = 1;859for (m = 0; m < idem_no; m++){860conj_idem[m] = mat_kon(zoo_inv ,real_idem[m], inzidenz[i]->zoogitter[j][l]);861Check_mat(conj_idem[m]);862if (conj_idem[m]->kgv != 1){863ganzzahlig = 0;864}865}866867if (ganzzahlig == 1){868/* it's an homogeneously decomposable lattice */869group = ggg;870}871else{872/* calculate the minimal homogeneously decomposable superlattice */873lattice = hom_de_super(ggg, id, conj_idem, idem_no);874tmp = mat_inv(lattice);875group = konj_bravais(ggg, tmp);876for (f = 0; f < group->form_no; f++)877group->form[f]->kgv = 1;878long_rein_formspace(group->form, group->form_no, 1);879}880881/* which one of the old homogeneously decomposable lattices is it */882zoo_kon = special_deal_with_zclass(SUPER_INFO->tree, group, &zoo);883884if (ganzzahlig != 1){885if (zoo != i){886/* another zoo */887samezoo = 0;888}889else{890/* same zoo */891samezoo = 1;892}893Knoten = SUPER_INFO->tree->root;894for (f = 0; f < zoo; f++){895Knoten = Knoten->next;896}897zwischen = mat_kon(zoo_kon, Knoten->Q, better[zoo]);898ttt = mat_inv(zwischen);899zoolattice = mat_mul(ttt, tmp);900free_mat(ttt);901Knoten = NULL;902}903904/* free */905if (ganzzahlig == 1){906group = NULL;907}908else{909free_bravais(group);910}911for (m = 0; m < idem_no; m++){912free_mat(conj_idem[m]);913}914free(conj_idem);915free_bravais(ggg);916917/* which lattice in the zoo? */918aa = liste[i] + j;919920if (ganzzahlig == 1){921/* it is the homogeneously decomposable lattice */922bb = liste[zoo];923bahnnummer = 0;924}925else{926/* search in the tree */927zoolattice_hnf = copy_mat(zoolattice);928long_col_hnf(zoolattice_hnf);929node = SUPER_info[zoo]->tree->root;930yeah = 0;931while (node != NULL){932/* could be made better: compare el_div first */933if (in_bahn(zoolattice_hnf, node, &bahnnummer) == 1){934yeah = 1;935break;936}937node = node->next;938}939if (yeah == 0){940fprintf(stderr,"ERROR 1 in q2z!\n");941exit(3);942}943laeufer = node->child;944for (m = 0; m < node->N_no_orbits - bahnnummer; m++){945laeufer = laeufer->elder;946if (laeufer == NULL){947fprintf(stderr,"ERROR 2 in q2z!\n");948exit(2);949}950}951bahnnummer = suche_mat(laeufer->he->U, inzidenz[zoo]->gitter, inzidenz[zoo]->anz);952if (bahnnummer == -1){953fprintf(stderr,"ERROR 3 in q2z!\n");954exit(3);955}956bb = liste[zoo] + bahnnummer;957node = NULL;958959free_mat(zoolattice_hnf);960}961962/* write information in INZ */963help = INZ->entry[aa][bb].anz;964if (help == 0){965INZ->entry[aa][bb].I = (int *)calloc(1024, sizeof(int));966INZ->entry[aa][bb].J = (int *)calloc(1024, sizeof(int));967INZ->entry[aa][bb].flag = (int *)calloc(1024, sizeof(int));968INZ->entry[aa][bb].lattice = (matrix_TYP **)calloc(1024, sizeof(matrix_TYP *));969}970INZ->entry[aa][bb].I[help] = inzidenz[i]->entry[j][0].I[l];971INZ->entry[aa][bb].J[help] = inzidenz[i]->entry[j][0].J[l];972INZ->entry[aa][bb].flag[help] = inzidenz[i]->entry[j][0].flag[l];973974if (ganzzahlig == 1){975Knoten = SUPER_INFO->tree->root;976for (f = 0; f < zoo; f++){977Knoten = Knoten->next;978}979mat_muleq(inzidenz[i]->entry[j][0].lattice[l], inzidenz[i]->zoogitter[j][l]);980mat_muleq(inzidenz[i]->entry[j][0].lattice[l], zoo_kon);981mat_muleq(inzidenz[i]->entry[j][0].lattice[l], Knoten->Q);982mat_muleq(inzidenz[i]->entry[j][0].lattice[l], better[zoo]);983}984else{985zoolattice_inv = mat_inv(zoolattice);986X = konjugierende(zoolattice_inv, SUPER_info[zoo]->tree->root->col_group,987laeufer->he);988free_mat(zoolattice_inv);989if (X == NULL){990fprintf(stderr, "ERROR 4 in q2z!\n");991exit(9);992}993994/*995if (samezoo != 1){996mat_muleq(inzidenz[i]->entry[j][0].lattice[l], zentr_inv[j]);997mat_muleq(inzidenz[i]->entry[j][0].lattice[l], H->zentr[zoo]);998}999*/1000mat_muleq(inzidenz[i]->entry[j][0].lattice[l], inzidenz[i]->zoogitter[j][l]);1001/*1002mat_muleq(inzidenz[i]->entry[j][0].lattice[l], lattice);1003mat_muleq(inzidenz[i]->entry[j][0].lattice[l], zwischen);1004mat_muleq(inzidenz[i]->entry[j][0].lattice[l], zoolattice);1005*/1006mat_muleq(inzidenz[i]->entry[j][0].lattice[l], X);1007free_mat(X);1008free_mat(zoolattice);1009free_mat(lattice);1010free_mat(tmp);1011free_mat(zwischen);1012}1013INZ->entry[aa][bb].lattice[help] = inzidenz[i]->entry[j][0].lattice[l];1014Check_mat(INZ->entry[aa][bb].lattice[help]);1015INZ->entry[aa][bb].anz++;1016if (zoo_inv != NULL)1017free_mat(zoo_inv);1018free_mat(zoo_kon);1019}1020}1021ADGROUPS[i]->zentr_no = zen_nr;1022ADGROUPS[i]->normal_no = normal_nr;1023ADGROUPS[i]->cen_no = cen_nr;1024}10251026/* print the matrix of incidences for the Z-classes */1027/*1028test = init_mat(INZ->anz, INZ->anz, "");1029for (i = 0; i < INZ->anz; i++){1030for (j = 0; j < INZ->anz; j++){1031test->array.SZ[i][j] = INZ->entry[i][j].anz;1032}1033}1034put_mat(test,0,"graph for the arithmetic classes",0);1035free_mat(test);1036*/10371038/* calculate standard form for the lattices */1039for (i = 0; i < INZ->anz; i++){1040for (j = 0; j < INZ->anz; j++){1041if (INZ->entry[i][j].anz != 0){1042INZ->entry[i][j].lsf = (matrix_TYP **)calloc(INZ->entry[i][j].anz,1043sizeof(matrix_TYP *));1044for (k = 0; k < INZ->entry[i][j].anz; k++){1045INZ->entry[i][j].lsf[k] = copy_mat(INZ->entry[i][j].lattice[k]);1046long_col_hnf(INZ->entry[i][j].lsf[k]);1047}1048}1049}1050}1051}10521053if (!ADFLAG){1054GROUPS = get_groups(ADGROUPS,ad_no,number);1055}10561057/* clean up */1058if (!ADFLAG){1059for (i=0;i<ad_no;i++){1060free_bravais(ADGROUPS[i]);1061}1062free(ADGROUPS);1063}10641065if (GRAPH){1066/* free better, inzidenz, SUPER_info and SUPER_INFO (oliver: 9.8.00) */1067free_ZZ_super(SUPER_INFO);1068for (i = 0; i < ad_no; i++){1069free_mat(zentr_inv[i]);1070free_ZZ_super(SUPER_info[i]);1071free_QtoZ(inzidenz[i], 1);1072free_mat(better[i]);1073}1074free(zentr_inv);1075free(liste);1076free(SUPER_info);1077free(inzidenz);1078free(better);1079ZZ_get_data (NULL, NULL, NULL, NULL, NULL, NULL, -3);1080}10811082free_bravais(H);1083free_mat(id);1084free_mat(new_base);1085free_mat(F);1086for (i=0;i<idem_no+dimc+dimcc;i++){1087free_mat(IDEM[i]);1088}1089free(IDEM);1090for (i=0;i<idem_no;i++){1091free_mat(IDEM_SPACES[i]);1092}1093free(IDEM_SPACES);1094G->gen_no -= idem_no;10951096if (ADFLAG){1097number[0] = ad_no;1098return ADGROUPS;1099}1100else{1101return GROUPS;1102}1103}110411051106