bridge/class-master/depend/pari/src/basemath/mftrace.c
/*************************************************************************/
/*                          TRACE FORMULAS                               */
/* CHIP primitive, initialize for t_POLMOD output */
TRACE FORMULAS
CHIP primitive, initialize for t_POLMOD output
TRACE FORMULAS CHIP primitive initialize for t_POLMOD output
static GEN
mfcharinit(GEN CHIP)
{
  long n, o, l, vt, N = mfcharmodulus(CHIP);
  GEN c, v, V, G, Pn;
  if (N == 1) return mkvec2(mkvec(gen_1), pol_x(0));
  G = gel(CHIP,1);
  v = ncharvecexpo(G, znconrey_normalized(G, gel(CHIP,2)));
  l = lg(v); V = cgetg(l, t_VEC);
  o = mfcharorder(CHIP);
  Pn = mfcharpol(CHIP); vt = varn(Pn);
  if (o <= 2)
  {
    for (n = 1; n < l; n++)
    {
      if (v[n] < 0) c = gen_0; else c = v[n]? gen_m1: gen_1;
      gel(V,n) = c;
    }
  }
  else
  {
    for (n = 1; n < l; n++)
    {
      if (v[n] < 0) c = gen_0;
      else
      {
        c = mygmodulo_lift(v[n], o, gen_1, vt);
        if (typ(c) == t_POL && lg(c) >= lg(Pn)) c = RgX_rem(c, Pn);
      }
      gel(V,n) = c;
    }
  }
  return mkvec2(V, Pn);
}
static GEN mfcharinit ( GEN CHIP ) { long n , o , l , vt , N = mfcharmodulus ( CHIP ) ; GEN c , v , V , G , Pn ; if ( N == 1 ) return mkvec2 ( mkvec ( gen_1 ) , pol_x ( 0 ) ) ; G = gel ( CHIP , 1 ) ; v = ncharvecexpo ( G , znconrey_normalized ( G , gel ( CHIP , 2 ) ) ) ; l = lg ( v ) ; V = cgetg ( l , t_VEC ) ; o = mfcharorder ( CHIP ) ; Pn = mfcharpol ( CHIP ) ; vt = varn ( Pn ) ; if ( o <= 2 ) { for ( n = 1 ; n < l ; n ++ ) { if ( v [ n ] < 0 ) c = gen_0 ; else c = v [ n ] ? gen_m1 : gen_1 ; gel ( V , n ) = c ; } } else { for ( n = 1 ; n < l ; n ++ ) { if ( v [ n ] < 0 ) c = gen_0 ; else { c = mygmodulo_lift ( v [ n ] , o , gen_1 , vt ) ; if ( typ ( c ) == t_POL && lg ( c ) >= lg ( Pn ) ) c = RgX_rem ( c , Pn ) ; } gel ( V , n ) = c ; } } return mkvec2 ( V , Pn ) ; }
TRACE FORMULAS
CHIP primitive, initialize for t_POLMOD output
TRACE FORMULAS CHIP primitive initialize for t_POLMOD output