bridge/class-master/depend/pari/src/basemath/bibli1.c
/* x is a vector of elts of a p-adic field */
x is a vector of elts of a p-adic field
x is a vector of elts of a p - adic field
GEN
lindep_padic(GEN x)
{
  long i, j, prec = LONG_MAX, nx = lg(x)-1, v;
  pari_sp av = avma;
  GEN p = NULL, pn, m, a;
  if (nx < 2) return cgetg(1,t_COL);
  for (i=1; i<=nx; i++)
  {
    GEN c = gel(x,i), q;
    if (typ(c) != t_PADIC) continue;
    j = precp(c); if (j < prec) prec = j;
    q = gel(c,2);
    if (!p) p = q; else if (!equalii(p, q)) pari_err_MODULUS("lindep_padic", p, q);
  }
  if (!p) pari_err_TYPE("lindep_padic [not a p-adic vector]",x);
  v = gvaluation(x,p); pn = powiu(p,prec);
  if (v) x = gmul(x, powis(p, -v));
  x = RgV_to_FpV(x, pn);
  a = negi(gel(x,1));
  m = cgetg(nx,t_MAT);
  for (i=1; i<nx; i++)
  {
    GEN c = zerocol(nx);
    gel(c,1+i) = a;
    gel(c,1) = gel(x,i+1);
    gel(m,i) = c;
  }
  m = ZM_lll(ZM_hnfmodid(m, pn), 0.99, LLL_INPLACE);
  return gerepilecopy(av, gel(m,1));
}
GEN lindep_padic ( GEN x ) { long i , j , prec = LONG_MAX , nx = lg ( x ) - 1 , v ; pari_sp av = avma ; GEN p = NULL , pn , m , a ; if ( nx < 2 ) return cgetg ( 1 , t_COL ) ; for ( i = 1 ; i <= nx ; i ++ ) { GEN c = gel ( x , i ) , q ; if ( typ ( c ) != t_PADIC ) continue ; j = precp ( c ) ; if ( j < prec ) prec = j ; q = gel ( c , 2 ) ; if ( ! p ) p = q ; else if ( ! equalii ( p , q ) ) pari_err_MODULUS ( " " , p , q ) ; } if ( ! p ) pari_err_TYPE ( " " , x ) ; v = gvaluation ( x , p ) ; pn = powiu ( p , prec ) ; if ( v ) x = gmul ( x , powis ( p , - v ) ) ; x = RgV_to_FpV ( x , pn ) ; a = negi ( gel ( x , 1 ) ) ; m = cgetg ( nx , t_MAT ) ; for ( i = 1 ; i < nx ; i ++ ) { GEN c = zerocol ( nx ) ; gel ( c , 1 + i ) = a ; gel ( c , 1 ) = gel ( x , i + 1 ) ; gel ( m , i ) = c ; } m = ZM_lll ( ZM_hnfmodid ( m , pn ) , 0.99 , LLL_INPLACE ) ; return gerepilecopy ( av , gel ( m , 1 ) ) ; }
x is a vector of elts of a p-adic field
x is a vector of elts of a p - adic field