GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
/* author: Oliver Heidbuechel */1/* last change: 13.09.2000 */234#include <ZZ.h>5#include <typedef.h>6#include <bravais.h>7#include<getput.h>8#include<matrix.h>9#include<longtools.h>10#include<tools.h>11#include"zass.h"12#include"symm.h"13#include"base.h"14#include"autgrp.h"15#include"voronoi.h"16#include"polyeder.h"17#include <graph.h>1819boolean GRAPH = FALSE;202122/* ---------------------------------------------------------------------------- */23/* Fill the structure Q_data_TYP for G, i.e. calculate various informations we */24/* need for calculating the indlusiongraph of subgroup relations in a Q-class */25/* pres has to be a correct presentation for G in Gl_n(Z) */26/* ---------------------------------------------------------------------------- */27Q_data_TYP *get_Q_data(bravais_TYP *G,28matrix_TYP *pres,29boolean l_option)30{31int i, j;3233Q_data_TYP *data;34353637data = (Q_data_TYP *)calloc(1, sizeof(Q_data_TYP));38data->G = copy_bravais(G);39data->pres = copy_mat(pres);40data->l_option = l_option;4142/* calculate the Z-classes */43data->INZ = (QtoZ_TYP *)calloc(1, sizeof(QtoZ_TYP));44GRAPH = TRUE;45data->Z = q2z(G, &data->Z_no, 0, data->INZ, 1);46cleanup_prime();47GRAPH = FALSE;4849/* affine classes */50data->all = 0;51data->aff_no = (int *)calloc(data->Z_no, sizeof(int));52data->WORDS = (int ****)calloc(data->Z_no, sizeof(int ***));53data->NUMBER_OF_WORDS = (int **)calloc(data->Z_no, sizeof(int *));54data->N = (matrix_TYP ***)calloc(data->Z_no, sizeof(matrix_TYP **));55data->X = (matrix_TYP ***)calloc(data->Z_no, sizeof(matrix_TYP **));56data->names = (MP_INT **)calloc(data->Z_no, sizeof(MP_INT *));57if (!data->l_option)58data->names_int = (int **)calloc(data->Z_no, sizeof(int *));59data->gen_inv = (matrix_TYP ***)calloc(data->Z_no, sizeof(matrix_TYP **));60data->coz = (matrix_TYP ***)calloc(data->Z_no, sizeof(matrix_TYP **));61data->norm_inv = (matrix_TYP ***)calloc(data->Z_no, sizeof(matrix_TYP **));62data->X_2_inv = (matrix_TYP **)calloc(data->Z_no, sizeof(matrix_TYP *));63data->coho_size = (int *)calloc(data->Z_no, sizeof(int));64data->stab_coz = (matrix_TYP ****)calloc(data->Z_no, sizeof(matrix_TYP ***));65data->stab_gen_no = (int **)calloc(data->Z_no, sizeof(int *));66data->first_aff = (int *)calloc(data->Z_no, sizeof(int));67data->list_of_names = (int **)calloc(data->Z_no, sizeof(int *));68for (i = 0; i < data->Z_no; i++){69cen_to_norm(data->Z[i]);70data->first_aff[i] = data->all;71data->WORDS[i] = (int ***)calloc(MIN_SPEICHER, sizeof(int **));72data->NUMBER_OF_WORDS[i] = (int *)calloc(MIN_SPEICHER, sizeof(int));73data->gen_inv[i] = (matrix_TYP **)calloc(data->Z[i]->gen_no, sizeof(matrix_TYP *));74data->coz[i] = all_cocycles(pres, data->Z[i], &data->aff_no[i], data->gen_inv[i],75&data->X[i], &data->names[i], &data->WORDS[i],76&data->NUMBER_OF_WORDS[i], &data->N[i], &data->coho_size[i],77&data->list_of_names[i], data->l_option);78data->all += data->aff_no[i];79data->norm_inv[i] = (matrix_TYP **)calloc(data->Z[i]->normal_no, sizeof(matrix_TYP *));80for (j = 0; j < data->Z[i]->normal_no; j++){81data->norm_inv[i][j] = mat_inv(data->Z[i]->normal[j]);82}83data->X_2_inv[i] = mat_inv(data->X[i][2]);84data->stab_coz[i] = (matrix_TYP ***)calloc(data->aff_no[i], sizeof(matrix_TYP **));85data->stab_gen_no[i] = (int *)calloc(data->aff_no[i], sizeof(int));86for (j = 0; j < data->aff_no[i]; j++){87data->stab_coz[i][j] = stab_coz(data->WORDS[i][j], data->NUMBER_OF_WORDS[i][j],88data->Z[i]->normal, data->norm_inv[i],89data->Z[i]->normal_no, j, &data->stab_gen_no[i][j]);90}91}9293/* put cocycles and pointgroup together */94data->aff = (bravais_TYP ***)calloc(data->Z_no, sizeof(bravais_TYP **));95for (i = 0; i < data->Z_no; i++){96data->aff[i] = (bravais_TYP **)calloc(data->aff_no[i], sizeof(bravais_TYP *));97if (!data->l_option)98data->names_int[i] = (int *)calloc(data->aff_no[i], sizeof(int));99for (j = 0; j < data->aff_no[i]; j++){100if (!data->l_option)101data->names_int[i][j] = mpz_get_ui(&data->names[i][j]);102data->aff[i][j] = extract_r(data->Z[i], data->coz[i][j]);103}104}105return(data);106}107108109110111/* ---------------------------------------------------------------------------- */112/* Write the number of Z-classes and affine classes in each Z-class to stdout! */113/* If printflag, we write the Z-classes and affine classes in files. */114/* data->aff, data->aff_no, data->Z, data->Z_no have to be filled correctly */115/* and completely */116/* ---------------------------------------------------------------------------- */117void put_Q_data(Q_data_TYP *data,118char *groupname,119int printflag)120{121int i, j;122123char comment[1000],124file[1000];125126matrix_TYP *form, *id;127128id = init_mat(data->G->dim, data->G->dim, "1");129130if (printflag){131for (i = 0; i < data->Z_no; i++){132sprintf(comment, "%d-th Z-class of %s", i+1, groupname);133sprintf(file, "%s.%d",groupname, i+1);134put_bravais(data->Z[i], file, comment);135136form = rform(data->Z[i]->gen, data->Z[i]->gen_no, id, 100);137sprintf(comment, "form of the %d-th Z-class of %s", i+1, groupname);138sprintf(file, "form.%s.%d",groupname, i+1);139put_mat(form, file, comment,0);140free_mat(form);141142for (j = 0; j < data->aff_no[i]; j++){143sprintf(comment, "%d-th affine class of the %d-th Z-class of %s",144j+1, i+1, groupname);145sprintf(file, "%s.%d.%d", groupname, i+1, j+1);146put_bravais(data->aff[i][j], file, comment);147}148}149}150151printf("There are %i Z-Classes with ", data->Z_no);152for (i = 0; i < data->Z_no; i++){153printf("%i ",data->aff_no[i]);154}155printf("Space Groups!\n");156157free_mat(id);158}159160161162/* ---------------------------------------------------------------------------- */163/* Free the structure Q_data_TYP */164/* data has to be filled correctly and completely */165/* ---------------------------------------------------------------------------- */166void free_Q_data(Q_data_TYP *data)167{168int i, j, k, Nanz;169170171if (data->first_aff){172free(data->first_aff);173}174if (data->names_int){175for (i = 0; i < data->Z_no; i++){176if (data->names_int[i] != NULL)177free(data->names_int[i]);178}179free(data->names_int);180}181if (data->list_of_names){182for (i = 0; i < data->Z_no; i++){183if (data->list_of_names[i] != NULL)184free(data->list_of_names[i]);185}186free(data->list_of_names);187}188if (data->stab_coz){189for (i = 0; i < data->Z_no; i++){190for (j = 0; j < data->aff_no[i]; j++){191for (k = 0; k < data->stab_gen_no[i][j]; k++){192free_mat(data->stab_coz[i][j][k]);193}194free(data->stab_coz[i][j]);195}196free(data->stab_coz[i]);197}198free(data->stab_coz);199}200if (data->stab_gen_no){201for (i = 0; i < data->Z_no; i++){202if (data->stab_gen_no[i] != NULL)203free(data->stab_gen_no[i]);204}205free(data->stab_gen_no);206}207if (data->norm_inv){208for (i = 0; i < data->Z_no; i++){209for (j = 0; j < data->Z[i]->normal_no; j++)210free_mat(data->norm_inv[i][j]);211free(data->norm_inv[i]);212}213free(data->norm_inv);214}215if (data->gen_inv){216for (i = 0; i < data->Z_no; i++){217for (j = 0; j < data->Z[i]->gen_no; j++)218if (data->gen_inv[i][j])219free_mat(data->gen_inv[i][j]);220free(data->gen_inv[i]);221}222free(data->gen_inv);223}224if (data->N){225for (i = 0; i < data->Z_no; i++){226if (data->N[i] != NULL){227Nanz = data->Z[i]->cen_no + data->Z[i]->normal_no;228for (j = 0; j < Nanz; j++)229free_mat(data->N[i][j]);230free(data->N[i]);231}232}233free(data->N);234}235if (data->WORDS && data->NUMBER_OF_WORDS && data->X){236for (i = 0; i < data->Z_no; i++){237if (data->X[i][0]->cols >= 1){238for (j = 0; j < data->aff_no[i]; j++){239for (k = 0; k < data->NUMBER_OF_WORDS[i][j]; k++){240free(data->WORDS[i][j][k]);241}242free(data->WORDS[i][j]);243}244}245free(data->WORDS[i]);246free(data->NUMBER_OF_WORDS[i]);247}248free(data->WORDS);249free(data->NUMBER_OF_WORDS);250}251if (data->X){252for (i = 0; i < data->Z_no; i++){253for (j = 0; j < 3; j++){254if (data->X[i][j] != NULL) free_mat(data->X[i][j]);255}256free(data->X[i]);257}258free(data->X);259}260if (data->X_2_inv){261for (i = 0; i < data->Z_no; i++){262if (data->X_2_inv[i] != NULL) free_mat(data->X_2_inv[i]);263}264free(data->X_2_inv);265}266if (data->names)267{268for (i = 0; i < data->Z_no; i++)269{270if (data->names[i] != NULL)271{272for (j = 0; j < data->aff_no[i]; j++)273mpz_clear(data->names[i] + j);274free(data->names[i]);275}276}277free(data->names);278}279if (data->coho_size){280free(data->coho_size);281}282free_QtoZ(data->INZ, 0);283for (i = 0; i < data->Z_no; i++){284for (j = 0; j < data->aff_no[i]; j++){285free_bravais(data->aff[i][j]);286free_mat(data->coz[i][j]);287}288free_bravais(data->Z[i]);289free(data->aff[i]);290free(data->coz[i]);291}292free(data->aff_no);293free(data->aff);294free(data->coz);295free(data->Z);296free_bravais(data->G);297free_mat(data->pres);298free(data);299}300301302303304305306307308309310311312