bridge/class-master/depend/pari/src/basemath/trans1.c
/* to be called by the generic function gpowgs(x,s) when s = 0 */
to be called by the generic function gpowgs(x,s) when s = 0
to be called by the generic function gpowgs ( x s ) when s = 0
static GEN
gpowg0(GEN x)
{
  long lx, i;
  GEN y;
  switch(typ(x))
  {
    case t_INT: case t_REAL: case t_FRAC: case t_PADIC:
      return gen_1;
    case t_QUAD: x++; 
    case t_COMPLEX: {
      pari_sp av = avma;
      GEN a = gpowg0(gel(x,1));
      GEN b = gpowg0(gel(x,2));
      if (a == gen_1) return b;
      if (b == gen_1) return a;
      return gerepileupto(av, gmul(a,b));
    }
    case t_INTMOD:
      y = cgetg(3,t_INTMOD);
      gel(y,1) = icopy(gel(x,1));
      gel(y,2) = is_pm1(gel(x,1))? gen_0: gen_1;
      return y;
    case t_FFELT: return FF_1(x);
    case t_POLMOD:
      retmkpolmod(scalarpol_get_1(gel(x,1)), gcopy(gel(x,1)));
    case t_RFRAC:
      return scalarpol_get_1(gel(x,2));
    case t_POL: case t_SER:
      return scalarpol_get_1(x);
    case t_MAT:
      lx=lg(x); if (lx==1) return cgetg(1,t_MAT);
      if (lx != lgcols(x)) pari_err_DIM("gpow");
      y = matid(lx-1);
      for (i=1; i<lx; i++) gcoeff(y,i,i) = gpowg0(gcoeff(x,i,i));
      return y;
    case t_QFR: return qfr_1(x);
    case t_QFI: return qfi_1(x);
    case t_VECSMALL: return identity_perm(lg(x) - 1);
  }
  pari_err_TYPE("gpow",x);
  return NULL; 
}
static GEN gpowg0 ( GEN x ) { long lx , i ; GEN y ; switch ( typ ( x ) ) { case t_INT : case t_REAL : case t_FRAC : case t_PADIC : return gen_1 ; case t_QUAD : x ++ ; case t_COMPLEX : { pari_sp av = avma ; GEN a = gpowg0 ( gel ( x , 1 ) ) ; GEN b = gpowg0 ( gel ( x , 2 ) ) ; if ( a == gen_1 ) return b ; if ( b == gen_1 ) return a ; return gerepileupto ( av , gmul ( a , b ) ) ; } case t_INTMOD : y = cgetg ( 3 , t_INTMOD ) ; gel ( y , 1 ) = icopy ( gel ( x , 1 ) ) ; gel ( y , 2 ) = is_pm1 ( gel ( x , 1 ) ) ? gen_0 : gen_1 ; return y ; case t_FFELT : return FF_1 ( x ) ; case t_POLMOD : retmkpolmod ( scalarpol_get_1 ( gel ( x , 1 ) ) , gcopy ( gel ( x , 1 ) ) ) ; case t_RFRAC : return scalarpol_get_1 ( gel ( x , 2 ) ) ; case t_POL : case t_SER : return scalarpol_get_1 ( x ) ; case t_MAT : lx = lg ( x ) ; if ( lx == 1 ) return cgetg ( 1 , t_MAT ) ; if ( lx != lgcols ( x ) ) pari_err_DIM ( " " ) ; y = matid ( lx - 1 ) ; for ( i = 1 ; i < lx ; i ++ ) gcoeff ( y , i , i ) = gpowg0 ( gcoeff ( x , i , i ) ) ; return y ; case t_QFR : return qfr_1 ( x ) ; case t_QFI : return qfi_1 ( x ) ; case t_VECSMALL : return identity_perm ( lg ( x ) - 1 ) ; } pari_err_TYPE ( " " , x ) ; return NULL ; }
to be called by the generic function gpowgs(x,s) when s = 0
to be called by the generic function gpowgs ( x s ) when s = 0
/*fall through*/ /* LCOV_EXCL_LINE */