bridge/class-master/depend/pari/src/basemath/base3.c
/* assume x integral, k integer, A in HNF */
assume x integral, k integer, A in HNF
assume x integral k integer A in HNF
GEN
nfpowmodideal(GEN nf,GEN x,GEN k,GEN A)
{
  long s = signe(k);
  pari_sp av;
  GEN y;
  if (!s) return gen_1;
  av = avma;
  x = nf_to_scalar_or_basis(nf, x);
  if (typ(x) != t_COL) return Fp_pow(x, k, gcoeff(A,1,1));
  if (s < 0) { x = nfinvmodideal(nf, x,A); k = negi(k); }
  for(y = NULL;;)
  {
    if (mpodd(k)) y = nfmulmodideal(nf,y,x,A);
    k = shifti(k,-1); if (!signe(k)) break;
    x = nfsqrmodideal(nf,x,A);
  }
  return gerepileupto(av, y);
}
GEN nfpowmodideal ( GEN nf , GEN x , GEN k , GEN A ) { long s = signe ( k ) ; pari_sp av ; GEN y ; if ( ! s ) return gen_1 ; av = avma ; x = nf_to_scalar_or_basis ( nf , x ) ; if ( typ ( x ) != t_COL ) return Fp_pow ( x , k , gcoeff ( A , 1 , 1 ) ) ; if ( s < 0 ) { x = nfinvmodideal ( nf , x , A ) ; k = negi ( k ) ; } for ( y = NULL ; ; ) { if ( mpodd ( k ) ) y = nfmulmodideal ( nf , y , x , A ) ; k = shifti ( k , -1 ) ; if ( ! signe ( k ) ) break ; x = nfsqrmodideal ( nf , x , A ) ; } return gerepileupto ( av , y ) ; }
assume x integral, k integer, A in HNF
assume x integral k integer A in HNF