/* K a bnf, compute Cl'(K) = ell-Sylow of Cl(K) / (places above ell). * Return [D, u, R0, U0, ordS] * - D: cyclic factors for Cl'(K) * - u: generators of cyclic factors (all coprime to ell) * - R0: subgroup isprincipal(<S>) (divides K.cyc) * - U0: generators of R0 are of the form S . U0 * - ordS[i] = order of S[i] in CL(K) */ static GEN CL_prime(GEN K, GEN ell, GEN Sell) { GEN g, ordS, R0, U0, U, D, u, cyc = bnf_get_cyc(K); long i, l, lD, lS = lg(Sell); g = leafcopy(bnf_get_gen(K)); l = lg(g); for (i = 1; i < l; i++) { GEN A = gel(g,i), a = gcoeff(A,1,1); long v = Z_pvalrem(a, ell, &a); if (v) gel(g,i) = hnfmodid(A, a); /* make coprime to ell */ } R0 = cgetg(lS, t_MAT); ordS = cgetg(lS, t_VEC); for (i = 1; i < lS; i++) { gel(R0,i) = isprincipal(K, gel(Sell,i)); gel(ordS,i) = charorder(cyc, gel(R0,i)); /* order of Sell[i] */ } R0 = shallowconcat(R0, diagonal_shallow(cyc)); /* R0 = subgroup generated by S in Cl(K) [ divides diagonal(K.cyc) ]*/ R0 = ZM_hnfall(R0, &U0, 2); /* [S | cyc] * U0 = R0 in HNF */ D = ZM_snfall(R0, &U,NULL); D = RgM_diagonal_shallow(D); lD = lg(D); u = ZM_inv(U, gen_1); settyp(u, t_VEC); for (i = 1; i < lD; i++) gel(u,i) = idealfactorback(K,g,gel(u,i),1); setlg(U0, l); U0 = rowslice(U0,1,lS-1); /* restrict to 'S' part */ return mkvec5(D, u, R0, U0, ordS); }
GEN F2xq_ellcard(GEN a, GEN a6, GEN T) { pari_sp av = avma; long n = F2x_degree(T); GEN q = int2u(n), c; if (typ(a)==t_VECSMALL) { GEN t = F2xq_elltrace_Harley(a6, T); c = addii(q, F2xq_trace(a,T) ? addui(1,t): subui(1,t)); } else if (n==1) { long a4i = lgpol(gel(a,2)), a6i = lgpol(a6); return utoi(a4i? (a6i? 1: 5): 3); } else if (n==2) { GEN a3 = gel(a,1), a4 = gel(a,2), x = polx_F2x(T[1]), x1 = pol1_F2x(T[1]); GEN a613 = F2xq_mul(F2x_add(x1, a6),a3,T), a43= F2xq_mul(a4,a3,T); long f0= F2xq_trace(F2xq_mul(a6,a3,T),T); long f1= F2xq_trace(F2x_add(a43,a613),T); long f2= F2xq_trace(F2x_add(F2xq_mul(a43,x,T),a613),T); long f3= F2xq_trace(F2x_add(F2xq_mul(a43,F2x_add(x,x1),T),a613),T); c = utoi(9-2*(f0+f1+f2+f3)); } else { struct _F2xqE e; long m = (n+1)>>1; GEN q1 = addis(q, 1); GEN v = n==4 ? mkvec4s(13,17,21,25) : odd(n) ? mkvec3(subii(q1,int2u(m)),q1,addii(q1,int2u(m))): mkvec5(subii(q1,int2u(m+1)),subii(q1,int2u(m)),q1, addii(q1,int2u(m)),addii(q1,int2u(m+1))); e.a2=a; e.a6=a6; e.T=T; c = gen_select_order(v,(void*)&e, &F2xqE_group); if (n==4 && equaliu(c, 21)) /* Ambiguous case */ { GEN d = F2xq_powu(polx_F2x(T[1]),3,T), a3 = gel(a,1); e.a6 = F2x_add(a6,F2xq_mul(d,F2xq_sqr(a3,T),T)); /* twist */ c = subui(34, gen_select_order(mkvec2s(13,25),(void*)&e, &F2xqE_group)); } } return gerepileuptoint(av, c); }