new boxes

This commit is contained in:
Florian Stecker 2018-04-26 15:01:22 +02:00
parent 5d12e4cbb8
commit 51bef29894
3 changed files with 8 additions and 148 deletions

View File

@ -1,16 +1,16 @@
HEADERS=triangle.h linalg.h queue.h
SPECIAL_OPTIONS=-O0 -g -D_DEBUG
#SPECIAL_OPTIONS=-O0 -g -D_DEBUG
#SPECIAL_OPTIONS=-O3 -pg -funroll-loops -fno-inline
#SPECIAL_OPTIONS=-O3 -flto -funroll-loops -Winline
SPECIAL_OPTIONS=-O3 -flto -funroll-loops -Winline
#SPECIAL_OPTIONS=
OPTIONS=-m64 -march=native -mtune=native -std=gnu99 -D_GNU_SOURCE $(SPECIAL_OPTIONS)
all: triangle_group element_path limit_set
all: singular_values element_path limit_set
triangle_group: triangle.o linalg.o main.o
gcc $(OPTIONS) -o triangle_group triangle.o linalg.o main.o -lm -lgsl -lcblas
singular_values: singular_values.o triangle.o linalg.o
gcc $(OPTIONS) -o singular_values triangle.o linalg.o singular_values.o -lm -lgsl -lcblas
element_path: element_path.o linalg.o
gcc $(OPTIONS) -o element_path element_path.o linalg.o -lm -lgsl -lcblas
@ -18,8 +18,8 @@ element_path: element_path.o linalg.o
limit_set: limit_set.o linalg.o triangle.o
gcc $(OPTIONS) -o limit_set limit_set.o linalg.o triangle.o -lm -lgsl -lcblas
main.o: main.c $(HEADERS)
gcc $(OPTIONS) -c main.c
singular_values.o: singular_values.c $(HEADERS)
gcc $(OPTIONS) -c singular_values.c
element_path.o: element_path.c $(HEADERS)
gcc $(OPTIONS) -c element_path.c
@ -34,4 +34,4 @@ limit_set.o: limit_set.c $(HEADERS)
gcc $(OPTIONS) -c limit_set.c
clean:
rm -f triangle_group element_path limit_set triangle.o linalg.o main.o element_path.o limit_set.o
rm -f singular_values element_path limit_set triangle.o linalg.o singular_values.o element_path.o limit_set.o

120
main.c
View File

@ -1,120 +0,0 @@
#include "triangle.h"
#include "linalg.h"
#define MAX_ELEMENTS 10000
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], 0, 1, 2*s*cos(M_PI*a1));
gsl_matrix_set(gen[0], 0, 2, 2/s*cos(M_PI*a2));
gsl_matrix_set(gen[1], 1, 0, 2/s*cos(M_PI*a1));
gsl_matrix_set(gen[1], 1, 1, -1);
gsl_matrix_set(gen[1], 1, 2, 2*s*cos(M_PI*a3));
gsl_matrix_set(gen[2], 2, 0, 2*s*cos(M_PI*a2));
gsl_matrix_set(gen[2], 2, 1, 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, 2.0/5.0, 2.0/5.0, 2.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;
}

View File

@ -1,20 +0,0 @@
#if(!exists("param")) param = log(0.3810364354550512)
if(!exists("param")) param = log(2.764)
print sprintf("param = %f", exp(param))
file = sprintf("< ./triangle_group %f", exp(param))
set zeroaxis
set size square
set xrange [0:20]
set yrange [0:20]
set grid
set parametric
plot file using 2:3 w p pt 7 ps 0.5 lc 1 t ""
pause mouse keypress
if(MOUSE_KEY == 60) param=param-0.02
if(MOUSE_KEY == 62) param=param+0.02
if(MOUSE_KEY == 13) param=log(2.764)
if(MOUSE_KEY != 113) reread