2022-06-13 10:05:34 +00:00
|
|
|
#include "generators.h"
|
2022-06-14 12:22:22 +00:00
|
|
|
#include "mat.h"
|
2022-06-13 10:05:34 +00:00
|
|
|
|
|
|
|
#define LOOP(i,n) for(int i = 0; i < (n); i++)
|
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
void generators_triangle_reflection_generic(mat *gen, NUMBER sqrho1, NUMBER sqrho2, NUMBER sqrho3, NUMBER t)
|
2022-06-13 10:05:34 +00:00
|
|
|
{
|
2022-06-14 12:22:22 +00:00
|
|
|
NUMBER tmp;
|
2022-06-15 10:20:45 +00:00
|
|
|
NUMBER tinv;
|
|
|
|
TYPE type = GETTYPE(sqrho1);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
INIT(tmp, type);
|
|
|
|
INIT(tinv, type);
|
|
|
|
INV(tinv, t);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
|
|
|
LOOP(i, 3) {
|
2022-06-15 10:20:45 +00:00
|
|
|
mat_init(gen[i], 3, type);
|
2022-06-13 10:05:34 +00:00
|
|
|
mat_zero(gen[i]);
|
|
|
|
LOOP(j, 3) {
|
|
|
|
SET_INT(*mat_ref(gen[i], j, j), i == j ? 1 : -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
MUL(tmp, t, sqrho1);
|
2022-06-14 12:22:22 +00:00
|
|
|
NEG(*mat_ref(gen[2], 1, 2), tmp);
|
2022-06-15 10:20:45 +00:00
|
|
|
NEG(*mat_ref(gen[0], 2, 0), sqrho2);
|
|
|
|
NEG(*mat_ref(gen[1], 0, 1), sqrho3);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
MUL(tmp, tinv, sqrho1);
|
|
|
|
NEG(*mat_ref(gen[1], 2, 1), tmp);
|
|
|
|
NEG(*mat_ref(gen[2], 0, 2), sqrho2);
|
|
|
|
NEG(*mat_ref(gen[0], 1, 0), sqrho3);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
2022-06-14 12:22:22 +00:00
|
|
|
CLEAR(tmp);
|
2022-06-15 10:20:45 +00:00
|
|
|
CLEAR(tinv);
|
2022-06-14 12:22:22 +00:00
|
|
|
}
|
2022-06-13 10:05:34 +00:00
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
// warning: this is not compatible anymore!
|
2022-06-13 10:05:34 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 12:22:22 +00:00
|
|
|
NUMBER param;
|
|
|
|
INIT(param, type);
|
|
|
|
SET_Q(param, t);
|
|
|
|
|
|
|
|
generators_triangle_reflection_generic(gen, rho[0], rho[1], rho[2], param);
|
|
|
|
|
|
|
|
LOOP(i, 3) CLEAR(rho[i]);
|
|
|
|
CLEAR(param);
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
int generators_triangle_reflection_group_555_complex(mat *gen, int q1, int q2, int q3, mpq_t treal, mpq_t timag)
|
|
|
|
{
|
|
|
|
|
|
|
|
int q[3] = {q1, q2, q3};
|
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
NUMBER sqrho[3];
|
|
|
|
LOOP(i, 3) INIT(sqrho[i], QT_GAUSS_SQRT5);
|
2022-06-14 12:22:22 +00:00
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
// compute sqrho1, sqrho2, sqrho3
|
2022-06-14 12:22:22 +00:00
|
|
|
LOOP(i, 3) {
|
|
|
|
if(q[i] == 1) {
|
2022-06-15 10:20:45 +00:00
|
|
|
// 2cos(pi/5) = 1/2 + 1/2*sqrt(5) = 1/2 + 7/12 a - 1/24 a^3
|
|
|
|
mpq_set_si(sqrho[i]->a[0], 1, 2);
|
|
|
|
mpq_set_si(sqrho[i]->a[1], 7, 12);
|
|
|
|
mpq_set_si(sqrho[i]->a[2], 0, 1);
|
|
|
|
mpq_set_si(sqrho[i]->a[3], -1, 24);
|
2022-06-14 12:22:22 +00:00
|
|
|
} else if(q[i] == 2) {
|
2022-06-15 10:20:45 +00:00
|
|
|
// 2cos(pi/5) = -1/2 + 1/2*sqrt(5)
|
|
|
|
mpq_set_si(sqrho[i]->a[0], -1, 2);
|
|
|
|
mpq_set_si(sqrho[i]->a[1], 7, 12);
|
|
|
|
mpq_set_si(sqrho[i]->a[2], 0, 1);
|
|
|
|
mpq_set_si(sqrho[i]->a[3], -1, 24);
|
2022-06-14 12:22:22 +00:00
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
NUMBER param;
|
|
|
|
INIT(param, QT_GAUSS_SQRT5);
|
|
|
|
mpq_set(param->a[0], treal);
|
|
|
|
mpq_set_si(param->a[1], -1, 6);
|
|
|
|
mpq_mul(param->a[1], param->a[1], timag);
|
|
|
|
mpq_set_si(param->a[2], 0, 1);
|
|
|
|
mpq_set_si(param->a[3], 1, 12);
|
|
|
|
mpq_mul(param->a[3], param->a[3], timag);
|
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
generators_triangle_reflection_generic(gen, sqrho[0], sqrho[1], sqrho[2], param);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
2022-06-15 10:20:45 +00:00
|
|
|
LOOP(i, 3) CLEAR(sqrho[i]);
|
2022-06-14 12:22:22 +00:00
|
|
|
CLEAR(param);
|
2022-06-13 10:05:34 +00:00
|
|
|
|
|
|
|
return 1;
|
2022-06-14 12:22:22 +00:00
|
|
|
|
2022-06-13 10:05:34 +00:00
|
|
|
}
|