GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
#include"typedef.h"1#include"longtools.h"2#include"matrix.h"3#include"base.h"45extern int INFO_LEVEL;6/**************************************************************************7@8@ -------------------------------------------------------------------------9@ FILE: conjugate.c10@ -------------------------------------------------------------------------11@12***************************************************************************/1314/***********************************************************************15@16@ -------------------------------------------------------------------------17@18@ matrix_TYP *conjugated(bravais_TYP *G,bravais_TYP *H,19@ matrix_TYP **N,int Nanz,bahn **strong)20@ Suppose the matrices in G->gen, H->gen generate finite matrix groups, and N21@ generates a matrix group with the condition that the orbit of N22@ on the conjugated of G under N is finite. Then the algorithm decides23@ whether G is conjugated to a supergroup of H, and if so gives an element24@ conjugating G over H, i.e H<= X * G * X^-1 for the result of this function.25@ Declaration of variables:26@ G: matrices generating G,27@ H:28@ N:29@ strong: a set of base/strong generators for G returned by30@ strong_generators31@32@ Sideefects: None of the variables given nor global variables should33@ be affected.34@35@ -------------------------------------------------------------------------36@37***********************************************************************/38matrix_TYP *conjugated(bravais_TYP *G,bravais_TYP *H,39matrix_TYP **N,int Nanz,bahn **strong)40{4142matrix_TYP **orbit, /* represents the orbit of G under N by the43conjugating element */44*test_subgroup,45*tmp,46*tmp2,47*tmp3,48*tmp4,49*erg = NULL;5051int found=1, /* number of conjugated subgroups found so far */52dealt=0, /* number of those dealt with */53i,54j,55k,56flag;5758if (INFO_LEVEL & 4){59fprintf(stderr,"entering conjugated\n");60}616263/* let's see whether H is not already a Subgroup of G */64flag = TRUE;65k = 0;66while ((k<H->gen_no) && flag){67if (!is_element(H->gen[k],G,strong,NULL)){68flag = FALSE;69}70k++;71}72/* if it was, leave instantly */73if (flag){74erg = init_mat(G->gen[0]->cols,G->gen[0]->cols,"1");75return(erg);76}7778orbit = (matrix_TYP **) malloc(1*sizeof(matrix_TYP *));79orbit[0] = init_mat(G->gen[0]->cols,G->gen[0]->cols,"1");8081/* start the obit calculation */82while ((dealt<found) && (erg == NULL)){8384/* output for debugging */85if (INFO_LEVEL & 4){86fprintf(stderr,"got %i conjugated subgroups so far\n",found);87fprintf(stderr,"dealt with %i of these\n",dealt);88}89/* loop over the generators of N */90for (i=0;(i<Nanz) & (erg == NULL);i++){9192/* calculating the new element */93test_subgroup = mat_mul(orbit[dealt],N[i]);9495/* see if this gives really a new element */96j=0;97tmp = mat_inv(test_subgroup);98while ((test_subgroup != NULL) && (j< found)){99tmp2 = mat_mul(orbit[j],tmp);100tmp3 = mat_inv(tmp2);101k=0;102flag = TRUE;103while (flag && (k<G->gen_no)){104tmp4 = mat_mul(tmp2,G->gen[k]);105tmp4 = mat_muleq(tmp4,tmp3);106if (!is_element(tmp4,G,strong,NULL)){107flag = FALSE;108}109free_mat(tmp4);110k++;111}112113if (flag){114free_mat(test_subgroup);115test_subgroup = NULL;116}117free_mat(tmp2);118free_mat(tmp3);119j++;120}121122/* if it was a new element, we should memorize it and check whether123is over H */124if ( test_subgroup!= NULL){125/* so let's see whether it is really over H */126flag = TRUE;127k=0;128while(flag && (k<H->gen_no)){129tmp2 = mat_mul(test_subgroup,H->gen[k]);130mat_muleq(tmp2,tmp);131if (!is_element(tmp2,G,strong,NULL)){132flag = FALSE;133}134free_mat(tmp2);135k++;136}137/* get more memory */138orbit = (matrix_TYP **) realloc(orbit,(found+1)*sizeof(matrix_TYP*));139orbit[found] = test_subgroup;140found++;141if (flag){ erg = long_mat_inv(test_subgroup); }142}143144free_mat(tmp);145146} /* for (i= .... */147dealt++;148}149150151/* cleaning up memory */152for (i=0;i<found;i++){153free_mat(orbit[i]);154}155free(orbit);156157return erg;158}159160161162