bridge/class-master/depend/pari/src/basemath/base5.c
/* Given an element x and an ideal I in HNF, gives an r such that x-r is in H
 * and r is small */
Given an element x and an ideal I in HNF, gives an r such that x-r is in H
and r is small
Given an element x and an ideal I in HNF gives an r such that x - r is in H and r is small
GEN
nfreduce(GEN nf, GEN x, GEN I)
{
  pari_sp av = avma;
  GEN aI;
  x = nf_to_scalar_or_basis(checknf(nf), x);
  if (idealtyp(&I,&aI) != id_MAT || lg(I)==1) pari_err_TYPE("nfreduce",I);
  if (typ(x) != t_COL) x = scalarcol( gmod(x, gcoeff(I,1,1)), lg(I)-1 );
  else x = reducemodinvertible(x, I);
  return gerepileupto(av, x);
}
GEN nfreduce ( GEN nf , GEN x , GEN I ) { pari_sp av = avma ; GEN aI ; x = nf_to_scalar_or_basis ( checknf ( nf ) , x ) ; if ( idealtyp ( & I , & aI ) != id_MAT || lg ( I ) == 1 ) pari_err_TYPE ( " " , I ) ; if ( typ ( x ) != t_COL ) x = scalarcol ( gmod ( x , gcoeff ( I , 1 , 1 ) ) , lg ( I ) - 1 ) ; else x = reducemodinvertible ( x , I ) ; return gerepileupto ( av , x ) ; }
Given an element x and an ideal I in HNF, gives an r such that x-r is in H
 and r is small
Given an element x and an ideal I in HNF gives an r such that x - r is in H and r is small