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

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