GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
1#include <signal.h>2#include "typedef.h"3#include "getput.h"4#include "tools.h"5#include "bravais.h"6#include "orbit.h"7#include "base.h"8#include "matrix.h"9#include "longtools.h"10#include "voronoi.h"11#include "sort.h"12#include "reduction.h"13#include "autgrp.h"14#include "ZZ_P.h"15#include "ZZ_irr_const_P.h"16#include "ZZ_lll_P.h"17#include "ZZ_cen_fun_P.h"18#include "ZZ_zclass_P.h"1920extern int INFO_LEVEL;212223static int position(matrix_TYP **a,matrix_TYP *x,int n)24/* returns the first index i<n such that a[i] == x, and25-1 if none exists */26{27int i=0;2829while (i<n){30if (mat_comp(a[i],x) == 0){31return i;32}33i++;34}35return -1;36}373839/*------------------------------------------------------------------------------- */40static matrix_TYP *is_conjugated_ZZ(n,new)41ZZ_node_t *n, *new;42{43int i,44Nanz;4546matrix_TYP *Tmp1,47*Tmp2,48*A,49*X = NULL,50**BASE,51**N;5253bravais_TYP *H=NULL;5455/* save the normailzer of n->colgroup in case it exits */56N = n->col_group->normal;57Nanz = n->col_group->normal_no;58n->col_group->normal = NULL;59n->col_group->normal_no = 0;6061/* bare in mind that is_z_equivalent has got an sideefect in62calculating the normalizer of the bravais group of the first63argument, and that it only calculates an isometry of formspaces. */64Tmp1 = is_z_equivalent_datei(n->col_group,65n->group,new->col_group,new->group,&n->perfect,&n->perfect_no);6667/* look whether we already got the bravais group n->brav */68if (n->brav == NULL){69n->brav = bravais_group(n->col_group,TRUE);70}7172if (n->col_group->normal != NULL &&73n->col_group->normal_no > 0){74/* stick the normalizer to the bravais group */75n->brav->normal = n->col_group->normal;76n->brav->normal_no = n->col_group->normal_no;77}7879n->col_group->normal = N;80n->col_group->normal_no = Nanz;8182if (Tmp1 != NULL){83/* we should get a stabchain for n->col_group */84if (n->stab_chain == NULL){85BASE = get_base(n->col_group);86n->stab_chain=strong_generators(BASE,n->col_group,FALSE);87/* free the base again */88for (i=0;i<n->col_group->dim;i++){89free_mat(BASE[i]);90}91free(BASE);92}9394Tmp2 = long_mat_inv(Tmp1);95H = konj_bravais(new->col_group,Tmp2);96free_mat(Tmp2);9798/* now we are in the position to look if H and n->col_group99are conjugated */100Nanz = n->brav->gen_no + n->brav->normal_no;101N = (matrix_TYP **) malloc(Nanz * sizeof(matrix_TYP *));102for (i=0;i<Nanz;i++){103if (i<n->brav->gen_no){104N[i] = n->brav->gen[i];105}106else{107N[i] = n->brav->normal[i-n->brav->gen_no];108}109}110111if (n->brav->normal_no == 0){112fprintf(stderr,113"ZZ_zclass: bravais group has no normalizer\n");114exit(3);115}116117A = conjugated(n->col_group,H,N,Nanz,118n->stab_chain);119120free(N);121122if (A == NULL){123free_mat(Tmp1);124}125else{126X = mat_mul(Tmp1, A);127free_mat(A);128free_mat(Tmp1);129}130}131132if (H!=NULL){133free_bravais(H);134}135136137return (X);138}139140141142/*------------------------------------------------------------------------------- */143int deal_with_ZCLASS(data, tree, father, new)144ZZ_data_t *data;145ZZ_tree_t *tree;146ZZ_node_t *father, *new;147{148149int f,150g;151152bravais_TYP *H;153154ZZ_node_t *n;155156matrix_TYP *X;157158159160/* now calculate the (integral) representation161on the new lattice (bare in mind that it is162row invariant. There is a flaw: normalizer and163centralizer won't be correct */164f = tree->root->group->normal_no;165tree->root->group->normal_no=0;166g = tree->root->group->cen_no;167tree->root->group->cen_no=0;168new->group = konj_bravais(tree->root->group,new->U);169tree->root->group->normal_no = f;170tree->root->group->cen_no = g;171172/* the second flaw of konj_bravais is the formspace */173for (f=0;f<new->group->form_no;f++)174new->group->form[f]->kgv = 1;175long_rein_formspace(new->group->form,new->group->form_no,1);176177new->col_group = tr_bravais(new->group,1,FALSE);178179/* see if we've got an Z-equivalent rep. already */180n = tree->root;181while (n != NULL){182X = is_conjugated_ZZ(n,new);183if (X != NULL){184free_mat(X);185return TRUE;186}187n = n->next;188}189190/* exit(3); */191192return FALSE;193}194195196197198/* -------------------------------------------------------------------------- */199matrix_TYP *special_deal_with_zclass(ZZ_tree_t *tree,200bravais_TYP *group,201int *nr)202{203ZZ_node_t *n,204*new;205206matrix_TYP *X;207208209nr[0] = 0;210new = (ZZ_node_t *)calloc(1, sizeof(ZZ_node_t));211new->col_group = group;212new->group = tr_bravais(group, 1, FALSE);213214n = tree->root;215while (n != NULL){216X = is_conjugated_ZZ(n, new);217if (X != NULL){218free_bravais(new->group);219new->col_group = NULL;220free(new);221n = NULL;222return(X);223}224nr[0]++;225n = n->next;226}227228fprintf(stderr,"ERROR in special_deal_with_zclass\n");229exit(4);230}231232233234235/*------------------------------------------------------------------------------- */236static int is_contained(matrix_TYP *U,matrix_TYP *V)237{238239int i,240j,241k,242sum;243244for (i=0;i<U->cols;i++){245for (j=0;j<U->rows;j++){246sum = 0;247for (k=0;k<U->rows;k++){248sum += (V->array.SZ[i][k] * U->array.SZ[k][j]);249}250if ((sum % V->kgv) != 0)251return FALSE;252}253}254255return TRUE;256/*257matrix_TYP *tmp;258259tmp = mat_mul(V,U);260261Check_mat(tmp);262263if (tmp->kgv == 1){264free_mat(tmp);265return TRUE;266}267else{268free_mat(tmp);269return FALSE;270}271*/272273}274275276277/*------------------------------------------------------------------------------- */278static int suche_mat(matrix_TYP *mat,279matrix_TYP **liste,280int anz)281{282int i;283284for (i = 0; i < anz; i++){285if (cmp_mat(mat, liste[i]) == 0)286return(i);287}288return(-1);289}290291292293/*------------------------------------------------------------------------------- */294int in_bahn(matrix_TYP *lattice,295ZZ_node_t *father,296int *i)297{298int flag = 0;299300301302for (i[0] = 0; i[0] < father->N_no_orbits && !flag; i[0]++){303flag = (mat_search(lattice, father->N_orbits[i[0]], father->N_lengths[i[0]], mat_comp) != -1);304}305306return(flag);307}308309310311/*------------------------------------------------------------------------------- */312int orbit_under_normalizer(data,tree,father,new,ii,jj,inzidenz,nr,nnn)313ZZ_data_t *data;314ZZ_tree_t *tree;315ZZ_node_t *father, *new;316int ii, jj;317QtoZ_TYP *inzidenz;318int *nr;319ZZ_node_t **nnn;320{321322int i__,323j__,324i, pos, oflag = 0,325father_flag = FALSE,326flag = FALSE;327328static int orb[6];329330matrix_TYP *tmp;331332ZZ_node_t *p;333334ZZ_couple_t *laeufer;335336bravais_TYP *G;337338orb[0]=0;339orb[1]=4;340341tmp = copy_mat(new->U);342long_row_hnf(tmp);343ZZ_transpose_array(tmp->array.SZ,tmp->cols);344345/* search the whole tree */346p = tree->root;347while (p!= NULL){348for (i__=0;i__<p->N_no_orbits && p->level==father->level && !flag;i__++){349flag = (mat_search(tmp,p->N_orbits[i__], p->N_lengths[i__],mat_comp) != -1);350}351if (flag)352break;353p = p->next;354}355356/* search the father357p = father;358for (i__=0;i__<p->N_no_orbits && !father_flag;i__++){359father_flag = (mat_search(tmp,p->N_orbits[i__],360p->N_lengths[i__]) != -1);361} */362free_mat(tmp);363364/* next 14 lines: oliver 10.8.00: graph for QtoZ */365if (flag && GRAPH){366laeufer = p->child;367for (i = 0; i < p->N_no_orbits - i__; i++){368laeufer = laeufer->elder;369if (laeufer == NULL){370fprintf(stderr,"ERROR 1 in orbit_under_normalizer!\n");371exit(2);372}373}374nnn[0] = laeufer->he;375nr[0] = suche_mat(laeufer->he->U, inzidenz->gitter, inzidenz->anz);376if (nr[0] == -1){377fprintf(stderr,"ERROR 2 in orbit_under_normalizer!\n");378exit(3);379}380}381/* else { */382p = father;383if (!flag){384/* p = father; */385tmp = tr_pose(new->U);386if (p->N_no_orbits == 0){387p->N_orbits = (matrix_TYP ***) malloc(1 *388sizeof(matrix_TYP **));389p->N_lengths = (int *) malloc(1 * sizeof(int));390}391else{392p->N_orbits = (matrix_TYP ***) realloc(p->N_orbits,393(p->N_no_orbits+1)* sizeof(matrix_TYP **));394p->N_lengths = (int *) realloc(p->N_lengths,395(p->N_no_orbits + 1) * sizeof(int));396}397398G = init_bravais(tree->root->group->dim);399400/* tilman: changed on 06.05.1998:401G->gen_no = tree->root->col_group->normal_no;402G->gen = tree->root->col_group->normal; */403G->gen_no = tree->root->group->normal_no;404G->gen = tree->root->group->normal;405406p->N_orbits[p->N_no_orbits] = orbit_alg(tmp,G,NULL,orb,407&p->N_lengths[p->N_no_orbits]);408409/* sort it */410mat_quicksort(p->N_orbits[p->N_no_orbits],0,411p->N_lengths[p->N_no_orbits]-1,mat_comp);412413p->N_no_orbits++;414415G->gen_no = 0;416G->gen = NULL;417free_bravais(G);418free_mat(tmp);419}420421if (!flag){422fprintf(stderr,"father: level %d number of orbits %d lengths %d\n",423p->level,p->N_no_orbits,p->N_lengths[p->N_no_orbits-1]);424}425426if (INFO_LEVEL & 8){427if (flag || father_flag){428fprintf(stderr,"returned TRUE\n");429}430else{431fprintf(stderr,"returned FALSE\n");432}433}434435return (flag || father_flag);436437}438439440441/* ---------------------------------------------------------------------------------------- */442matrix_TYP *konjugierende(matrix_TYP *Li,443bravais_TYP *G,444ZZ_node_t *n)445{446ZZ_node_t *new;447448matrix_TYP *X;449450bravais_TYP *group;451452int f, g;453454455456f = G->normal_no; G->normal_no = 0;457g = G->cen_no; G->cen_no = 0;458group = konj_bravais(G, Li);459G->normal_no = f;460G->cen_no = g;461for (f = 0; f < group->form_no; f++)462group->form[f]->kgv = 1;463long_rein_formspace(group->form, group->form_no, 1);464465new = (ZZ_node_t *)calloc(1, sizeof(ZZ_node_t));466new->col_group = group;467new->group = tr_bravais(group, 1, FALSE);468469X = is_conjugated_ZZ(n, new);470471/* clean */472free_bravais(new->group);473free_bravais(new->col_group);474free(new);475476return(X);477}478479480481482483484485486487488489490491