bridge/class-master/depend/pari/src/modules/algebras.c
/* ramified prime with nontrivial Hasse invariant */
ramified prime with nontrivial Hasse invariant
ramified prime with nontrivial Hasse invariant
static GEN
localcomplete(GEN rnf, GEN pl, GEN cnd, GEN auts, long j, long n, long h, long* v)
{
  GEN nf, gens, hgens, pr, modpr, T, p, sol, U, D, b, gene, randg, pu;
  long ngens, i, d, np, k, d1, d2, hg, dnf, vcnd, curgcd;
  nf = rnf_get_nf(rnf);
  pr = gcoeff(cnd,j,1);
  np = umodiu(pr_norm(pr), n);
  dnf = nf_get_degree(nf);
  vcnd = itos(gcoeff(cnd,j,2));
  ngens = 13+dnf;
  gens = zerovec(ngens);
  hgens = zerovec(ngens);
  *v = 0;
  curgcd = 0;
  ngens = 0;
  if (!uisprime(n)) {
    gene =  pr_get_gen(pr);
    hg = localhasse(rnf, cnd, pl, auts, gene, j);
    nextgen(gene, hg, &gens, &hgens, &ngens, &curgcd);
  }
  if (ugcd(np,n) != 1) { 
    pu = idealprincipalunits(nf,pr,vcnd);
    pu = abgrp_get_gen(pu);
    for (i=1; i<lg(pu) && !dividesmod(curgcd,h,n); i++) {
      gene = gel(pu,i);
      hg = localhasse(rnf, cnd, pl, auts, gene, j);
      nextgen(gene, hg, &gens, &hgens, &ngens, &curgcd);
    }
  }
  d = ugcd(np-1,n);
  if (d != 1) { 
    modpr = nf_to_Fq_init(nf, &pr, &T, &p);
    while (!dividesmod(curgcd,h,n)) { 
      if (T==NULL) randg = randomi(p);
      else randg = random_FpX(degpol(T), varn(T),p);
      if (!gequal0(randg) && !gequal1(randg)) {
        gene = Fq_to_nf(randg, modpr);
        hg = localhasse(rnf, cnd, pl, auts, gene, j);
        nextgen(gene, hg, &gens, &hgens, &ngens, &curgcd);
      }
    }
  }
  setlg(gens,ngens+1);
  setlg(hgens,ngens+1);
  sol = ZV_extgcd(hgens);
  D = gel(sol,1);
  U = gmael(sol,2,ngens);
  b = gen_1;
  d = itou(D);
  d1 = ugcd(d,n);
  d2 = d/d1;
  d = ((h/d1)*Fl_inv(d2,n))%n;
  for (i=1; i<=ngens; i++) {
    k = (itos(gel(U,i))*d)%n;
    if (k<0) k = n-k;
    if (k) b = nfmul(nf, b, nfpow_u(nf, gel(gens,i),k));
    if (i==1) *v = k;
  }
  return b;
}
static GEN localcomplete ( GEN rnf , GEN pl , GEN cnd , GEN auts , long j , long n , long h , long * v ) { GEN nf , gens , hgens , pr , modpr , T , p , sol , U , D , b , gene , randg , pu ; long ngens , i , d , np , k , d1 , d2 , hg , dnf , vcnd , curgcd ; nf = rnf_get_nf ( rnf ) ; pr = gcoeff ( cnd , j , 1 ) ; np = umodiu ( pr_norm ( pr ) , n ) ; dnf = nf_get_degree ( nf ) ; vcnd = itos ( gcoeff ( cnd , j , 2 ) ) ; ngens = 13 + dnf ; gens = zerovec ( ngens ) ; hgens = zerovec ( ngens ) ; * v = 0 ; curgcd = 0 ; ngens = 0 ; if ( ! uisprime ( n ) ) { gene = pr_get_gen ( pr ) ; hg = localhasse ( rnf , cnd , pl , auts , gene , j ) ; nextgen ( gene , hg , & gens , & hgens , & ngens , & curgcd ) ; } if ( ugcd ( np , n ) != 1 ) { pu = idealprincipalunits ( nf , pr , vcnd ) ; pu = abgrp_get_gen ( pu ) ; for ( i = 1 ; i < lg ( pu ) && ! dividesmod ( curgcd , h , n ) ; i ++ ) { gene = gel ( pu , i ) ; hg = localhasse ( rnf , cnd , pl , auts , gene , j ) ; nextgen ( gene , hg , & gens , & hgens , & ngens , & curgcd ) ; } } d = ugcd ( np - 1 , n ) ; if ( d != 1 ) { modpr = nf_to_Fq_init ( nf , & pr , & T , & p ) ; while ( ! dividesmod ( curgcd , h , n ) ) { if ( T == NULL ) randg = randomi ( p ) ; else randg = random_FpX ( degpol ( T ) , varn ( T ) , p ) ; if ( ! gequal0 ( randg ) && ! gequal1 ( randg ) ) { gene = Fq_to_nf ( randg , modpr ) ; hg = localhasse ( rnf , cnd , pl , auts , gene , j ) ; nextgen ( gene , hg , & gens , & hgens , & ngens , & curgcd ) ; } } } setlg ( gens , ngens + 1 ) ; setlg ( hgens , ngens + 1 ) ; sol = ZV_extgcd ( hgens ) ; D = gel ( sol , 1 ) ; U = gmael ( sol , 2 , ngens ) ; b = gen_1 ; d = itou ( D ) ; d1 = ugcd ( d , n ) ; d2 = d / d1 ; d = ( ( h / d1 ) * Fl_inv ( d2 , n ) ) % n ; for ( i = 1 ; i <= ngens ; i ++ ) { k = ( itos ( gel ( U , i ) ) * d ) % n ; if ( k < 0 ) k = n - k ; if ( k ) b = nfmul ( nf , b , nfpow_u ( nf , gel ( gens , i ) , k ) ) ; if ( i == 1 ) * v = k ; } return b ; }
ramified prime with nontrivial Hasse invariant
ramified prime with nontrivial Hasse invariant
/* GCD(Np,n) != 1 */ /* GCD(Np-1,n) != 1 */ /* TODO gener_FpXQ_local */