#include "triangle.h" #include "linalg.h" #define MAX_ELEMENTS 20000 void initialize_triangle_generators(gsl_matrix **gen, double a1, double a2, double a3, double s) { for(int i = 0; i < 3; i++) gsl_matrix_set_identity(gen[i]); gsl_matrix_set(gen[0], 0, 0, -1); gsl_matrix_set(gen[0], 1, 0, 2*s*cos(M_PI*a1)); gsl_matrix_set(gen[0], 2, 0, 2/s*cos(M_PI*a2)); gsl_matrix_set(gen[1], 0, 1, 2/s*cos(M_PI*a1)); gsl_matrix_set(gen[1], 1, 1, -1); gsl_matrix_set(gen[1], 2, 1, 2*s*cos(M_PI*a3)); gsl_matrix_set(gen[2], 0, 2, 2*s*cos(M_PI*a2)); gsl_matrix_set(gen[2], 1, 2, 2/s*cos(M_PI*a3)); gsl_matrix_set(gen[2], 2, 2, -1); } char *print_word(groupelement_t *g, char *str) { int i = g->length - 1; str[g->length] = 0; while(g->parent) { str[i--] = 'a' + g->letter; g = g->parent; } return str; } int main(int argc, char *argv[]) { groupelement_t *group; workspace_t *ws; gsl_matrix **matrices; gsl_matrix *gen[3]; gsl_matrix *tmp, *tmp2, *coxeter; double mu[2]; char buf[100]; if(argc < 2) { fprintf(stderr, "Too few arguments!\n"); return 1; } // allocate stuff group = malloc(MAX_ELEMENTS*sizeof(groupelement_t)); ws = workspace_alloc(3); matrices = malloc(MAX_ELEMENTS*sizeof(gsl_matrix*)); for(int i = 0; i < MAX_ELEMENTS; i++) matrices[i] = gsl_matrix_alloc(3, 3); for(int i = 0; i < 3; i++) gen[i] = gsl_matrix_alloc(3, 3); tmp = gsl_matrix_alloc(3, 3); tmp2 = gsl_matrix_alloc(3, 3); coxeter = gsl_matrix_alloc(3, 3); // the real action generate_triangle_group(group, MAX_ELEMENTS, 5, 9, 7); // initialize_triangle_generators(gen, 1.0/5, 1.0/5, 1.0/5, 1.0); // Fuchsian initialize_triangle_generators(gen, 3.0/5.0, 3.0/5.0, 3.0/5.0, atof(argv[1])); gsl_matrix_set_identity(matrices[0]); for(int i = 1; i < MAX_ELEMENTS; i++) multiply(matrices[group[i].parent->id], gen[group[i].letter], matrices[i]); for(int i = 0; i < MAX_ELEMENTS; i++) { cartan_calc(matrices[i], mu, ws); printf("%d %f %f 0x0000ff %s\n", group[i].length, mu[0], mu[1], print_word(&group[i], buf)); //invert(matrices[i], tmp, ws); //printf("%d %f %f %f 0x0000ff\n", group[i].length, determinant(matrices[i], ws)*trace(matrices[i]), determinant(matrices[i], ws)*trace(tmp), determinant(matrices[i], ws)); } /* for(int p = 0; p < 6; p++) { groupelement_t *cur = &group[0]; while(1) { if(!(cur = cur->adj[p%3])) break; cartan_calc(matrices[cur->id], mu, ws); printf("%d %f %f 0xff0000\n", group[cur->id].length, mu[0], mu[1]); if(!(cur = cur->adj[(p+p/3+1)%3])) break; cartan_calc(matrices[cur->id], mu, ws); printf("%d %f %f 0xff0000\n", group[cur->id].length, mu[0], mu[1]); if(!(cur = cur->adj[(p-p/3+2)%3])) break; cartan_calc(matrices[cur->id], mu, ws); printf("%d %f %f 0xff0000\n", group[cur->id].length, mu[0], mu[1]); // invert(matrices[cur->id], tmp, ws); // printf("%d %f %f %f 0xff0000\n", group[cur->id].length, determinant(matrices[cur->id], ws)*trace(matrices[cur->id]), determinant(matrices[cur->id], ws)*trace(tmp), determinant(matrices[cur->id], ws)); } } */ // free stuff for(int i = 0; i < MAX_ELEMENTS; i++) gsl_matrix_free(matrices[i]); for(int i = 0; i < 3; i++) gsl_matrix_free(gen[i]); gsl_matrix_free(tmp); gsl_matrix_free(tmp2); gsl_matrix_free(coxeter); free(matrices); free(group); workspace_free(ws); return 0; }