bridge/class-master/depend/pari/src/modules/algebras.c
/* Return gen_0 if already simple. mini: only returns a central idempotent
 * corresponding to one simple factor
 * if pt_primelt!=NULL, sets it to a primitive element of the center when simple */
Return gen_0 if already simple. mini: only returns a central idempotent
corresponding to one simple factor
if pt_primelt!=NULL, sets it to a primitive element of the center when simple
Return gen_0 if already simple . mini : only returns a central idempotent corresponding to one simple factor if pt_primelt! = NULL sets it to a primitive element of the center when simple
static GEN
alg_decompose(GEN al, GEN Z, long mini, GEN* pt_primelt)
{
  pari_sp av;
  GEN Zal, x, zx, rand, dec0, B, p;
  long i, nz = lg(Z)-1;
  if (nz == 1) {
    if (pt_primelt != 0) *pt_primelt = mkvec2(zerocol(alg_get_dim(al)), pol_x(0));
    return gen_0;
  }
  p = alg_get_char(al);
  dbg_printf(2)(" alg_decompose: char=%Ps, dim=%d, dim Z=%d\n", p, alg_get_absdim(al), nz);
  Zal = alg_subalg(al,Z);
  Z = gel(Zal,2);
  Zal = gel(Zal,1);
  av = avma;
  rand = random_pm1(nz);
  zx = zc_to_ZC(rand);
  if (signe(p)) {
    zx = FpC_red(zx,p);
    x = ZM_zc_mul(Z,rand);
    x = FpC_red(x,p);
  }
  else x = RgM_zc_mul(Z,rand);
  dec0 = try_fact(al,x,zx,Z,Zal,mini,pt_primelt);
  if (dec0) return dec0;
  avma = av;
  for (i=2; i<=nz; i++)
  {
    dec0 = try_fact(al,gel(Z,i),col_ei(nz,i),Z,Zal,mini,pt_primelt);
    if (dec0) return dec0;
    avma = av;
  }
  B = int2n(10);
  for (;;)
  {
    GEN x = randcol(nz,B), zx = ZM_ZC_mul(Z,x);
    dec0 = try_fact(al,x,zx,Z,Zal,mini,pt_primelt);
    if (dec0) return dec0;
    avma = av;
  }
}
static GEN alg_decompose ( GEN al , GEN Z , long mini , GEN * pt_primelt ) { pari_sp av ; GEN Zal , x , zx , rand , dec0 , B , p ; long i , nz = lg ( Z ) - 1 ; if ( nz == 1 ) { if ( pt_primelt != 0 ) * pt_primelt = mkvec2 ( zerocol ( alg_get_dim ( al ) ) , pol_x ( 0 ) ) ; return gen_0 ; } p = alg_get_char ( al ) ; dbg_printf ( 2 ) ( " \n " , p , alg_get_absdim ( al ) , nz ) ; Zal = alg_subalg ( al , Z ) ; Z = gel ( Zal , 2 ) ; Zal = gel ( Zal , 1 ) ; av = avma ; rand = random_pm1 ( nz ) ; zx = zc_to_ZC ( rand ) ; if ( signe ( p ) ) { zx = FpC_red ( zx , p ) ; x = ZM_zc_mul ( Z , rand ) ; x = FpC_red ( x , p ) ; } else x = RgM_zc_mul ( Z , rand ) ; dec0 = try_fact ( al , x , zx , Z , Zal , mini , pt_primelt ) ; if ( dec0 ) return dec0 ; avma = av ; for ( i = 2 ; i <= nz ; i ++ ) { dec0 = try_fact ( al , gel ( Z , i ) , col_ei ( nz , i ) , Z , Zal , mini , pt_primelt ) ; if ( dec0 ) return dec0 ; avma = av ; } B = int2n ( 10 ) ; for ( ; ; ) { GEN x = randcol ( nz , B ) , zx = ZM_ZC_mul ( Z , x ) ; dec0 = try_fact ( al , x , zx , Z , Zal , mini , pt_primelt ) ; if ( dec0 ) return dec0 ; avma = av ; } }
Return gen_0 if already simple.
Return gen_0 if already simple .