#include "generators.h" #include "mat.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, NUMBER q) { NUMBER tmp; NUMBER qinv; TYPE t = GETTYPE(rho1); INIT(tmp, t); INIT(qinv, t); INV(qinv, q); 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); } } MUL(tmp, q, rho1); NEG(*mat_ref(gen[2], 1, 2), tmp); MUL(tmp, q, rho2); NEG(*mat_ref(gen[0], 2, 0), tmp); MUL(tmp, q, rho3); NEG(*mat_ref(gen[1], 0, 1), tmp); NEG(*mat_ref(gen[1], 2, 1), qinv); NEG(*mat_ref(gen[2], 0, 2), qinv); NEG(*mat_ref(gen[0], 1, 0), qinv); CLEAR(tmp); 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; } } 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}; NUMBER rho[3]; LOOP(i, 3) INIT(rho[i], QT_GAUSS_SQRT5); // compute rho1, rho2, rho3 LOOP(i, 3) { if(q[i] == 1) { // 4cos(pi/5)^2 = 3/2 + 1/2*sqrt(5) mpq_set_si(rho[i]->a[0], 3, 2); mpq_set_si(rho[i]->a[1], 7, 12); mpq_set_si(rho[i]->a[2], 0, 1); mpq_set_si(rho[i]->a[3], -1, 24); } else if(q[i] == 2) { // 4cos(pi/5)^2 = 3/2 - 1/2*sqrt(5) mpq_set_si(rho[i]->a[0], 3, 2); mpq_set_si(rho[i]->a[1], -7, 12); mpq_set_si(rho[i]->a[2], 0, 1); mpq_set_si(rho[i]->a[3], 1, 24); } 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); generators_triangle_reflection_generic(gen, rho[0], rho[1], rho[2], param); LOOP(i, 3) CLEAR(rho[i]); CLEAR(param); return 1; }