From 15681c308b26cff66ab9682bd9e84e625a3d1215 Mon Sep 17 00:00:00 2001 From: Florian Stecker Date: Mon, 13 Jun 2022 12:05:34 +0200 Subject: [PATCH] import enumerate.c and generators.c, prepare Makefile --- Makefile | 50 ++------ complex_anosov.c | 13 ++ enumerate.c | 24 ++++ enumerate.h | 9 ++ generators.c | 111 ++++++++++++++++++ generators.h | 9 ++ .../enumerate_triangle_group.c | 0 .../enumerate_triangle_group.h | 0 singular_values.c => old/singular_values.c | 0 .../singular_values_barbot.c | 0 parallel.c => parallelization/parallel.c | 0 parallel.h => parallelization/parallel.h | 0 12 files changed, 178 insertions(+), 38 deletions(-) create mode 100644 complex_anosov.c create mode 100644 enumerate.c create mode 100644 enumerate.h create mode 100644 generators.c create mode 100644 generators.h rename enumerate_triangle_group.c => old/enumerate_triangle_group.c (100%) rename enumerate_triangle_group.h => old/enumerate_triangle_group.h (100%) rename singular_values.c => old/singular_values.c (100%) rename singular_values_barbot.c => old/singular_values_barbot.c (100%) rename parallel.c => parallelization/parallel.c (100%) rename parallel.h => parallelization/parallel.h (100%) diff --git a/Makefile b/Makefile index 5766967..daf8750 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -HEADERS=linalg.h mat.h coxeter.h enumerate_triangle_group.h parallel.h qext.h +HEADERS=mat.h coxeter.h enumerate.h generators.h qext.h SPECIAL_OPTIONS=-O0 -g -D_DEBUG -DQEXT #SPECIAL_OPTIONS=-O3 -pg -g -funroll-loops -fno-inline @@ -7,44 +7,21 @@ SPECIAL_OPTIONS=-O0 -g -D_DEBUG -DQEXT #SPECIAL_OPTIONS= OPTIONS=-I../mps/include -L../mps/lib -pthread -m64 -std=gnu99 -D_GNU_SOURCE $(SPECIAL_OPTIONS) +CC=gcc -all: singular_values special_element convert billiard_words +all: complex_anosov -convert: convert.hs - ghc --make -dynamic convert.hs +complex_anosov: complex_anosov.o mat.o coxeter.o enumerate.o generators.o qext.o + $(CC) $(OPTIONS) -o complex_anosov -lm complex_anosov.o mat.o coxeter.o enumerate.o generators.o qext.o -lgmp -lmps -billiard_words: billiard_words.hs - ghc --make -dynamic billiard_words.hs +complex_anosov.o: complex_anosov.c $(HEADERS) + gcc $(OPTIONS) -c complex_anosov.c -singular_values: singular_values.o coxeter.o mat.o enumerate_triangle_group.o parallel.o - mpicc $(OPTIONS) -o singular_values coxeter.o singular_values.o mat.o enumerate_triangle_group.o parallel.o -lm -lgmp -lmps +enumerate.o: enumerate.c $(HEADERS) + gcc $(OPTIONS) -c enumerate.c -singular_values_barbot: singular_values_barbot.o coxeter.o mat.o enumerate_triangle_group.o parallel.o qext.o - mpicc $(OPTIONS) -o singular_values_barbot coxeter.o singular_values_barbot.o mat.o enumerate_triangle_group.o parallel.o qext.o -lm -lgmp -lmps - -#singular_values_mpi: singular_values_mpi.o coxeter.o mat.o -# mpicc $(OPTIONS) -o singular_values_mpi coxeter.o singular_values_mpi.o mat.o -lm -lgmp -lmps - -special_element: special_element.o coxeter.o linalg.o mat.o enumerate_triangle_group.o - gcc $(OPTIONS) -o special_element coxeter.o linalg.o special_element.o mat.o enumerate_triangle_group.o -lm -lgmp -lmps -lgsl -lcblas - -singular_values.o: singular_values.c $(HEADERS) - gcc $(OPTIONS) -c singular_values.c - -singular_values_barbot.o: singular_values_barbot.c $(HEADERS) - gcc $(OPTIONS) -c singular_values_barbot.c - -#singular_values_mpi.o: singular_values_mpi.c $(HEADERS) -# mpicc $(OPTIONS) -c singular_values_mpi.c - -special_element.o: special_element.c $(HEADERS) - gcc $(OPTIONS) -c special_element.c - -enumerate_triangle_group.o: enumerate_triangle_group.c $(HEADERS) - gcc $(OPTIONS) -c enumerate_triangle_group.c - -linalg.o: linalg.c $(HEADERS) - gcc $(OPTIONS) -c linalg.c +generators.o: generators.c $(HEADERS) + gcc $(OPTIONS) -c generators.c coxeter.o: coxeter.c $(HEADERS) gcc $(OPTIONS) -c coxeter.c @@ -52,11 +29,8 @@ coxeter.o: coxeter.c $(HEADERS) mat.o: mat.c $(HEADERS) gcc $(OPTIONS) -c mat.c -parallel.o: parallel.c $(HEADERS) - gcc $(OPTIONS) -c parallel.c - qext.o: qext.c $(HEADERS) gcc $(OPTIONS) -c qext.c clean: - rm -f singular_values singular_values_barbot special_element singular_values_mpi coxeter.o linalg.o singular_values.o singular_values_barbot.o singular_values_mpi.o mat.o special_element.o convert.hi convert.o convert billiard_words.hi billiard_words.o billiard_words enumerate_triangle_group.o parallel.o qext.o + rm -f complex_anosov complex_anosov.o mat.o coxeter.o enumerate.o generators.o qext.o diff --git a/complex_anosov.c b/complex_anosov.c new file mode 100644 index 0000000..62c2301 --- /dev/null +++ b/complex_anosov.c @@ -0,0 +1,13 @@ +#include "coxeter.h" +#include "enumerate.h" +#include "generators.h" +#include "mat.h" +#include "qext.h" + +#include + +int main(int argc, char *argv[]) +{ + printf("initial main function.\n"); + return 0; +} diff --git a/enumerate.c b/enumerate.c new file mode 100644 index 0000000..90ea826 --- /dev/null +++ b/enumerate.c @@ -0,0 +1,24 @@ +#include "enumerate.h" + +#define LOOP(i,n) for(int i = 0; i < (n); i++) + +void enumerate_coxeter_group(group_t *group, mat *gen, mat *matrices) +{ + TYPE t = GETTYPE(gen[0]->x[0]); + mat_workspace *ws; + + ws = mat_workspace_init(3, t); + + mat_identity(matrices[0]); + for(int i = 1; i < group->size; i++) { + if(!group->elements[i].inverse) + continue; + + int parent = group->elements[i].parent->id; + int letter = group->elements[i].letter; + + mat_multiply(ws, matrices[i], matrices[parent], gen[letter]); + } + + mat_workspace_clear(ws); +} diff --git a/enumerate.h b/enumerate.h new file mode 100644 index 0000000..6e1a83c --- /dev/null +++ b/enumerate.h @@ -0,0 +1,9 @@ +#ifndef ENUMERATE_H +#define ENUMERATE_H + +#include "mat.h" +#include "coxeter.h" + +void enumerate_coxeter_group(group_t *group, mat *gen, mat *matrices); + +#endif diff --git a/generators.c b/generators.c new file mode 100644 index 0000000..5639e2d --- /dev/null +++ b/generators.c @@ -0,0 +1,111 @@ +#include "generators.h" + +#define LOOP(i,n) for(int i = 0; i < (n); i++) + +void generators_triangle_reflection_generic(mat *gen, NUMBER rho1, NUMBER rho2, NUMBER rho3, mpq_t q) +{ + NUMBER b1,c1,a2,c2,a3,b3; + mpq_t qinv; + TYPE t = GETTYPE(rho1); + + INIT(b1,t);INIT(c1,t);INIT(a2,t);INIT(c2,t);INIT(a3,t);INIT(b3,t); + + // qinv = q^{-1} + mpq_init(qinv); + mpq_inv(qinv, q); + + // c1 = rho2 q, a2 = rho3 q, b3 = rho1 q, b1 = c2 = a3 = 1/q + SET_ZERO(c1); + SET_Q(c1, q); + SET_Q(a2, q); + SET_Q(b3, q); + MUL(c1, c1, rho2); + MUL(a2, a2, rho3); + MUL(b3, b3, rho1); + SET_INT(b1, 1); + SET_INT(c2, 1); + SET_INT(a3, 1); + SET_Q(b1, qinv); + SET_Q(c2, qinv); + SET_Q(a3, qinv); + + LOOP(i, 3) { + mat_init(gen[i], 3, t); + mat_zero(gen[i]); + LOOP(j, 3) { + SET_INT(*mat_ref(gen[i], j, j), i == j ? 1 : -1); + } + } + + NEG(*mat_ref(gen[0], 1, 0), b1); + NEG(*mat_ref(gen[0], 2, 0), c1); + NEG(*mat_ref(gen[1], 0, 1), a2); + NEG(*mat_ref(gen[1], 2, 1), c2); + NEG(*mat_ref(gen[2], 0, 2), a3); + NEG(*mat_ref(gen[2], 1, 2), b3); + + CLEAR(b1);CLEAR(c1);CLEAR(a2);CLEAR(c2);CLEAR(a3);CLEAR(b3); + mpq_clear(qinv); +} + + +int generators_triangle_reflection_group(mat *gen, int p1, int p2, int p3, int q1, int q2, int q3, mpq_t t) +{ + int p[3] = {p1, p2, p3}; + int q[3] = {q1, q2, q3}; + TYPE type; + + LOOP(i, 3) + if(p[i] < 2 || p[i] > 6) + return 0; + +#ifdef QEXT + type = QT_TRIVIAL; + LOOP(i, 3) + if(p[i] == 5) + type = QT_SQRT5; +#else + LOOP(i, 3) + if(p[i] == 5) + return 0; +#endif + + + NUMBER rho[3]; + LOOP(i, 3) INIT(rho[i], type); + + // compute rho1, rho2, rho3 + LOOP(i, 3) { + if(p[i] == 2 && q[i] == 1) { + SET_INT(rho[i], 0); + } else if(p[i] == 3 && q[i] == 1) { + SET_INT(rho[i], 1); + } else if(p[i] == 4 && q[i] == 1) { + SET_INT(rho[i], 2); + } else if(p[i] == 4 && q[i] == 2) { + SET_INT(rho[i], 0); + } else if(p[i] == 6 && q[i] == 1) { + SET_INT(rho[i], 3); + } else if(p[i] == 6 && q[i] == 2) { + SET_INT(rho[i], 1); + } else if(p[i] == 6 && q[i] == 3) { + SET_INT(rho[i], 0); +#ifdef QEXT + } else if(p[i] == 5 && q[i] == 1) { + mpq_set_si(rho[i]->a[0], 3, 2); + mpq_set_si(rho[i]->a[1], 1, 2); + } else if(p[i] == 5 && q[i] == 2) { + mpq_set_si(rho[i]->a[0], 3, 2); + mpq_set_si(rho[i]->a[1], -1, 2); +#endif + } else { + return 0; + } + } + + generators_triangle_reflection_generic(gen, rho[0], rho[1], rho[2], t); + + LOOP(i, 3) CLEAR(rho[i]); + + return 1; +} diff --git a/generators.h b/generators.h new file mode 100644 index 0000000..ca97d52 --- /dev/null +++ b/generators.h @@ -0,0 +1,9 @@ +#ifndef GENERATORS_H +#define GENERATORS_H + +#include "mat.h" + +void generators_triangle_reflection_generic(mat *gen, NUMBER rho1, NUMBER rho2, NUMBER rho3, mpq_t q); +int generators_triangle_reflection_group(mat *gen, int p1, int p2, int p3, int q1, int q2, int q3, mpq_t q); + +#endif diff --git a/enumerate_triangle_group.c b/old/enumerate_triangle_group.c similarity index 100% rename from enumerate_triangle_group.c rename to old/enumerate_triangle_group.c diff --git a/enumerate_triangle_group.h b/old/enumerate_triangle_group.h similarity index 100% rename from enumerate_triangle_group.h rename to old/enumerate_triangle_group.h diff --git a/singular_values.c b/old/singular_values.c similarity index 100% rename from singular_values.c rename to old/singular_values.c diff --git a/singular_values_barbot.c b/old/singular_values_barbot.c similarity index 100% rename from singular_values_barbot.c rename to old/singular_values_barbot.c diff --git a/parallel.c b/parallelization/parallel.c similarity index 100% rename from parallel.c rename to parallelization/parallel.c diff --git a/parallel.h b/parallelization/parallel.h similarity index 100% rename from parallel.h rename to parallelization/parallel.h