bridge/class-master/depend/pari/src/modules/algebras.c
/* assumes the lattice contains d * integral basis, d=0 allowed */
assumes the lattice contains d * integral basis, d=0 allowed
assumes the lattice contains d * integral basis d = 0 allowed
GEN
alglathnf(GEN al, GEN m, GEN d)
{
  pari_sp av = avma;
  long N,i,j;
  GEN m2, c;
  checkalg(al);
  N = alg_get_absdim(al);
  if (!d) d = gen_0;
  if (typ(m) == t_VEC) m = matconcat(m);
  if (typ(m) == t_COL) m = algleftmultable(al,m);
  if (typ(m) != t_MAT) pari_err_TYPE("alglathnf",m);
  if (typ(d) != t_FRAC && typ(d) != t_INT) pari_err_TYPE("alglathnf",d);
  if (lg(m)-1 < N || lg(gel(m,1))-1 != N) pari_err_DIM("alglathnf");
  for (i=1; i<=N; i++)
    for (j=1; j<lg(m); j++)
      if (typ(gcoeff(m,i,j)) != t_FRAC && typ(gcoeff(m,i,j)) != t_INT)
        pari_err_TYPE("alglathnf", gcoeff(m,i,j));
  m2 = Q_primitive_part(m,&c);
  if (!c) c = gen_1;
  if (!signe(d)) d = detint(m2);
  else           d = gdiv(d,c); 
  if (!signe(d)) pari_err_INV("alglathnf [m does not have full rank]", m2);
  m2 = ZM_hnfmodid(m2,d);
  return gerepilecopy(av, mkvec2(m2,c));
}
GEN alglathnf ( GEN al , GEN m , GEN d ) { pari_sp av = avma ; long N , i , j ; GEN m2 , c ; checkalg ( al ) ; N = alg_get_absdim ( al ) ; if ( ! d ) d = gen_0 ; if ( typ ( m ) == t_VEC ) m = matconcat ( m ) ; if ( typ ( m ) == t_COL ) m = algleftmultable ( al , m ) ; if ( typ ( m ) != t_MAT ) pari_err_TYPE ( " " , m ) ; if ( typ ( d ) != t_FRAC && typ ( d ) != t_INT ) pari_err_TYPE ( " " , d ) ; if ( lg ( m ) - 1 < N || lg ( gel ( m , 1 ) ) - 1 != N ) pari_err_DIM ( " " ) ; for ( i = 1 ; i <= N ; i ++ ) for ( j = 1 ; j < lg ( m ) ; j ++ ) if ( typ ( gcoeff ( m , i , j ) ) != t_FRAC && typ ( gcoeff ( m , i , j ) ) != t_INT ) pari_err_TYPE ( " " , gcoeff ( m , i , j ) ) ; m2 = Q_primitive_part ( m , & c ) ; if ( ! c ) c = gen_1 ; if ( ! signe ( d ) ) d = detint ( m2 ) ; else d = gdiv ( d , c ) ; if ( ! signe ( d ) ) pari_err_INV ( " " , m2 ) ; m2 = ZM_hnfmodid ( m2 , d ) ; return gerepilecopy ( av , mkvec2 ( m2 , c ) ) ; }
assumes the lattice contains d * integral basis, d=0 allowed
assumes the lattice contains d * integral basis d = 0 allowed
/* should be an integer */