bridge/class-master/depend/pari/src/basemath/base3.c
/* return (column) vector of R1 signatures of x (0 or 1) */
return (column) vector of R1 signatures of x (0 or 1)
return ( column ) vector of R1 signatures of x ( 0 or 1 )
GEN
nfsign_arch(GEN nf, GEN x, GEN arch)
{
  GEN sarch, M, V, archp = vec01_to_indices(arch);
  long i, s, np, n = lg(archp)-1;
  pari_sp av;
  if (!n) return cgetg(1,t_VECSMALL);
  nf = checknf(nf);
  if (typ(x) == t_MAT)
  { 
    GEN g = gel(x,1), e = gel(x,2);
    V = zero_zv(n);
    for (i=1; i<lg(g); i++)
      if (mpodd(gel(e,i)))
        Flv_add_inplace(V, nfsign_arch(nf,gel(g,i),archp), 2);
    avma = (pari_sp)V; return V;
  }
  av = avma; V = cgetg(n+1,t_VECSMALL);
  x = nf_to_scalar_or_basis(nf, x);
  switch(typ(x))
  {
    case t_INT:
      s = signe(x);
      if (!s) pari_err_DOMAIN("nfsign_arch","element","=",gen_0,x);
      avma = av; return const_vecsmall(n, (s < 0)? 1: 0);
    case t_FRAC:
      s = signe(gel(x,1));
      avma = av; return const_vecsmall(n, (s < 0)? 1: 0);
  }
  x = Q_primpart(x); M = nf_get_M(nf); sarch = NULL; np = -1;
  for (i = 1; i <= n; i++)
  {
    long s = eval_sign(M, x, archp[i]);
    if (s < 0) 
    {
      long ni, r1 = nf_get_r1(nf);
      GEN xi;
      if (np < 0)
      {
        np = num_positive(nf, x);
        if (np == 0) { avma = av; return const_vecsmall(n, 1); }
        if (np == r1){ avma = av; return const_vecsmall(n, 0); }
        sarch = nfarchstar(nf, NULL, identity_perm(r1));
      }
      xi = set_sign_mod_divisor(nf, vecsmall_ei(r1, archp[i]), gen_1, sarch);
      xi = Q_primpart(xi);
      ni = num_positive(nf, nfmuli(nf,x,xi));
      if (ni == 0) { avma = av; V = const_vecsmall(n, 1); V[i] = 0; return V; }
      if (ni == r1){ avma = av; V = const_vecsmall(n, 0); V[i] = 1; return V; }
      s = ni < np? 0: 1;
    }
    V[i] = s;
  }
  avma = (pari_sp)V; return V;
}
GEN nfsign_arch ( GEN nf , GEN x , GEN arch ) { GEN sarch , M , V , archp = vec01_to_indices ( arch ) ; long i , s , np , n = lg ( archp ) - 1 ; pari_sp av ; if ( ! n ) return cgetg ( 1 , t_VECSMALL ) ; nf = checknf ( nf ) ; if ( typ ( x ) == t_MAT ) { GEN g = gel ( x , 1 ) , e = gel ( x , 2 ) ; V = zero_zv ( n ) ; for ( i = 1 ; i < lg ( g ) ; i ++ ) if ( mpodd ( gel ( e , i ) ) ) Flv_add_inplace ( V , nfsign_arch ( nf , gel ( g , i ) , archp ) , 2 ) ; avma = ( pari_sp ) V ; return V ; } av = avma ; V = cgetg ( n + 1 , t_VECSMALL ) ; x = nf_to_scalar_or_basis ( nf , x ) ; switch ( typ ( x ) ) { case t_INT : s = signe ( x ) ; if ( ! s ) pari_err_DOMAIN ( " " , " " , " " , gen_0 , x ) ; avma = av ; return const_vecsmall ( n , ( s < 0 ) ? 1 : 0 ) ; case t_FRAC : s = signe ( gel ( x , 1 ) ) ; avma = av ; return const_vecsmall ( n , ( s < 0 ) ? 1 : 0 ) ; } x = Q_primpart ( x ) ; M = nf_get_M ( nf ) ; sarch = NULL ; np = -1 ; for ( i = 1 ; i <= n ; i ++ ) { long s = eval_sign ( M , x , archp [ i ] ) ; if ( s < 0 ) { long ni , r1 = nf_get_r1 ( nf ) ; GEN xi ; if ( np < 0 ) { np = num_positive ( nf , x ) ; if ( np == 0 ) { avma = av ; return const_vecsmall ( n , 1 ) ; } if ( np == r1 ) { avma = av ; return const_vecsmall ( n , 0 ) ; } sarch = nfarchstar ( nf , NULL , identity_perm ( r1 ) ) ; } xi = set_sign_mod_divisor ( nf , vecsmall_ei ( r1 , archp [ i ] ) , gen_1 , sarch ) ; xi = Q_primpart ( xi ) ; ni = num_positive ( nf , nfmuli ( nf , x , xi ) ) ; if ( ni == 0 ) { avma = av ; V = const_vecsmall ( n , 1 ) ; V [ i ] = 0 ; return V ; } if ( ni == r1 ) { avma = av ; V = const_vecsmall ( n , 0 ) ; V [ i ] = 1 ; return V ; } s = ni < np ? 0 : 1 ; } V [ i ] = s ; } avma = ( pari_sp ) V ; return V ; }
return (column) vector of R1 signatures of x (0 or 1)
return ( column ) vector of R1 signatures of x ( 0 or 1 )
/* factorisation */ /* failure */