bridge/class-master/depend/pari/src/basemath/base3.c
/* signs = NULL: totally positive at archp */
signs = NULL: totally positive at archp
signs = NULL : totally positive at archp
static GEN
nfsetsigns(GEN nf, GEN signs, GEN x, GEN sarch)
{
  long i, l = lg(sarch_get_archp(sarch));
  GEN ex;
  if (typ(x) != t_COL)
  {
    long s = gsigne(x);
    if (!s) i = 1;
    else if (!signs)
      i = (s < 0)? 1: l;
    else
    {
      s = s < 0? 1: 0;
      for (i = 1; i < l; i++)
        if (signs[i] != s) break;
    }
    ex = (i < l)? const_col(l-1, x): NULL;
  }
  else
  {
    pari_sp av = avma;
    GEN cex, M = nf_get_M(nf), archp = sarch_get_archp(sarch);
    GEN xp = Q_primitive_part(x,&cex);
    ex = cgetg(l,t_COL);
    for (i = 1; i < l; i++) gel(ex,i) = zk_embed(M,xp,archp[i]);
    if (nfchecksigns_i(nf, xp, ex, signs, archp)) { ex = NULL; avma = av; }
    else if (cex) ex = RgC_Rg_mul(ex, cex); 
  }
  if (ex)
  { 
    GEN MI = sarch_get_MI(sarch), F = sarch_get_F(sarch);
    GEN lambda = sarch_get_lambda(sarch);
    GEN t = RgC_sub(get_C(lambda, l, signs), ex);
    long e;
    t = grndtoi(RgM_RgC_mul(MI,t), &e);
    if (lg(F) != 1) t = ZM_ZC_mul(F, t);
    x = typ(x) == t_COL? RgC_add(t, x): RgC_Rg_add(t, x);
  }
  return x;
}
static GEN nfsetsigns ( GEN nf , GEN signs , GEN x , GEN sarch ) { long i , l = lg ( sarch_get_archp ( sarch ) ) ; GEN ex ; if ( typ ( x ) != t_COL ) { long s = gsigne ( x ) ; if ( ! s ) i = 1 ; else if ( ! signs ) i = ( s < 0 ) ? 1 : l ; else { s = s < 0 ? 1 : 0 ; for ( i = 1 ; i < l ; i ++ ) if ( signs [ i ] != s ) break ; } ex = ( i < l ) ? const_col ( l - 1 , x ) : NULL ; } else { pari_sp av = avma ; GEN cex , M = nf_get_M ( nf ) , archp = sarch_get_archp ( sarch ) ; GEN xp = Q_primitive_part ( x , & cex ) ; ex = cgetg ( l , t_COL ) ; for ( i = 1 ; i < l ; i ++ ) gel ( ex , i ) = zk_embed ( M , xp , archp [ i ] ) ; if ( nfchecksigns_i ( nf , xp , ex , signs , archp ) ) { ex = NULL ; avma = av ; } else if ( cex ) ex = RgC_Rg_mul ( ex , cex ) ; } if ( ex ) { GEN MI = sarch_get_MI ( sarch ) , F = sarch_get_F ( sarch ) ; GEN lambda = sarch_get_lambda ( sarch ) ; GEN t = RgC_sub ( get_C ( lambda , l , signs ) , ex ) ; long e ; t = grndtoi ( RgM_RgC_mul ( MI , t ) , & e ) ; if ( lg ( F ) != 1 ) t = ZM_ZC_mul ( F , t ) ; x = typ ( x ) == t_COL ? RgC_add ( t , x ) : RgC_Rg_add ( t , x ) ; } return x ; }
signs = NULL: totally positive at archp
signs = NULL : totally positive at archp
/* Is signature already correct ? */ /* put back content */ /* If no, fix it */