import enumerate.c and generators.c, prepare Makefile

This commit is contained in:
Florian Stecker 2022-06-13 12:05:34 +02:00
parent 3309c37955
commit 15681c308b
12 changed files with 178 additions and 38 deletions

View File

@ -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

13
complex_anosov.c Normal file
View File

@ -0,0 +1,13 @@
#include "coxeter.h"
#include "enumerate.h"
#include "generators.h"
#include "mat.h"
#include "qext.h"
#include <stdio.h>
int main(int argc, char *argv[])
{
printf("initial main function.\n");
return 0;
}

24
enumerate.c Normal file
View File

@ -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);
}

9
enumerate.h Normal file
View File

@ -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

111
generators.c Normal file
View File

@ -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;
}

9
generators.h Normal file
View File

@ -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