bridge/class-master/depend/pari/src/basemath/ellsea.c
/* Finds the isogenous EC, and the sum of the x-coordinates of the points in
 * the kernel of the isogeny E -> Eb
 * E: elliptic curve, ell: a prime, meqn: Atkin modular equation
 * g: root of meqn defining isogenous curve Eb. */
Finds the isogenous EC, and the sum of the x-coordinates of the points in
the kernel of the isogeny E -> Eb
E: elliptic curve, ell: a prime, meqn: Atkin modular equation
g: root of meqn defining isogenous curve Eb.
Finds the isogenous EC and the sum of the x - coordinates of the points in the kernel of the isogeny E - > Eb E : elliptic curve ell : a prime meqn : Atkin modular equation g : root of meqn defining isogenous curve Eb .
static GEN
find_isogenous_from_Atkin(GEN a4, GEN a6, ulong ell, struct meqn *MEQN, GEN g, GEN T, GEN pp, long e)
{
  pari_sp ltop = avma, btop;
  GEN meqn = MEQN->eq, meqnx, Dmeqnx, Roots, gprime, u1;
  long k, vJ = MEQN->vy;
  GEN p = e==1 ? pp: powiu(pp, e);
  GEN j = Zq_ellj(a4, a6, T, p, pp, e);
  GEN E4 = Fq_div(a4, stoi(-3), T, p);
  GEN E6 = Fq_neg(Fq_halve(a6, T, p), T, p);
  GEN Dx = RgX_deriv(meqn);
  GEN DJ = deriv(meqn, vJ);
  GEN Dxg = FpXY_Fq_evaly(Dx, g, T, p, vJ);
  GEN px = FqX_eval(Dxg, j, T, p), dx = Fq_mul(px, g, T, p);
  GEN DJg = FpXY_Fq_evaly(DJ, g, T, p, vJ);
  GEN pJ = FqX_eval(DJg, j, T, p), dJ = Fq_mul(pJ, j, T, p);
  GEN Dxx = RgX_deriv(Dx);
  GEN DxJg = FqX_deriv(Dxg, T, p);
  GEN Dxxg = FpXY_Fq_evaly(Dxx, g, T, p, vJ);
  GEN DJJg = FqX_deriv(DJg, T, p);
  GEN a, b;
  if (!signe(Fq_red(dJ,T,pp)) || !signe(Fq_red(dx,T,pp)))
  {
    if (DEBUGLEVEL>0) err_printf("[A: d%c=0]",signe(dJ)? 'x': 'J');
    avma = ltop; return NULL;
  }
  a = Fq_mul(dJ, Fq_mul(g, E6, T, p), T, p);
  b = Fq_mul(E4, dx, T, p);
  gprime = Zq_div(a, b, T, p, pp, e);
  u1 = compute_u(gprime, Dxxg, DxJg, DJJg, j, pJ, px, 1, E4, E6, T, p, pp, e);
  meqnx = FpXY_Fq_evaly(meqn, g, T, p, vJ);
  Dmeqnx = FqX_deriv(meqnx, T, pp);
  Roots = FqX_roots(meqnx, T, pp);
  btop = avma;
  for (k = lg(Roots)-1; k >= 1; k--, avma = btop)
  {
    GEN jt = gel(Roots, k);
    if (signe(FqX_eval(Dmeqnx, jt, T, pp))==0)
      continue;
    if (e > 1)
      jt = ZqX_liftroot(meqnx, gel(Roots, k), T, pp, e);
    if (signe(Fq_red(jt, T, pp)) == 0 || signe(Fq_sub(jt, utoi(1728), T, pp)) == 0)
    {
      if (DEBUGLEVEL>0) err_printf("[A: jt=%ld]",signe(Fq_red(jt,T,p))? 1728: 0);
      avma = ltop; return NULL;
    }
    else
    {
      GEN pxstar = FqX_eval(Dxg, jt, T, p);
      GEN dxstar = Fq_mul(pxstar, g, T, p);
      GEN pJstar = FqX_eval(DJg, jt, T, p);
      GEN dJstar = Fq_mul(Fq_mulu(jt, ell, T, p), pJstar, T, p);
      GEN u = Fq_mul(Fq_mul(dxstar, dJ, T, p), E6, T, p);
      GEN v = Fq_mul(Fq_mul(dJstar, dx, T, p), E4, T, p);
      GEN E4t = Zq_div(Fq_mul(Fq_sqr(u, T, p), jt, T, p), Fq_mul(Fq_sqr(v, T, p), Fq_sub(jt, utoi(1728), T, p), T, p), T, p, pp, e);
      GEN E6t = Zq_div(Fq_mul(u, E4t, T, p), v, T, p, pp, e);
      GEN u2 = compute_u(gprime, Dxxg, DxJg, DJJg, jt, pJstar, pxstar, ell, E4t, E6t, T, p, pp, e);
      GEN pp1 = Fq_mulu(Fq_sub(u1, u2, T, p), 3*ell, T, p);
      GEN a4t = Fq_mul(mulsi(-3, powuu(ell,4)), E4t, T, p);
      GEN a6t = Fq_mul(mulsi(-2, powuu(ell,6)), E6t, T, p);
      GEN h = find_kernel(a4, a6, ell, a4t, a6t, pp1, T, p, pp, e);
      if (h) return gerepilecopy(ltop, mkvec3(a4t, a6t, h));
    }
  }
  pari_err_BUG("find_isogenous_from_Atkin, kernel not found");
  return NULL;
}
static GEN find_isogenous_from_Atkin ( GEN a4 , GEN a6 , ulong ell , struct meqn * MEQN , GEN g , GEN T , GEN pp , long e ) { pari_sp ltop = avma , btop ; GEN meqn = MEQN -> eq , meqnx , Dmeqnx , Roots , gprime , u1 ; long k , vJ = MEQN -> vy ; GEN p = e == 1 ? pp : powiu ( pp , e ) ; GEN j = Zq_ellj ( a4 , a6 , T , p , pp , e ) ; GEN E4 = Fq_div ( a4 , stoi ( -3 ) , T , p ) ; GEN E6 = Fq_neg ( Fq_halve ( a6 , T , p ) , T , p ) ; GEN Dx = RgX_deriv ( meqn ) ; GEN DJ = deriv ( meqn , vJ ) ; GEN Dxg = FpXY_Fq_evaly ( Dx , g , T , p , vJ ) ; GEN px = FqX_eval ( Dxg , j , T , p ) , dx = Fq_mul ( px , g , T , p ) ; GEN DJg = FpXY_Fq_evaly ( DJ , g , T , p , vJ ) ; GEN pJ = FqX_eval ( DJg , j , T , p ) , dJ = Fq_mul ( pJ , j , T , p ) ; GEN Dxx = RgX_deriv ( Dx ) ; GEN DxJg = FqX_deriv ( Dxg , T , p ) ; GEN Dxxg = FpXY_Fq_evaly ( Dxx , g , T , p , vJ ) ; GEN DJJg = FqX_deriv ( DJg , T , p ) ; GEN a , b ; if ( ! signe ( Fq_red ( dJ , T , pp ) ) || ! signe ( Fq_red ( dx , T , pp ) ) ) { if ( DEBUGLEVEL > 0 ) err_printf ( " " , signe ( dJ ) ? ' ' : ' ' ) ; avma = ltop ; return NULL ; } a = Fq_mul ( dJ , Fq_mul ( g , E6 , T , p ) , T , p ) ; b = Fq_mul ( E4 , dx , T , p ) ; gprime = Zq_div ( a , b , T , p , pp , e ) ; u1 = compute_u ( gprime , Dxxg , DxJg , DJJg , j , pJ , px , 1 , E4 , E6 , T , p , pp , e ) ; meqnx = FpXY_Fq_evaly ( meqn , g , T , p , vJ ) ; Dmeqnx = FqX_deriv ( meqnx , T , pp ) ; Roots = FqX_roots ( meqnx , T , pp ) ; btop = avma ; for ( k = lg ( Roots ) - 1 ; k >= 1 ; k -- , avma = btop ) { GEN jt = gel ( Roots , k ) ; if ( signe ( FqX_eval ( Dmeqnx , jt , T , pp ) ) == 0 ) continue ; if ( e > 1 ) jt = ZqX_liftroot ( meqnx , gel ( Roots , k ) , T , pp , e ) ; if ( signe ( Fq_red ( jt , T , pp ) ) == 0 || signe ( Fq_sub ( jt , utoi ( 1728 ) , T , pp ) ) == 0 ) { if ( DEBUGLEVEL > 0 ) err_printf ( " " , signe ( Fq_red ( jt , T , p ) ) ? 1728 : 0 ) ; avma = ltop ; return NULL ; } else { GEN pxstar = FqX_eval ( Dxg , jt , T , p ) ; GEN dxstar = Fq_mul ( pxstar , g , T , p ) ; GEN pJstar = FqX_eval ( DJg , jt , T , p ) ; GEN dJstar = Fq_mul ( Fq_mulu ( jt , ell , T , p ) , pJstar , T , p ) ; GEN u = Fq_mul ( Fq_mul ( dxstar , dJ , T , p ) , E6 , T , p ) ; GEN v = Fq_mul ( Fq_mul ( dJstar , dx , T , p ) , E4 , T , p ) ; GEN E4t = Zq_div ( Fq_mul ( Fq_sqr ( u , T , p ) , jt , T , p ) , Fq_mul ( Fq_sqr ( v , T , p ) , Fq_sub ( jt , utoi ( 1728 ) , T , p ) , T , p ) , T , p , pp , e ) ; GEN E6t = Zq_div ( Fq_mul ( u , E4t , T , p ) , v , T , p , pp , e ) ; GEN u2 = compute_u ( gprime , Dxxg , DxJg , DJJg , jt , pJstar , pxstar , ell , E4t , E6t , T , p , pp , e ) ; GEN pp1 = Fq_mulu ( Fq_sub ( u1 , u2 , T , p ) , 3 * ell , T , p ) ; GEN a4t = Fq_mul ( mulsi ( -3 , powuu ( ell , 4 ) ) , E4t , T , p ) ; GEN a6t = Fq_mul ( mulsi ( -2 , powuu ( ell , 6 ) ) , E6t , T , p ) ; GEN h = find_kernel ( a4 , a6 , ell , a4t , a6t , pp1 , T , p , pp , e ) ; if ( h ) return gerepilecopy ( ltop , mkvec3 ( a4t , a6t , h ) ) ; } } pari_err_BUG ( " " ) ; return NULL ; }
Finds the isogenous EC, and the sum of the x-coordinates of the points in
 the kernel of the isogeny E -> Eb
 E: elliptic curve, ell: a prime, meqn: Atkin modular equation
 g: root of meqn defining isogenous curve Eb.
Finds the isogenous EC and the sum of the x - coordinates of the points in the kernel of the isogeny E - > Eb E : elliptic curve ell : a prime meqn : Atkin modular equation g : root of meqn defining isogenous curve Eb .
/*LCOV_EXCL_LINE*/