bridge/class-master/depend/pari/src/basemath/elliptic.c
/* Return D such that E_D has minimal discriminant.
   It also has minimal conductor in Z[1/2]
*/
Return D such that E_D has minimal discriminant.
It also has minimal conductor in Z[1/2]
Return D such that E_D has minimal discriminant . It also has minimal conductor in Z [ 1 / 2 ]
GEN
ellminimaltwist(GEN e)
{
  pari_sp av = avma;
  GEN c4, c6, disc, g, N, M, F, E, D = gen_1;
  long i, lF;
  checkell_Q(e);
  E = ellminimalmodel(e, NULL);
  c4 = ell_get_c4(E);
  c6 = ell_get_c6(E);
  disc = ell_get_disc(E);
  g = gcdii(disc, sqri(c6));
  ellQ_get_Nfa(E, &N, &M);
  F = gel(M, 1); lF = lg(F);
  for(i = 1; i < lF; i++)
  {
    GEN p = gel(F, i);
    long vg = Z_pval(g,p), d2;
    if (vg < 6) continue;
    switch(itou_or_0(p))
    {
      default: 
        D = mulii(D, (mod4(p)==1)? p: negi(p));
        break;
      case 3: 
        if (safe_Z_lval(c6,3) != 5) D = mulis(D, -3);
        break;
      case 2:
        d2 = twist2(c4,c6,disc,vg);
        if (d2 != 1) D = mulis(D,d2);
        break;
    }
  }
  obj_free(E);
  return gerepileuptoleaf(av, D);
}
GEN ellminimaltwist ( GEN e ) { pari_sp av = avma ; GEN c4 , c6 , disc , g , N , M , F , E , D = gen_1 ; long i , lF ; checkell_Q ( e ) ; E = ellminimalmodel ( e , NULL ) ; c4 = ell_get_c4 ( E ) ; c6 = ell_get_c6 ( E ) ; disc = ell_get_disc ( E ) ; g = gcdii ( disc , sqri ( c6 ) ) ; ellQ_get_Nfa ( E , & N , & M ) ; F = gel ( M , 1 ) ; lF = lg ( F ) ; for ( i = 1 ; i < lF ; i ++ ) { GEN p = gel ( F , i ) ; long vg = Z_pval ( g , p ) , d2 ; if ( vg < 6 ) continue ; switch ( itou_or_0 ( p ) ) { default : D = mulii ( D , ( mod4 ( p ) == 1 ) ? p : negi ( p ) ) ; break ; case 3 : if ( safe_Z_lval ( c6 , 3 ) != 5 ) D = mulis ( D , -3 ) ; break ; case 2 : d2 = twist2 ( c4 , c6 , disc , vg ) ; if ( d2 != 1 ) D = mulis ( D , d2 ) ; break ; } } obj_free ( E ) ; return gerepileuptoleaf ( av , D ) ; }
Return D such that E_D has minimal discriminant.
Return D such that E_D has minimal discriminant .
/* on twist by d, (c4,c6,D,g) -> (d^2 c4, d^3 c6, d^6 D, d^6 g),
   * then apply get_u(). Since model is minimal, v(g) < 12 unless p=3 and
   * v(g) < 14 or p = 2 and v(g) <= 18 */ /* twist by fund. discriminant d2; in get_u, we have v(g) = vg + 6*v(d2) */ /* p > 3, 6 <= v(g) < 12 => v(D) -= 6 */ /* bad case: v(final_c6) = 2 => no reduction; else v(D) -= 6 */