bridge/class-master/depend/pari/src/basemath/base2.c
/* Given bnf and either an order as output by rnfpseudobasis or a polynomial,
 * and outputs a basis (not pseudo) in Hermite Normal Form if it exists, zero
 * if not
 */
Given bnf and either an order as output by rnfpseudobasis or a polynomial,
and outputs a basis (not pseudo) in Hermite Normal Form if it exists, zero
if not
Given bnf and either an order as output by rnfpseudobasis or a polynomial and outputs a basis ( not pseudo ) in Hermite Normal Form if it exists zero if not
GEN
rnfhnfbasis(GEN bnf, GEN order)
{
  pari_sp av = avma;
  long j, n;
  GEN nf, A, I, a;
  bnf = checkbnf(bnf); nf = bnf_get_nf(bnf);
  order = get_order(nf, order, "rnfbasis");
  A = gel(order,1); A = RgM_shallowcopy(A);
  I = gel(order,2); n = lg(A)-1;
  for (j=1; j<=n; j++)
  {
    if (ideal_is1(gel(I,j))) continue;
    a = gen_if_principal(bnf, gel(I,j));
    if (!a) { avma = av; return gen_0; }
    gel(A,j) = nfC_nf_mul(nf, gel(A,j), a);
  }
  return gerepilecopy(av,A);
}
GEN rnfhnfbasis ( GEN bnf , GEN order ) { pari_sp av = avma ; long j , n ; GEN nf , A , I , a ; bnf = checkbnf ( bnf ) ; nf = bnf_get_nf ( bnf ) ; order = get_order ( nf , order , " " ) ; A = gel ( order , 1 ) ; A = RgM_shallowcopy ( A ) ; I = gel ( order , 2 ) ; n = lg ( A ) - 1 ; for ( j = 1 ; j <= n ; j ++ ) { if ( ideal_is1 ( gel ( I , j ) ) ) continue ; a = gen_if_principal ( bnf , gel ( I , j ) ) ; if ( ! a ) { avma = av ; return gen_0 ; } gel ( A , j ) = nfC_nf_mul ( nf , gel ( A , j ) , a ) ; } return gerepilecopy ( av , A ) ; }
Given bnf and either an order as output by rnfpseudobasis or a polynomial,
 and outputs a basis (not pseudo) in Hermite Normal Form if it exists, zero
 if not
Given bnf and either an order as output by rnfpseudobasis or a polynomial and outputs a basis ( not pseudo ) in Hermite Normal Form if it exists zero if not