bridge/class-master/depend/pari/src/basemath/base3.c
/* Assume nf is a genuine nf. */
Assume nf is a genuine nf.
Assume nf is a genuine nf .
GEN
nf_to_scalar_or_alg(GEN nf, GEN x)
{
  switch(typ(x))
  {
    case t_INT: case t_FRAC:
      return x;
    case t_POLMOD:
      x = checknfelt_mod(nf,x,"nf_to_scalar_or_alg");
      if (typ(x) != t_POL) return x;
    case t_POL:
    {
      GEN T = nf_get_pol(nf);
      long l = lg(x);
      if (varn(x) != varn(T)) pari_err_VAR("nf_to_scalar_or_alg", x,T);
      if (l >= lg(T)) { x = RgX_rem(x, T); l = lg(x); }
      if (l == 2) return gen_0;
      if (l == 3) return gel(x,2);
      return x;
    }
    case t_COL:
    {
      GEN dx;
      if (lg(x)-1 != nf_get_degree(nf)) break;
      if (QV_isscalar(x)) return gel(x,1);
      x = Q_remove_denom(x, &dx);
      x = RgV_RgC_mul(nf_get_zkprimpart(nf), x);
      dx = mul_denom(dx, nf_get_zkden(nf));
      return gdiv(x,dx);
    }
  }
  pari_err_TYPE("nf_to_scalar_or_alg",x);
  return NULL; 
}
GEN nf_to_scalar_or_alg ( GEN nf , GEN x ) { switch ( typ ( x ) ) { case t_INT : case t_FRAC : return x ; case t_POLMOD : x = checknfelt_mod ( nf , x , " " ) ; if ( typ ( x ) != t_POL ) return x ; case t_POL : { GEN T = nf_get_pol ( nf ) ; long l = lg ( x ) ; if ( varn ( x ) != varn ( T ) ) pari_err_VAR ( " " , x , T ) ; if ( l >= lg ( T ) ) { x = RgX_rem ( x , T ) ; l = lg ( x ) ; } if ( l == 2 ) return gen_0 ; if ( l == 3 ) return gel ( x , 2 ) ; return x ; } case t_COL : { GEN dx ; if ( lg ( x ) - 1 != nf_get_degree ( nf ) ) break ; if ( QV_isscalar ( x ) ) return gel ( x , 1 ) ; x = Q_remove_denom ( x , & dx ) ; x = RgV_RgC_mul ( nf_get_zkprimpart ( nf ) , x ) ; dx = mul_denom ( dx , nf_get_zkden ( nf ) ) ; return gdiv ( x , dx ) ; } } pari_err_TYPE ( " " , x ) ; return NULL ; }
Assume nf is a genuine nf.
Assume nf is a genuine nf .
/* fall through */ /* LCOV_EXCL_LINE */