Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418384#include <typedef.h>12#include <getput.h>3#include <matrix.h>4#include <orbit.h>5#include <bravais.h>6#include <base.h>7#include <tools.h>8#include <zass.h>9#include <datei.h>10#include <presentation.h>1112int INFO_LEVEL;13extern int SFLAG;1415matrix_TYP *translation_lattice(matrix_TYP **G,int number,matrix_TYP *P);1617int main(int argc,char **argv){1819bravais_TYP *G,20*H;2122matrix_TYP *X,23**XX,24**base,25*T,26**COZ;2728bahn **strong;2930int i,31j,32k,33type, /* TRUE iff the function has been called via34...Standart_affine_form */35kgv,36cozanz;3738char comment[1000],39file[1000];4041G = NULL;42H = NULL;43X = NULL;44T = NULL;4546read_header(argc,argv);4748#define OTHER_NAME "Standard_affine_form"49if (strlen(argv[0]) < strlen(OTHER_NAME)){50/* it can't have been called via .....OTHER_NAME */51type = FALSE;52}53else{54type = (strcmp(argv[0]+(strlen(argv[0])-strlen(OTHER_NAME)),55OTHER_NAME) == 0);56}575859if ((type && FILEANZ < 1) ||60(!type && ((is_option('h') && optionnumber('h')==0)||61(FILEANZ < 1) ||62((FILEANZ < 2) && (is_option('r')))))){63if (type){64printf("Usage: %s 'file1' 'file2' [-t]\n",argv[0]);65printf("\n");66printf("file1: bravais_TYP containing a space group G.\n");67printf("file2: matrix_TYP contatining a presentation of the point\n");68printf(" group of G.\n");69printf("\n");70printf("Transforms the space group with generators in file1 into standard\n");71printf("form, ie. the translation lattice is transformed to Z^n.\n");72printf("In case the translation subgroup has dimension smaller than n, i.\n");73printf("e. the group is not an n-dimensional space group, the program\n");74printf("will indicate an error, gives the rank, and exit.\n");75printf("\n");76printf("Options:\n");77printf("-t : The transforming matrix will be given as well.\n");78printf("\n");79printf("Cf. Extensions, Vector_systems\n");80printf("Note: This program is a synonym for Extract -t.\n");81}82else{83printf("Usage: %s 'file1' ['file2'] [-c] [-p] [-f] [-r [-D]] [-t=n]\n",argv[0]);84printf("\n");85printf("file1: bravais_TYP containing a space or (in case of option -r) a point group.\n");86printf("file2: matrix_TYP only used with options -r and -t, cf. below. \n");87printf("\n");88printf("Extracts the linear part of the affine (space) group in file1.\n");89printf("Note this is the point group of the space group in case the space \n");90printf("group is given in standard form.\n");91printf("\n");92printf("Options:\n");93printf("-p : extracts the linear part (default).\n");94printf("-c : extracts the translational part as a vector system (1-cozycle).\n");95printf("-f : do not calculate the formspace of the point group.\n");96printf("-r : reverses the process: Reads in the generators of the point group \n");97printf(" of file1 and multiple vector systems for these generators from file2 \n");98printf(" and outputs the resulting space groups. Overwrites any other option.\n");99printf("-D : this option only works together with '-r'. The spacegroups are written\n");100printf(" to 'file.i' with i = 1, ...\n");101printf("-t=n : transform the space group with generators in file1 into standard\n");102printf(" form, ie. the translation lattice is transformed to Z^n. If a \n");103printf(" parameter n>0 is specified, the transforming matrix will be\n");104printf(" given as well. NOTE: For the -t-option file2 must contain a \n");105printf(" presentation for the point group. If the translation lattice \n");106printf(" is of smaller rank, it will give the rank. Synonymous command:\n");107printf(" Standard_affine_form\n");108printf("-T : RESERVED\n");109printf("\n");110printf("Cf. Extensions, Vector_systems\n");111}112113114if (is_option('h')){115exit(0);116}117else{118exit(31);119}120}121122INFO_LEVEL = optionnumber('h');123124if (INFO_LEVEL & 12){125SFLAG = 1;126}127128G = get_bravais(FILENAMES[0]);129130if (is_option('t') || type){131132if (FILEANZ == 2){133XX = mget_mat(FILENAMES[1],&i);134if (i>1){135fprintf(stderr,"you should only give a single matrix as presention\n");136exit(3);137}138X = XX[0];139free(XX);140141}142else{143144/* get the point group */145H = init_bravais(G->dim-1);146H->gen_no = G->gen_no;147H->gen = (matrix_TYP **) malloc(H->gen_no * sizeof(matrix_TYP *));148for (i=0;i<H->gen_no;i++){149H->gen[i] = copy_mat(G->gen[i]);150real_mat(H->gen[i],G->dim,G->dim-1);151real_mat(H->gen[i],G->dim-1,G->dim-1);152}153154155/* calculate a presentation */156base = get_base(H);157158strong = strong_generators(base,H,TRUE);159160X = pres(strong,H,NULL);161162for (i=0;i<H->dim;i++){163free_mat(base[i]);164free_bahn(strong[i]);165free(strong[i]);166}167free(strong);168free(base);169free_bravais(H); H = NULL;170}171172if (is_option('T')){173real_mat(X,X->rows+G->dim-1,X->cols);174for (i=0;i<G->dim-1;i++){175X->array.SZ[X->rows-G->dim+1+i][0] = G->gen_no - i ;176}177}178179/* set the transformation matrix */180T = translation_lattice(G->gen,G->gen_no,X);181free_mat(X);182X = NULL;183184/* echo the rank if needed */185if (T->rows != T->cols){186fprintf(stderr,"The rank of the translation lattice is %d\n",T->cols);187exit(3);188}189190real_mat(T,T->rows+1,T->cols+1);191192/* paranoia */193rat2kgv(T);194195T->array.SZ[T->rows-1][T->cols-1] = T->kgv;196Check_mat(T);197198if ((optionnumber('t')>0 && !type) ||199(is_option('t') && type)){200sprintf(comment,"transformation matrix for space group in %s",201FILENAMES[0]);202put_mat(T,NULL,comment,2);203}204205/* we should also calculate a positive definite, point group206invariant form, and transform the group according to a mink_red207of this form. left for further development */208209/* now transform the group */210H = init_bravais(G->dim);211H->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));212H->gen_no = G->gen_no;213X = mat_inv(T);214for (i=0;i<H->gen_no;i++){215H->gen[i] = mat_kon(X,G->gen[i],T);216}217218sprintf(comment,"space group of %s on Z^n",219FILENAMES[0]);220put_bravais(H,NULL,NULL);221}222else{223if (is_option('r')){224COZ = mget_mat(FILENAMES[1], &cozanz);225for (k = 0; k < cozanz; k++){226rat2kgv(COZ[k]);227Check_mat(COZ[k]);228convert_cocycle_to_column(&COZ[k],1,G->dim,G->gen_no);229230/* is it a valid cozycle? */231if ((G->dim * G->gen_no != COZ[k]->rows) || (COZ[k]->cols != 1)){232fprintf(stderr,"The cozycle is not compatible to this point group\n");233fprintf(stderr,"It should have %d * %d = %d rows\n",G->dim,G->gen_no,234G->dim*G->gen_no);235exit(3);236}237H = init_bravais(G->dim+1);238H->gen_no = G->gen_no;239H->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));240241for (i=0;i<H->gen_no;i++){242H->gen[i] = copy_mat(G->gen[i]);243rat2kgv(H->gen[i]);244Check_mat(H->gen[i]);245real_mat(H->gen[i],H->dim,H->dim);246iscal_mul(H->gen[i],COZ[k]->kgv);247H->gen[i]->kgv = H->gen[i]->kgv * COZ[k]->kgv;248for (j=0;j<H->dim-1;j++)249H->gen[i]->array.SZ[j][H->dim-1] = COZ[k]->array.SZ[i*(H->dim-1)+j][0];250H->gen[i]->array.SZ[H->dim-1][H->dim-1] = COZ[k]->kgv;251Check_mat(H->gen[i]);252}253if (is_option('D')){254sprintf(file, "%s.%d", FILENAMES[0], k + 1);255sprintf(comment, "space group to the point group of %s and the %d-th cozycle of %s",256FILENAMES[0], k+1, FILENAMES[1]);257put_bravais(H, file, comment);258}259else{260sprintf(comment, "space group to the point group of %s and the %d-th cozycle of %s",261FILENAMES[0], k+1, FILENAMES[1]);262put_bravais(H, NULL, comment);263}264free_bravais(H);265free_mat(COZ[k]);266}267H = NULL;268free(COZ);269}270else if (is_option('p') || (!is_option('p') && ! is_option('c'))){271/* extract the point group */272H = init_bravais(G->dim-1);273274H->gen_no = G->gen_no;275H->gen = (matrix_TYP **) malloc(G->gen_no * sizeof(matrix_TYP *));276for (i=0;i<H->gen_no;i++){277H->gen[i] = copy_mat(G->gen[i]);278real_mat(H->gen[i],H->dim,G->dim);279real_mat(H->gen[i],H->dim,H->dim);280rat2kgv(H->gen[i]);281Check_mat(H->gen[i]);282}283284if (!is_option('f'))285H->form = formspace(H->gen,H->gen_no,1,&H->form_no);286287/* output */288sprintf(comment,"point group to the space group of %s",FILENAMES[0]);289put_bravais(H,NULL,comment);290free_bravais(H);291H = NULL;292}293if (is_option('c')){294X = init_mat(G->gen_no * (G->dim-1),1,"");295kgv = 1;296for (i=0;i<G->gen_no;i++){297rat2kgv(G->gen[i]);298kgv = kgv*G->gen[i]->kgv/GGT(kgv,G->gen[i]->kgv);299}300301302/* set the cozycle */303X->kgv = kgv;304for(i=0;i<G->gen_no;i++)305for (j=0;j<G->dim-1;j++)306X->array.SZ[i*(G->dim-1)+j][0] = X->kgv/G->gen[i]->kgv *307G->gen[i]->array.SZ[j][G->dim-1];308309Check_mat(X);310sprintf(comment,"cozycle to the group of %s",FILENAMES[0]);311put_cocycle(X,G->dim-1,G->gen_no,NULL,comment);312}313}314315/* cleaning up */316if (G!=NULL) free_bravais(G);317if (H!=NULL) free_bravais(H);318if (X!=NULL) free_mat(X);319if (T!=NULL) free_mat(T);320321exit(0);322323} /* main */324325326