bridge/class-master/depend/pari/src/basemath/alglin2.c
/* characteristic pol. Easy cases. Return NULL in case it's not so easy. */
characteristic pol. Easy cases. Return NULL in case it's not so easy.
characteristic pol . Easy cases . Return NULL in case it ' s not so easy .
static GEN
easychar(GEN x, long v)
{
  pari_sp av;
  long lx;
  GEN p1;
  switch(typ(x))
  {
    case t_INT: case t_REAL: case t_INTMOD:
    case t_FRAC: case t_PADIC:
      p1=cgetg(4,t_POL);
      p1[1]=evalsigne(1) | evalvarn(v);
      gel(p1,2) = gneg(x); gel(p1,3) = gen_1;
      return p1;
    case t_COMPLEX: case t_QUAD:
      p1 = cgetg(5,t_POL);
      p1[1] = evalsigne(1) | evalvarn(v);
      gel(p1,2) = gnorm(x); av = avma;
      gel(p1,3) = gerepileupto(av, gneg(gtrace(x)));
      gel(p1,4) = gen_1; return p1;
    case t_FFELT: {
      pari_sp ltop=avma;
      p1 = FpX_to_mod(FF_charpoly(x), FF_p_i(x));
      setvarn(p1,v); return gerepileupto(ltop,p1);
    }
    case t_POLMOD:
    {
      GEN A = gel(x,2), T = gel(x,1);
      if (typ(A)==t_POL && RgX_is_QX(A) && RgX_is_ZX(T))
        return QXQ_charpoly(A, T, v);
      else
        return RgXQ_charpoly(A, T, v);
    }
    case t_MAT:
      lx=lg(x);
      if (lx==1) return pol_1(v);
      if (lgcols(x) != lx) break;
      return NULL;
  }
  pari_err_TYPE("easychar",x);
  return NULL; 
}
static GEN easychar ( GEN x , long v ) { pari_sp av ; long lx ; GEN p1 ; switch ( typ ( x ) ) { case t_INT : case t_REAL : case t_INTMOD : case t_FRAC : case t_PADIC : p1 = cgetg ( 4 , t_POL ) ; p1 [ 1 ] = evalsigne ( 1 ) | evalvarn ( v ) ; gel ( p1 , 2 ) = gneg ( x ) ; gel ( p1 , 3 ) = gen_1 ; return p1 ; case t_COMPLEX : case t_QUAD : p1 = cgetg ( 5 , t_POL ) ; p1 [ 1 ] = evalsigne ( 1 ) | evalvarn ( v ) ; gel ( p1 , 2 ) = gnorm ( x ) ; av = avma ; gel ( p1 , 3 ) = gerepileupto ( av , gneg ( gtrace ( x ) ) ) ; gel ( p1 , 4 ) = gen_1 ; return p1 ; case t_FFELT : { pari_sp ltop = avma ; p1 = FpX_to_mod ( FF_charpoly ( x ) , FF_p_i ( x ) ) ; setvarn ( p1 , v ) ; return gerepileupto ( ltop , p1 ) ; } case t_POLMOD : { GEN A = gel ( x , 2 ) , T = gel ( x , 1 ) ; if ( typ ( A ) == t_POL && RgX_is_QX ( A ) && RgX_is_ZX ( T ) ) return QXQ_charpoly ( A , T , v ) ; else return RgXQ_charpoly ( A , T , v ) ; } case t_MAT : lx = lg ( x ) ; if ( lx == 1 ) return pol_1 ( v ) ; if ( lgcols ( x ) != lx ) break ; return NULL ; } pari_err_TYPE ( " " , x ) ; return NULL ; }
characteristic pol.
characteristic pol .
/* LCOV_EXCL_LINE */