bridge/class-master/depend/pari/src/basemath/mftrace.c
/* Assume mf is a non-trivial new space, rational primitive character CHIP
 * and (Q,FC) = 1 */
Assume mf is a non-trivial new space, rational primitive character CHIP
and (Q,FC) = 1
Assume mf is a non - trivial new space rational primitive character CHIP and ( Q FC ) = 1
static GEN
mfatkinmatnewquad(GEN mf, GEN CHIP, long Q, long flag, long PREC)
{
  GEN cM, M, D, MF, den, vE, F = MF_get_newforms(mf);
  long i, c, e, prec, bitprec, lF = lg(F), N = MF_get_N(mf), k = MF_get_k(mf);
  if (Q == 1) return mkvec4(gen_0, matid(MF_get_dim(mf)), gen_1, mf);
  den = gel(MF_get_Minv(mf), 2);
  bitprec = expi(den) + 64;
  if (!flag) bitprec = maxss(bitprec, prec2nbits(PREC));
START:
  prec = nbits2prec(bitprec);
  vE = mfeigenembed(mf, prec);
  M = cgetg(lF, t_VEC);
  for (i = 1; i < lF; i++) gel(M,i) = RgC_embedall(gel(F,i), gel(vE,i));
  if (Q != N)
  {
    D = mfatkineigenquad(mf, CHIP, Q, M, bitprec);
    c = odd(k)? Q: 1;
  }
  else
  {
    D = mffrickeeigen(mf, vE, DEFAULTPREC);
    c = mfcharmodulus(CHIP); if (odd(k)) c = -Q/c;
  }
  D = shallowconcat1(D);
  if (vec_isconst(D)) { MF = diagonal_shallow(D); flag = 0; }
  else
  {
    M = shallowconcat1(M);
    MF = RgM_mul(matmuldiagonal(M,D), ginv(M));
  }
  if (!flag) return mkvec4(gen_0, MF, gen_1, mf);
  if (c > 0)
    cM = myusqrt(c, PREC);
  else
  {
    MF = imag_i(MF); c = -c;
    cM = mkcomplex(gen_0, myusqrt(c,PREC));
  }
  if (c != 1) MF = RgM_Rg_mul(MF, myusqrt(c,prec));
  MF = grndtoi(RgM_Rg_mul(MF,den), &e);
  if (e > -32) { bitprec <<= 1; goto START; }
  MF = RgM_Rg_div(MF, den);
  if (is_rational_t(typ(cM)) && !isint1(cM))
  { MF = RgM_Rg_div(MF, cM); cM = gen_1; }
  return mkvec4(gen_0, MF, cM, mf);
}
static GEN mfatkinmatnewquad ( GEN mf , GEN CHIP , long Q , long flag , long PREC ) { GEN cM , M , D , MF , den , vE , F = MF_get_newforms ( mf ) ; long i , c , e , prec , bitprec , lF = lg ( F ) , N = MF_get_N ( mf ) , k = MF_get_k ( mf ) ; if ( Q == 1 ) return mkvec4 ( gen_0 , matid ( MF_get_dim ( mf ) ) , gen_1 , mf ) ; den = gel ( MF_get_Minv ( mf ) , 2 ) ; bitprec = expi ( den ) + 64 ; if ( ! flag ) bitprec = maxss ( bitprec , prec2nbits ( PREC ) ) ; START : prec = nbits2prec ( bitprec ) ; vE = mfeigenembed ( mf , prec ) ; M = cgetg ( lF , t_VEC ) ; for ( i = 1 ; i < lF ; i ++ ) gel ( M , i ) = RgC_embedall ( gel ( F , i ) , gel ( vE , i ) ) ; if ( Q != N ) { D = mfatkineigenquad ( mf , CHIP , Q , M , bitprec ) ; c = odd ( k ) ? Q : 1 ; } else { D = mffrickeeigen ( mf , vE , DEFAULTPREC ) ; c = mfcharmodulus ( CHIP ) ; if ( odd ( k ) ) c = - Q / c ; } D = shallowconcat1 ( D ) ; if ( vec_isconst ( D ) ) { MF = diagonal_shallow ( D ) ; flag = 0 ; } else { M = shallowconcat1 ( M ) ; MF = RgM_mul ( matmuldiagonal ( M , D ) , ginv ( M ) ) ; } if ( ! flag ) return mkvec4 ( gen_0 , MF , gen_1 , mf ) ; if ( c > 0 ) cM = myusqrt ( c , PREC ) ; else { MF = imag_i ( MF ) ; c = - c ; cM = mkcomplex ( gen_0 , myusqrt ( c , PREC ) ) ; } if ( c != 1 ) MF = RgM_Rg_mul ( MF , myusqrt ( c , prec ) ) ; MF = grndtoi ( RgM_Rg_mul ( MF , den ) , & e ) ; if ( e > -32 ) { bitprec <<= 1 ; goto START ; } MF = RgM_Rg_div ( MF , den ) ; if ( is_rational_t ( typ ( cM ) ) && ! isint1 ( cM ) ) { MF = RgM_Rg_div ( MF , cM ) ; cM = gen_1 ; } return mkvec4 ( gen_0 , MF , cM , mf ) ; }
Assume mf is a non-trivial new space, rational primitive character CHIP
 and (Q,FC) = 1
Assume mf is a non - trivial new space rational primitive character CHIP and ( Q FC ) = 1