bridge/class-master/depend/pari/src/basemath/base3.c
/* given an element x in Z_K and an integral ideal y in HNF, coprime with x,
   outputs an element inverse of x modulo y */
given an element x in Z_K and an integral ideal y in HNF, coprime with x,
outputs an element inverse of x modulo y
given an element x in Z_K and an integral ideal y in HNF coprime with x outputs an element inverse of x modulo y
GEN
nfinvmodideal(GEN nf, GEN x, GEN y)
{
  pari_sp av = avma;
  GEN a, yZ = gcoeff(y,1,1);
  if (equali1(yZ)) return gen_0;
  x = nf_to_scalar_or_basis(nf, x);
  if (typ(x) == t_INT) return gerepileupto(av, Fp_inv(x, yZ));
  a = hnfmerge_get_1(idealhnf_principal(nf,x), y);
  if (!a) pari_err_INV("nfinvmodideal", x);
  return gerepileupto(av, zk_modHNF(nfdiv(nf,a,x), y));
}
GEN nfinvmodideal ( GEN nf , GEN x , GEN y ) { pari_sp av = avma ; GEN a , yZ = gcoeff ( y , 1 , 1 ) ; if ( equali1 ( yZ ) ) return gen_0 ; x = nf_to_scalar_or_basis ( nf , x ) ; if ( typ ( x ) == t_INT ) return gerepileupto ( av , Fp_inv ( x , yZ ) ) ; a = hnfmerge_get_1 ( idealhnf_principal ( nf , x ) , y ) ; if ( ! a ) pari_err_INV ( " " , x ) ; return gerepileupto ( av , zk_modHNF ( nfdiv ( nf , a , x ) , y ) ) ; }
given an element x in Z_K and an integral ideal y in HNF, coprime with x,
outputs an element inverse of x modulo y
given an element x in Z_K and an integral ideal y in HNF coprime with x outputs an element inverse of x modulo y