rem
stringlengths 0
274k
| add
stringlengths 0
169k
| context
stringlengths 9
471k
|
---|---|---|
if (plift == 0 || (n > 24 && n%12 == 0 && Fp[np]==3 && !O[6]) || ((group&ga_non_wss) && omax == Fp[np])) | if (plift == 0 || ((group&ga_non_wss) && order == Fp[np])) | galoisanalysis(GEN T, struct galois_analysis *ga, long calcul_l){ ulong ltop=avma; long n,p; long i; long group,omax; /*TODO: complete the table to at least 200*/ const int prim_nonss_orders[]={36,48,56,60,72,75,80,96,108,0}; GEN F,Fp,Fe,Fpe,O; long np; long order,phi_order; long plift,nbmax,nbtest,deg; byteptr primepointer,pp; if (DEBUGLEVEL >= 1) timer2(); n = degree(T); O = cgetg(n+1,t_VECSMALL); for(i=1;i<=n;i++) O[i]=0; F = factor(stoi(n)); Fp=vectosmall((GEN)F[1]); Fe=vectosmall((GEN)F[2]); np=lg(Fp)-1; Fpe=cgetg(lg(Fp), t_VECSMALL); for (i = 1; i < lg(Fpe); i++) Fpe[i] = itos(powgi(gmael(F,1,i), gmael(F,2,i))); /*In this part, we study the cardinal of the group to have an information about the orders, so if we are unlucky we can continue.*/ /*Are there non WSS groups of this order ?*/ group=0; for(i=0;prim_nonss_orders[i];i++) if (n%prim_nonss_orders[i] == 0) group |= ga_non_wss; if ( n>12 && n%12 == 0 ) { /*We need to know the greatest prime dividing n/12*/ if ( Fp[np] == 3 && Fe[np] == 1 ) group |= ga_ext_2; } phi_order = 1; order = 1; for (i = np; i > 0; i--) { p = Fp[i]; if (phi_order % p != 0) { order *= p; phi_order *= p - 1; } else { group |= ga_all_normal; break; } if (Fe[i]>1) break; } /*Now, we study the orders of the Frobenius elements*/ plift = 0; omax=0; nbmax = 8+(n>>1); nbtest = 0; deg = 0; for (p = 0, pp = primepointer = diffptr; (plift == 0 || (nbtest < nbmax && order != n && (nbtest <=8 || order != (n>>1))) || (n == 24 && O[6] == 0 && O[4] == 0)) && (nbtest < 3 * nbmax || (!(group&ga_non_wss) && n%12 ) ) ;) { ulong av; long prime_incr; GEN ip,FS,p1; long o,norm_o; prime_incr = *primepointer++; if (!prime_incr) err(primer1); p += prime_incr; /*discard small primes*/ if (p <= (n << 1)) continue; ip=stoi(p); if (!Fp_is_squarefree(T,ip)) continue; nbtest++; av=avma; FS=(GEN)simplefactmod(T,ip)[1]; p1=(GEN)FS[1]; for(i=2;i<lg(FS);i++) if (cmpii(p1,(GEN)FS[i])) break; if (i<lg(FS)) { avma = ltop; if (DEBUGLEVEL >= 2) fprintferr("GaloisAnalysis:non Galois for p=%ld\n", p); ga->p = p; ga->deg = 0; return; /* Not a Galois polynomial */ } o=n/(lg(FS)-1); avma=av; if (!O[o]) O[o]=p; if (DEBUGLEVEL >= 6) fprintferr("GaloisAnalysis:Nbtest=%ld,p=%ld,o=%ld,plift=%ld,ord=%ld\n", nbtest, p, o, plift, order); if (o > omax) omax = o; if (o >= order) { /*We try to find a power of the Frobenius which generate a normal subgroup just by looking at the order.*/ if (o * Fp[1] >= n) /*Subgroup of smallest index are normal*/ norm_o = o; else { norm_o = 1; for (i = np; i > 0; i--) { if (o % Fpe[i] == 0) norm_o *= Fpe[i]; else break; } } if (norm_o != 1) { if (!(group&ga_all_normal) || o > order || (o == order && (plift == 0 || norm_o > deg))) { deg = norm_o; order = o; plift = p; pp = primepointer; group |= ga_all_normal; } } else if (!(group&ga_all_normal) && (plift == 0 || o > order)) { deg = Fp[np]; order = o; plift = p; pp = primepointer; } } } /* This is to avoid looping on non-wss group. To be completed*/ if (plift == 0 || /*I am not 100% sure of this one, at least it is right for n<=72*/ (n > 24 && n%12 == 0 && Fp[np]==3 && !O[6]) || ((group&ga_non_wss) && omax == Fp[np])) { deg = 0; err(warner, "Galois group almost certainly not weakly super solvable"); } if (calcul_l && !O[1]) { ulong av; long prime_incr; long l=0; /*we need a totally splited prime l*/ av = avma; while (l == 0) { long nb; prime_incr = *primepointer++; if (!prime_incr) err(primer1); p += prime_incr; nb=FpX_nbroots(T,stoi(p)); if (nb == n) l = p; else if (nb && Fp_is_squarefree(T,stoi(p))) { avma = ltop; if (DEBUGLEVEL >= 2) fprintferr("GaloisAnalysis:non Galois for p=%ld\n", p); ga->p = p; ga->deg = 0; return; /* Not a Galois polynomial */ } avma = av; } O[1]=l; } ga->p = plift; ga->group = group; ga->deg = deg; ga->ord = order; ga->l = O[1]; ga->primepointer = pp; ga->ppp = Fp[1]; ga->p4 = O[4]; if (DEBUGLEVEL >= 4) fprintferr("GaloisAnalysis:p=%ld l=%ld group=%ld deg=%ld ord=%ld\n", p, O[1], group, deg, order); if (DEBUGLEVEL >= 1) msgtimer("galoisanalysis()"); avma = ltop;} |
p, O[1], group, deg, order); | plift, O[1], group, deg, order); | galoisanalysis(GEN T, struct galois_analysis *ga, long calcul_l){ ulong ltop=avma; long n,p; long i; long group,omax; /*TODO: complete the table to at least 200*/ const int prim_nonss_orders[]={36,48,56,60,72,75,80,96,108,0}; GEN F,Fp,Fe,Fpe,O; long np; long order,phi_order; long plift,nbmax,nbtest,deg; byteptr primepointer,pp; if (DEBUGLEVEL >= 1) timer2(); n = degree(T); O = cgetg(n+1,t_VECSMALL); for(i=1;i<=n;i++) O[i]=0; F = factor(stoi(n)); Fp=vectosmall((GEN)F[1]); Fe=vectosmall((GEN)F[2]); np=lg(Fp)-1; Fpe=cgetg(lg(Fp), t_VECSMALL); for (i = 1; i < lg(Fpe); i++) Fpe[i] = itos(powgi(gmael(F,1,i), gmael(F,2,i))); /*In this part, we study the cardinal of the group to have an information about the orders, so if we are unlucky we can continue.*/ /*Are there non WSS groups of this order ?*/ group=0; for(i=0;prim_nonss_orders[i];i++) if (n%prim_nonss_orders[i] == 0) group |= ga_non_wss; if ( n>12 && n%12 == 0 ) { /*We need to know the greatest prime dividing n/12*/ if ( Fp[np] == 3 && Fe[np] == 1 ) group |= ga_ext_2; } phi_order = 1; order = 1; for (i = np; i > 0; i--) { p = Fp[i]; if (phi_order % p != 0) { order *= p; phi_order *= p - 1; } else { group |= ga_all_normal; break; } if (Fe[i]>1) break; } /*Now, we study the orders of the Frobenius elements*/ plift = 0; omax=0; nbmax = 8+(n>>1); nbtest = 0; deg = 0; for (p = 0, pp = primepointer = diffptr; (plift == 0 || (nbtest < nbmax && order != n && (nbtest <=8 || order != (n>>1))) || (n == 24 && O[6] == 0 && O[4] == 0)) && (nbtest < 3 * nbmax || (!(group&ga_non_wss) && n%12 ) ) ;) { ulong av; long prime_incr; GEN ip,FS,p1; long o,norm_o; prime_incr = *primepointer++; if (!prime_incr) err(primer1); p += prime_incr; /*discard small primes*/ if (p <= (n << 1)) continue; ip=stoi(p); if (!Fp_is_squarefree(T,ip)) continue; nbtest++; av=avma; FS=(GEN)simplefactmod(T,ip)[1]; p1=(GEN)FS[1]; for(i=2;i<lg(FS);i++) if (cmpii(p1,(GEN)FS[i])) break; if (i<lg(FS)) { avma = ltop; if (DEBUGLEVEL >= 2) fprintferr("GaloisAnalysis:non Galois for p=%ld\n", p); ga->p = p; ga->deg = 0; return; /* Not a Galois polynomial */ } o=n/(lg(FS)-1); avma=av; if (!O[o]) O[o]=p; if (DEBUGLEVEL >= 6) fprintferr("GaloisAnalysis:Nbtest=%ld,p=%ld,o=%ld,plift=%ld,ord=%ld\n", nbtest, p, o, plift, order); if (o > omax) omax = o; if (o >= order) { /*We try to find a power of the Frobenius which generate a normal subgroup just by looking at the order.*/ if (o * Fp[1] >= n) /*Subgroup of smallest index are normal*/ norm_o = o; else { norm_o = 1; for (i = np; i > 0; i--) { if (o % Fpe[i] == 0) norm_o *= Fpe[i]; else break; } } if (norm_o != 1) { if (!(group&ga_all_normal) || o > order || (o == order && (plift == 0 || norm_o > deg))) { deg = norm_o; order = o; plift = p; pp = primepointer; group |= ga_all_normal; } } else if (!(group&ga_all_normal) && (plift == 0 || o > order)) { deg = Fp[np]; order = o; plift = p; pp = primepointer; } } } /* This is to avoid looping on non-wss group. To be completed*/ if (plift == 0 || /*I am not 100% sure of this one, at least it is right for n<=72*/ (n > 24 && n%12 == 0 && Fp[np]==3 && !O[6]) || ((group&ga_non_wss) && omax == Fp[np])) { deg = 0; err(warner, "Galois group almost certainly not weakly super solvable"); } if (calcul_l && !O[1]) { ulong av; long prime_incr; long l=0; /*we need a totally splited prime l*/ av = avma; while (l == 0) { long nb; prime_incr = *primepointer++; if (!prime_incr) err(primer1); p += prime_incr; nb=FpX_nbroots(T,stoi(p)); if (nb == n) l = p; else if (nb && Fp_is_squarefree(T,stoi(p))) { avma = ltop; if (DEBUGLEVEL >= 2) fprintferr("GaloisAnalysis:non Galois for p=%ld\n", p); ga->p = p; ga->deg = 0; return; /* Not a Galois polynomial */ } avma = av; } O[1]=l; } ga->p = plift; ga->group = group; ga->deg = deg; ga->ord = order; ga->l = O[1]; ga->primepointer = pp; ga->ppp = Fp[1]; ga->p4 = O[4]; if (DEBUGLEVEL >= 4) fprintferr("GaloisAnalysis:p=%ld l=%ld group=%ld deg=%ld ord=%ld\n", p, O[1], group, deg, order); if (DEBUGLEVEL >= 1) msgtimer("galoisanalysis()"); avma = ltop;} |
return gerepileupto(av, gcopy(C)); | return gerepilecopy(av, C); | rnfequation0(GEN nf, GEN B, long flall){ ulong av = avma; long v,vpol,k,lA,lB; GEN cC,A,C,LPRS; if (typ(nf)==t_POL) A=nf; else { nf=checknf(nf); A=(GEN)nf[1]; } B = fix_relative_pol(nf,B,1); v = varn(A); lA = lgef(A); vpol= varn(B); lB = lgef(B); if (lA<=3 || lB<=3) err(constpoler,"rnfequation"); check_pol_int(A,"rnfequation"); B = lift_intern(B); B = gdiv(B, content(B)); for (k=2; k<lB; k++) if (lgef(B[k]) >= lA) B[k] = lres((GEN)B[k],A); if (!nfissquarefree(A,B)) err(talker,"not k separable relative equation in rnfequation"); k = 0; C = ZY_ZXY_resultant_all(A, B, &k, flall? &LPRS: NULL); if (gsigne(leadingcoeff(C)) < 0) C = gneg_i(C); C = primitive_part(C, &cC); if (flall) { GEN w,a,b; /* a,b,c root of A,B,C = compositum, c = b - k a */ /* invmod possibly very costly */ a = gmul((GEN)LPRS[1], ZX_invmod((GEN)LPRS[2], C)); a = gneg_i(gmod(a, C)); b = gadd(polx[v], gmulsg(k,a)); w = cgetg(4,t_VEC); /* [C, a, n ] */ w[1] = (long)C; w[2] = (long)to_polmod(a, (GEN)w[1]); w[3] = lstoi(-k); C = w; } return gerepileupto(av, gcopy(C));} |
cbach /= 2; | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
|
av = avma; cache.end = cache.chk = cache.last = cache.base = NULL; | av = avma; cache.base = NULL; F.subFB = NULL; cbach /= 2; | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
avma = av; desallocate(&cache); | avma = av; if (cache.base) delete_cache(&cache); if (F.subFB) delete_FB(&F); | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
if (!F.pow) powFBgen(&F, &cache, nf); | if (F.newpow) powFBgen(&F, &cache, nf); | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
if (!F.pow) powFBgen(&F, NULL, nf); | if (F.newpow) powFBgen(&F, NULL, nf); | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
desallocate(&cache); gunclone(F.subFB); | delete_cache(&cache); delete_FB(&F); | buch(GEN *pnf, double cbach, double cbach2, long nbrelpid, long flun, long PRECREG){ pari_sp av, av2; long N, R1, R2, RU, LIMC, LIMC2, lim, zc, i, jid; long nreldep, sfb_trials, need, precdouble = 0, precadd = 0; double drc, LOGD, LOGD2; GEN vecG, fu, zu, nf, D, A, W, R, Res, z, h, L_jid, PERM; GEN res, L, resc, B, C, lambda, dep, clg1, clg2, Vbase; char *precpb = NULL; const int minsFB = 3; RELCACHE_t cache; FB_t F; nf = *pnf; *pnf = NULL; N = degpol(nf[1]); if (N <= 1) return buchall_for_degree_one_pol(nf, flun); zu = rootsof1(nf); zu[2] = lmul((GEN)nf[7],(GEN)zu[2]); if (DEBUGLEVEL) msgtimer("initalg & rootsof1"); nf_get_sign(nf, &R1, &R2); RU = R1+R2; D = (GEN)nf[3]; drc = fabs(gtodouble(D)); LOGD = log(drc); LOGD2 = LOGD*LOGD; lim = (long) (exp(-(double)N) * sqrt(2*PI*N*drc) * pow(4/PI,(double)R2)); if (lim < 3) lim = 3; if (cbach > 12.) cbach = 12.; cbach /= 2; if (cbach <= 0.) err(talker,"Bach constant <= 0 in buch"); /* resc ~ sqrt(D) w / 2^r1 (2pi)^r2 = hR / Res(zeta_K, s=1) */ resc = gdiv(mulri(gsqrt(absi(D),DEFAULTPREC), (GEN)zu[1]), gmul2n(gpowgs(Pi2n(1,DEFAULTPREC), R2), R1)); if (DEBUGLEVEL) fprintferr("R1 = %ld, R2 = %ld\nD = %Z\n",R1,R2, D); av = avma; cache.end = cache.chk = cache.last = cache.base = NULL;START: avma = av; desallocate(&cache); cbach = check_bach(cbach,12.); LIMC = (long)(cbach*LOGD2); if (LIMC < 20) { LIMC = 20; cbach = (double)LIMC / LOGD2; } LIMC2 = max(3 * N, (long)(cbach2*LOGD2)); if (LIMC2 < LIMC) LIMC2 = LIMC; if (DEBUGLEVEL) { fprintferr("LIMC = %ld, LIMC2 = %ld\n",LIMC,LIMC2); } Res = FBgen(&F, nf, LIMC2, LIMC); if (!Res || !subFBgen(&F, nf, min(lim,LIMC2) + 0.5, minsFB)) goto START; PERM = dummycopy(F.perm); /* to be restored in case of precision increase */ av2 = avma; init_rel(&cache, &F, RU); /* trivial relations */ if (nbrelpid > 0) {small_norm(&cache,&F,LOGD,nf,nbrelpid,LIMC2); avma = av2;} /* Random relations */ W = vecG = L_jid = NULL; jid = sfb_trials = nreldep = 0; need = cache.end - cache.last; if (need > 0) { if (DEBUGLEVEL) fprintferr("\n#### Looking for random relations\n");MORE: if (!vecG) { vecG = compute_vecG(nf, min(RU, 9)); av2 = avma; } pre_allocate(&cache, need); cache.end = cache.last + need; if (++nreldep > MAXRELSUP) { F.sfb_chg = sfb_INCREASE; if (++sfb_trials > SFB_MAX) goto START; } if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; jid = nreldep = 0; } if (!F.pow) powFBgen(&F, &cache, nf); if (!F.sfb_chg && !rnd_rel(&cache,&F, nf, vecG, L_jid, &jid)) goto START; L_jid = NULL; } if (precpb) {PRECPB: if (precadd) { PRECREG += precadd; precadd = 0; } else PRECREG = (PRECREG<<1)-2; if (DEBUGLEVEL) { char str[64]; sprintf(str,"buchall (%s)",precpb); err(warnprec,str,PRECREG); } precdouble++; precpb = NULL; nf = nf_cloneprec(nf, PRECREG, pnf); if (F.pow && F.pow->arc) { gunclone(F.pow->arc); F.pow->arc = NULL; } for (i = 1; i < lg(PERM); i++) F.perm[i] = PERM[i]; cache.chk = cache.base; W = NULL; /* recompute arch components + reduce */ } { /* Reduce relation matrices */ long l = cache.last - cache.chk + 1, j; GEN M = gmael(nf, 5, 1), mat = cgetg(l, t_VEC), emb = cgetg(l, t_MAT); int first = (W == NULL); /* never reduced before */ REL_t *rel; if (F.pow && !F.pow->arc) powFB_fill(&cache, M); for (j=1,rel = cache.chk + 1; rel <= cache.last; rel++,j++) { mat[j] = (long)rel->R; emb[j] = (long)get_log_embed(rel, M, RU, R1, PRECREG); } if (first) { C = emb; W = hnfspec_i((long**)mat, F.perm, &dep, &B, &C, lg(F.subFB)-1); } else W = hnfadd_i(W, F.perm, &dep, &B, &C, mat, emb); gerepileall(av2, 4, &W,&C,&B,&dep); cache.chk = cache.last; need = lg(dep)>1? lg(dep[1])-1: lg(B[1])-1; if (need) { /* dependent rows */ if (need > 5) { if (need > 20 && !first) F.sfb_chg = sfb_CHANGE; L_jid = vecextract_i(F.perm, 1, need); vecsmall_sort(L_jid); jid = 0; } goto MORE; } } zc = (cache.last - cache.base) - (lg(B)-1) - (lg(W)-1); A = vecextract_i(C, 1, zc); /* cols corresponding to units */ R = compute_multiple_of_R(A, RU, N, &lambda); if (!R) { /* not full rank for units */ if (DEBUGLEVEL) fprintferr("regulator is zero.\n"); goto MORE; } if (!lambda) { precpb = "bestappr"; goto PRECPB; } h = dethnf_i(W); if (DEBUGLEVEL) fprintferr("\n#### Tentative class number: %Z\n", h); z = mulrr(Res, resc); /* ~ hR if enough relations, a multiple otherwise */ switch (compute_R(lambda, divir(h,z), &L, &R)) { case fupb_RELAT: goto MORE; /* not enough relations */ case fupb_PRECI: /* prec problem unless we cheat on Bach constant */ if ((precdouble&7) < 7 || cbach>2) { precpb = "compute_R"; goto PRECPB; } goto START; } /* DONE */ if (F.KCZ2 > F.KCZ) { if (!vecG) vecG = compute_vecG(nf, min(RU, 9)); if (!F.pow) powFBgen(&F, NULL, nf); if (F.sfb_chg) { if (!subFB_change(&F, nf, L_jid)) goto START; powFBgen(&F, NULL, nf); } if (!be_honest(&F, nf, vecG)) goto START; } F.KCZ2 = 0; /* be honest only once */ /* fundamental units */ if (flun & (nf_UNITS|nf_INIT)) { GEN v = extract_full_lattice(L); /* L may be very large */ if (v) { A = vecextract_p(A, v); L = vecextract_p(L, v); } /* arch. components of fund. units */ A = cleanarch(gmul(A,lllint(L)), N, PRECREG); if (DEBUGLEVEL) msgtimer("cleanarch"); } fu = NULL; if (flun & nf_UNITS) { long e; fu = getfu(nf, &A, flun, &e, PRECREG); if (e <= 0 && (flun & nf_FORCE)) { if (e < 0) precadd = (DEFAULTPREC-2) + ((-e) >> TWOPOTBITS_IN_LONG); precpb = "getfu"; goto PRECPB; } } desallocate(&cache); gunclone(F.subFB); /* class group generators */ i = lg(C)-zc; C += zc; C[0] = evaltyp(t_MAT)|evallg(i); C = cleanarch(C, N, PRECREG); Vbase = vecextract_p(F.LP, F.perm); class_group_gen(nf,W,C,Vbase,PRECREG,NULL, &clg1, &clg2); res = get_clfu(clg1, R, zu, fu, flun); return buchall_end(nf,flun,res,clg2,W,B,A,C,Vbase);} |
KCZ2=i; KC2=ip; MAXRELSUP = min(50,4*KC); | KCZ2=i; KC2=ip; MAXRELSUP = min(50,4*KC) / SFB_MAX; | factorbasegen(GEN nf,long n2,long n){ byteptr delta=diffptr; long KC2,i,j,k,p,lon,ip,nor, N = lgef(nf[1])-3; GEN p2,p1,NormP,lfun; long prim[] = { evaltyp(t_INT)|m_evallg(3), evalsigne(1)|evallgefint(3),0 }; numfactorbase= (long*)gpmalloc(sizeof(long)*(n2+1)); factorbase = (long*)gpmalloc(sizeof(long)*(n2+1)); numideal = (long*)gpmalloc(sizeof(long)*(n2+1)); idealbase = (GEN *)gpmalloc(sizeof(GEN )*(n2+1)); lfun=cgetr(DEFAULTPREC); affsr(1,lfun); p=*delta++; i=0; ip=0; KC=0; while (p<=n2) { long av = avma, av1; if (DEBUGLEVEL>=2) { fprintferr(" %ld",p); flusherr(); } prim[2] = p; p1 = primedec(nf,prim); lon=lg(p1); av1 = avma; divrsz(mulsr(p-1,lfun),p,lfun); if (itos(gmael(p1,1,4)) == N) /* p inert */ { NormP = gpowgs(prim,N); if (!is_bigint(NormP) && (nor=NormP[2]) <= n2) divrsz(mulsr(nor,lfun),nor-1, lfun); avma = av1; } else { numideal[p]=ip; i++; numfactorbase[p]=i; factorbase[i]=p; for (k=1; k<lon; k++,ip++) { NormP = powgi(prim,gmael(p1,k,4)); if (is_bigint(NormP) || (nor=NormP[2]) > n2) break; divrsz(mulsr(nor,lfun),nor-1, lfun); } /* keep all ideals with Norm <= n2 */ avma = av1; if (k == lon) setisclone(p1); /* flag it: all prime divisors in factorbase */ else { setlg(p1,k); p1 = gerepile(av,av1,gcopy(p1)); } idealbase[i] = p1; } if (!*delta) err(primer1); p += *delta++; if (KC == 0 && p>n) { KCZ=i; KC=ip; } } if (!KC) return NULL; KCZ2=i; KC2=ip; MAXRELSUP = min(50,4*KC); vectbase=cgetg(KC+1,t_COL); for (i=1; i<=KCZ; i++) { p1 = idealbase[i]; k=lg(p1); p2 = vectbase + numideal[factorbase[i]]; for (j=1; j<k; j++) p2[j]=p1[j]; } if (DEBUGLEVEL) { if (DEBUGLEVEL>1) fprintferr("\n"); if (DEBUGLEVEL>6) { fprintferr("########## FACTORBASE ##########\n\n"); fprintferr("KC2=%ld, KC=%ld, KCZ=%ld, KCZ2=%ld, MAXRELSUP=%ld\n", KC2, KC, KCZ, KCZ2, MAXRELSUP); for (i=1; i<=KCZ; i++) fprintferr("++ idealbase[%ld] = %Z",i,idealbase[i]); } msgtimer("factor base"); } return lfun;} |
perm1 = sindexsort(y2); for (j=1; j<=n; j++) vperm[j] = perm[j]; for ( ; j<lv; j++) vperm[j] = perm1[j]; | perm1 = sindexsort(y2); avma = av; | subfactorbasegen(long N,long m,long minsfb,GEN vperm){ long av=avma,i,j, lv=lg(vectbase),s=0,s1=0,n=0,ss=0,z=0; GEN y1,y2,perm,perm1,P,Q; double prod; y1 = cgetg(lv,t_COL); y2 = cgetg(lv,t_COL); for (i=1,P=(GEN)vectbase[i];;P=Q) { /* we'll sort ideals by norm (flag excluded ideals with "zero") */ long e = itos((GEN)P[3]); long ef= e*itos((GEN)P[4]); s1 += ef; y2[i] = (long)powgi((GEN)P[1],(GEN)P[4]); /* take only unramified ideals */ if (e>1) { y1[i]=zero; s=0; z++; } else { y1[i]=y2[i]; s += ef; } i++; Q = (GEN)vectbase[i]; if (i == lv || !egalii((GEN)P[1], (GEN)Q[1])) { /* don't take all P above a given p (delete the last one) */ if (s == N) { y1[i-1]=zero; z++; } if (s1== N) ss++; if (i == lv) break; s=0; s1=0; } } if (z+minsfb >= lv) return -1; prod = 1.0; perm = sindexsort(y1) + z; /* skip "zeroes" (excluded ideals) */ for(;;) { if (++n > minsfb && (z+n >= lv || prod > m + 0.5)) break; prod *= gtodouble((GEN)y1[perm[n]]); } if (prod < m) return -1; n--; /* take the first (wrt norm) n ideals, and put them first */ for (j=1; j<=n; j++) y2[perm[j]] = zero; perm1 = sindexsort(y2); for (j=1; j<=n; j++) vperm[j] = perm[j]; for ( ; j<lv; j++) vperm[j] = perm1[j]; avma = av; subfactorbase=cgetg(n+1,t_COL); for (j=1; j<=n; j++) subfactorbase[j] = vectbase[vperm[j]]; if (DEBUGLEVEL) { if (DEBUGLEVEL>3) { fprintferr("\n***** IDEALS IN FACTORBASE *****\n\n"); for (i=1; i<=KC; i++) fprintferr("no %ld = %Z\n",i,vectbase[i]); fprintferr("\n***** IDEALS IN SUB FACTORBASE *****\n\n"); outerr(subfactorbase); fprintferr("\n***** INITIAL PERMUTATION *****\n\n"); fprintferr("vperm = %Z\n\n",vperm); } msgtimer("subfactorbase (%ld elements)",n); } return ss;} |
avma = av; subfactorbase=cgetg(n+1,t_COL); | if (vperm) { for (j=1; j<=n; j++) vperm[j] = perm[j]; for ( ; j<lv; j++) vperm[j] = perm1[j]; } subfactorbase=cgetg(n+1,t_COL); for (j=1; j<=n; j++) subfactorbase[j] = vectbase[perm[j]]; | subfactorbasegen(long N,long m,long minsfb,GEN vperm){ long av=avma,i,j, lv=lg(vectbase),s=0,s1=0,n=0,ss=0,z=0; GEN y1,y2,perm,perm1,P,Q; double prod; y1 = cgetg(lv,t_COL); y2 = cgetg(lv,t_COL); for (i=1,P=(GEN)vectbase[i];;P=Q) { /* we'll sort ideals by norm (flag excluded ideals with "zero") */ long e = itos((GEN)P[3]); long ef= e*itos((GEN)P[4]); s1 += ef; y2[i] = (long)powgi((GEN)P[1],(GEN)P[4]); /* take only unramified ideals */ if (e>1) { y1[i]=zero; s=0; z++; } else { y1[i]=y2[i]; s += ef; } i++; Q = (GEN)vectbase[i]; if (i == lv || !egalii((GEN)P[1], (GEN)Q[1])) { /* don't take all P above a given p (delete the last one) */ if (s == N) { y1[i-1]=zero; z++; } if (s1== N) ss++; if (i == lv) break; s=0; s1=0; } } if (z+minsfb >= lv) return -1; prod = 1.0; perm = sindexsort(y1) + z; /* skip "zeroes" (excluded ideals) */ for(;;) { if (++n > minsfb && (z+n >= lv || prod > m + 0.5)) break; prod *= gtodouble((GEN)y1[perm[n]]); } if (prod < m) return -1; n--; /* take the first (wrt norm) n ideals, and put them first */ for (j=1; j<=n; j++) y2[perm[j]] = zero; perm1 = sindexsort(y2); for (j=1; j<=n; j++) vperm[j] = perm[j]; for ( ; j<lv; j++) vperm[j] = perm1[j]; avma = av; subfactorbase=cgetg(n+1,t_COL); for (j=1; j<=n; j++) subfactorbase[j] = vectbase[vperm[j]]; if (DEBUGLEVEL) { if (DEBUGLEVEL>3) { fprintferr("\n***** IDEALS IN FACTORBASE *****\n\n"); for (i=1; i<=KC; i++) fprintferr("no %ld = %Z\n",i,vectbase[i]); fprintferr("\n***** IDEALS IN SUB FACTORBASE *****\n\n"); outerr(subfactorbase); fprintferr("\n***** INITIAL PERMUTATION *****\n\n"); fprintferr("vperm = %Z\n\n",vperm); } msgtimer("subfactorbase (%ld elements)",n); } return ss;} |
for (j=1; j<=n; j++) subfactorbase[j] = vectbase[vperm[j]]; | subfactorbasegen(long N,long m,long minsfb,GEN vperm){ long av=avma,i,j, lv=lg(vectbase),s=0,s1=0,n=0,ss=0,z=0; GEN y1,y2,perm,perm1,P,Q; double prod; y1 = cgetg(lv,t_COL); y2 = cgetg(lv,t_COL); for (i=1,P=(GEN)vectbase[i];;P=Q) { /* we'll sort ideals by norm (flag excluded ideals with "zero") */ long e = itos((GEN)P[3]); long ef= e*itos((GEN)P[4]); s1 += ef; y2[i] = (long)powgi((GEN)P[1],(GEN)P[4]); /* take only unramified ideals */ if (e>1) { y1[i]=zero; s=0; z++; } else { y1[i]=y2[i]; s += ef; } i++; Q = (GEN)vectbase[i]; if (i == lv || !egalii((GEN)P[1], (GEN)Q[1])) { /* don't take all P above a given p (delete the last one) */ if (s == N) { y1[i-1]=zero; z++; } if (s1== N) ss++; if (i == lv) break; s=0; s1=0; } } if (z+minsfb >= lv) return -1; prod = 1.0; perm = sindexsort(y1) + z; /* skip "zeroes" (excluded ideals) */ for(;;) { if (++n > minsfb && (z+n >= lv || prod > m + 0.5)) break; prod *= gtodouble((GEN)y1[perm[n]]); } if (prod < m) return -1; n--; /* take the first (wrt norm) n ideals, and put them first */ for (j=1; j<=n; j++) y2[perm[j]] = zero; perm1 = sindexsort(y2); for (j=1; j<=n; j++) vperm[j] = perm[j]; for ( ; j<lv; j++) vperm[j] = perm1[j]; avma = av; subfactorbase=cgetg(n+1,t_COL); for (j=1; j<=n; j++) subfactorbase[j] = vectbase[vperm[j]]; if (DEBUGLEVEL) { if (DEBUGLEVEL>3) { fprintferr("\n***** IDEALS IN FACTORBASE *****\n\n"); for (i=1; i<=KC; i++) fprintferr("no %ld = %Z\n",i,vectbase[i]); fprintferr("\n***** IDEALS IN SUB FACTORBASE *****\n\n"); outerr(subfactorbase); fprintferr("\n***** INITIAL PERMUTATION *****\n\n"); fprintferr("vperm = %Z\n\n",vperm); } msgtimer("subfactorbase (%ld elements)",n); } return ss;} |
|
GEN M, basden, G2, u, u0 = NULL; | GEN ro, M, basden, G2, u, u0 = NULL; | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
if (!*polr) *polr = get_roots(x,r1,prec); | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
|
M = make_M(basden, *polr); | ro = get_roots(x,r1,prec); M = make_M(basden, ro); | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
if (typ(u) == t_MAT) return u0? gmul(u0,u): u; | if (typ(u) == t_MAT) break; | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
*polr = get_roots(x,r1, prec); | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
|
if (polr) *polr = ro; return u0? gmul(u0,u): u; | get_red_T2(GEN x, GEN *polr, GEN base, long r1, long prec){ GEN M, basden, G2, u, u0 = NULL; gpmem_t av; long i; basden = get_bas_den(base); av = avma; if (!*polr) *polr = get_roots(x,r1,prec); for (i=1; ; i++) { M = make_M(basden, *polr); G2 = make_Cholevsky_T2(M, r1, prec); if (u0) G2 = gmul(G2, u0); if ((u = lllfp_marked(1, G2, 100, 2, prec, 0))) { if (typ(u) == t_MAT) return u0? gmul(u0,u): u; u = (GEN)u[1]; if (u0) u0 = gerepileupto(av, gmul(u0,u)); else u0 = gerepilecopy(av, u); } if (i == MAXITERPOL) err(accurer,"red_T2"); prec = (prec<<1)-2; if (DEBUGLEVEL) err(warnprec,"red_T2",prec); *polr = get_roots(x,r1, prec); }} |
|
buchgenfu(GEN g1,GEN g2,GEN g3,GEN g4, GEN g5,long l1,long l2,long prec) { return buchall(g1,gtodouble(g2),gtodouble(g3),l1,nf_UNITS,prec); } | buchgenfu(B_ARGS) { return B_CALL(nf_UNITS); } | buchgenfu(GEN g1,GEN g2,GEN g3,GEN g4, GEN g5,long l1,long l2,long prec) { return buchall(g1,gtodouble(g2),gtodouble(g3),l1,nf_UNITS,prec);} |
long i,j,ind, n = min(lg(T2),9); | long i,j,ind, n = min(lg(T2)-1,9); | compute_vecT2(GEN nf,long prec){ GEN vecT2, M = gmael(nf,5,1), MC = gmael(nf,5,2), T2 = gmael(nf,5,3); long i,j,ind, n = min(lg(T2),9); vecT2=cgetg(1 + n*(n+1)/2,t_VEC); if (nfgetprec(nf) > prec) { M = gprec_w(M,prec); MC= gprec_w(MC,prec); T2= gprec_w(T2,prec); } for (ind=j=1; j<=n; j++) for (i=1; i<=j; i++) vecT2[ind++] = (long)shift_t2(T2,M,MC,i,j); if (DEBUGLEVEL) msgtimer("weighted T2 matrices"); return vecT2;} |
GEN csurn = gdivgs(c1, n), nsurc = ginv(csurn); GEN lncsurn = glog(csurn, prec2); | GEN csurn, nsurc, lncsurn; | GetST(GEN dataCR, long prec){ const long cl = lg(dataCR) - 1; ulong av, av1, av2; long ncond, n, j, k, jc, nmax, prec2, i0, r1, r2; GEN bnr, nf, racpi, powracpi; GEN rep, vChar, N0, C, T, S, an, degs, p1; if (DEBUGLEVEL) timer2(); /* allocate memory for answer */ rep = cgetg(3, t_VEC); S = cgetg(cl+1, t_VEC); rep[1] = (long)S; T = cgetg(cl+1, t_VEC); rep[2] = (long)T; for (j = 1; j <= cl; j++) { S[j] = (long)cgetc(prec); T[j] = (long)cgetc(prec); } av = avma; /* initializations */ degs = GetDeg(dataCR); vChar= sortChars(dataCR,0); ncond = lg(vChar)-1; bnr = gmael(dataCR,1,4); nf = checknf(bnr); nf_get_sign(nf,&r1,&r2); C = cgetg(ncond+1, t_VEC); N0 = cgetg(ncond+1, t_VECSMALL); nmax = 0; for (j = 1; j <= ncond; j++) { C[j] = mael(dataCR, mael(vChar,j,1), 2); N0[j] = GetBoundN0((GEN)C[j], r1, r2, prec); if (nmax < N0[j]) nmax = N0[j]; } if ((ulong)nmax > maxprime()) err(talker, "Not enough precomputed primes (need all p <= %ld)", nmax); i0 = GetBoundi0(r1, r2, prec); if (DEBUGLEVEL>1) fprintferr("nmax = %ld, i0 = %ld\n", nmax, i0); prec2 = ((prec-2) << 1) + EXTRA_PREC; racpi = mpsqrt(mppi(prec2)); powracpi = cgetg(r1+2,t_VEC); powracpi++; powracpi[0] = un; powracpi[1] = (long)racpi; for (j=2; j<=r1; j++) powracpi[j] = lmulrr((GEN)powracpi[j-1], racpi); av1 = avma; for (jc = 1; jc <= ncond; jc++) { const GEN c1 = (GEN)C[jc]; const GEN LChar = (GEN)vChar[jc]; const long nChar = lg(LChar)-1, NN = N0[jc]; long i,a,b,c,rc1,rc2,r; GEN Z, cS, cT, *aij,*bij; int **matan = NULL; if (DEBUGLEVEL>1) fprintferr("* conductor no %ld/%ld (N = %ld)\n Init:", jc,ncond,NN); if (nChar == 1) { /* quadratic or trivial char, precompute for early abort later */ const long t = LChar[1], d = degs[t]; matan = ComputeCoeff((GEN)dataCR[t], NN, d, prec); } p1 = gmael(dataCR, LChar[1], 9); a = p1[1]; b = p1[2]; c = p1[3]; rc1 = a+c; rc2 = b+c; r = max(rc2+1, rc1); /* >= 2 */ ppgamma(&aij, &bij, a, b, c, i0, prec2); cS = cgetg(NN+1, t_VEC); cT = cgetg(NN+1, t_VEC); Z = cgetg(r+1, t_VEC); Z[1] = un; av2 = avma; for (n = 1; n <= NN; n++) { GEN csurn = gdivgs(c1, n), nsurc = ginv(csurn); GEN lncsurn = glog(csurn, prec2); GEN A,B,s,t, *gptr[2]; if (DEBUGLEVEL>1 && n%100 == 0) fprintferr(" %ld", n); if (matan && IsZero(matan[n], degs[LChar[1]])) continue; Z[2] = (long)lncsurn; /* r >= 2 */ for (i = 3; i <= r; i++) { s = gmul((GEN)Z[i-1], lncsurn); Z[i] = ldivgs(s, i-1); /* Z[i] = ln^(i-1)(c1/n) / (i-1)! */ } /* i = i0 */ A = aij[i0]; t = (GEN)A[1]; B = bij[i0]; s = (GEN)B[1]; for (j = 2; j <= r; j++) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } for (i = i0 - 1; i > 1; i--) { A = aij[i]; t = gmul(t, nsurc); B = bij[i]; s = gmul(s, nsurc); for (j = odd(i)? rc2: rc1; j; j--) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } } /* i = 1 */ A = aij[1]; t = gmul(t, nsurc); B = bij[1]; s = gmul(s, nsurc); for (j = 1; j <= r; j++) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } s = gadd(s, gmul(csurn, (GEN)powracpi[b])); gptr[0] = &s; gptr[1] = &t; gerepilemany(av2, gptr, 2); cS[n] = (long)s; cT[n] = (long)t; av2 = avma; } for (k = 1; k <= nChar; k++) { const long t = LChar[k], d = degs[t]; const GEN z = gmael3(dataCR, t, 5, 2); GEN p1 = gzero, p2 = gzero; if (DEBUGLEVEL>1) fprintferr("\n character no: %ld/%ld\n", t,k); if (!matan) matan = ComputeCoeff((GEN)dataCR[t], NN, d, prec); for (n = 1; n <= NN; n++) if ((an = EvalCoeff(z, matan[n], d))) { p1 = gadd(p1, gmul(an, (GEN)cS[n])); p2 = gadd(p2, gmul(gconj(an), (GEN)cT[n])); } gaffect(p1, (GEN)S[t]); gaffect(p2, (GEN)T[t]); FreeMat(matan, NN); avma = av2; } if (DEBUGLEVEL>1) fprintferr("\n"); avma = av1; } if (DEBUGLEVEL) msgtimer("S&T"); avma = av; return rep;} |
FreeMat(matan, NN); avma = av2; | FreeMat(matan, NN); matan = NULL; avma = av2; | GetST(GEN dataCR, long prec){ const long cl = lg(dataCR) - 1; ulong av, av1, av2; long ncond, n, j, k, jc, nmax, prec2, i0, r1, r2; GEN bnr, nf, racpi, powracpi; GEN rep, vChar, N0, C, T, S, an, degs, p1; if (DEBUGLEVEL) timer2(); /* allocate memory for answer */ rep = cgetg(3, t_VEC); S = cgetg(cl+1, t_VEC); rep[1] = (long)S; T = cgetg(cl+1, t_VEC); rep[2] = (long)T; for (j = 1; j <= cl; j++) { S[j] = (long)cgetc(prec); T[j] = (long)cgetc(prec); } av = avma; /* initializations */ degs = GetDeg(dataCR); vChar= sortChars(dataCR,0); ncond = lg(vChar)-1; bnr = gmael(dataCR,1,4); nf = checknf(bnr); nf_get_sign(nf,&r1,&r2); C = cgetg(ncond+1, t_VEC); N0 = cgetg(ncond+1, t_VECSMALL); nmax = 0; for (j = 1; j <= ncond; j++) { C[j] = mael(dataCR, mael(vChar,j,1), 2); N0[j] = GetBoundN0((GEN)C[j], r1, r2, prec); if (nmax < N0[j]) nmax = N0[j]; } if ((ulong)nmax > maxprime()) err(talker, "Not enough precomputed primes (need all p <= %ld)", nmax); i0 = GetBoundi0(r1, r2, prec); if (DEBUGLEVEL>1) fprintferr("nmax = %ld, i0 = %ld\n", nmax, i0); prec2 = ((prec-2) << 1) + EXTRA_PREC; racpi = mpsqrt(mppi(prec2)); powracpi = cgetg(r1+2,t_VEC); powracpi++; powracpi[0] = un; powracpi[1] = (long)racpi; for (j=2; j<=r1; j++) powracpi[j] = lmulrr((GEN)powracpi[j-1], racpi); av1 = avma; for (jc = 1; jc <= ncond; jc++) { const GEN c1 = (GEN)C[jc]; const GEN LChar = (GEN)vChar[jc]; const long nChar = lg(LChar)-1, NN = N0[jc]; long i,a,b,c,rc1,rc2,r; GEN Z, cS, cT, *aij,*bij; int **matan = NULL; if (DEBUGLEVEL>1) fprintferr("* conductor no %ld/%ld (N = %ld)\n Init:", jc,ncond,NN); if (nChar == 1) { /* quadratic or trivial char, precompute for early abort later */ const long t = LChar[1], d = degs[t]; matan = ComputeCoeff((GEN)dataCR[t], NN, d, prec); } p1 = gmael(dataCR, LChar[1], 9); a = p1[1]; b = p1[2]; c = p1[3]; rc1 = a+c; rc2 = b+c; r = max(rc2+1, rc1); /* >= 2 */ ppgamma(&aij, &bij, a, b, c, i0, prec2); cS = cgetg(NN+1, t_VEC); cT = cgetg(NN+1, t_VEC); Z = cgetg(r+1, t_VEC); Z[1] = un; av2 = avma; for (n = 1; n <= NN; n++) { GEN csurn = gdivgs(c1, n), nsurc = ginv(csurn); GEN lncsurn = glog(csurn, prec2); GEN A,B,s,t, *gptr[2]; if (DEBUGLEVEL>1 && n%100 == 0) fprintferr(" %ld", n); if (matan && IsZero(matan[n], degs[LChar[1]])) continue; Z[2] = (long)lncsurn; /* r >= 2 */ for (i = 3; i <= r; i++) { s = gmul((GEN)Z[i-1], lncsurn); Z[i] = ldivgs(s, i-1); /* Z[i] = ln^(i-1)(c1/n) / (i-1)! */ } /* i = i0 */ A = aij[i0]; t = (GEN)A[1]; B = bij[i0]; s = (GEN)B[1]; for (j = 2; j <= r; j++) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } for (i = i0 - 1; i > 1; i--) { A = aij[i]; t = gmul(t, nsurc); B = bij[i]; s = gmul(s, nsurc); for (j = odd(i)? rc2: rc1; j; j--) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } } /* i = 1 */ A = aij[1]; t = gmul(t, nsurc); B = bij[1]; s = gmul(s, nsurc); for (j = 1; j <= r; j++) { s = gadd(s, gmul((GEN)Z[j], (GEN)B[j])); t = gadd(t, gmul((GEN)Z[j], (GEN)A[j])); } s = gadd(s, gmul(csurn, (GEN)powracpi[b])); gptr[0] = &s; gptr[1] = &t; gerepilemany(av2, gptr, 2); cS[n] = (long)s; cT[n] = (long)t; av2 = avma; } for (k = 1; k <= nChar; k++) { const long t = LChar[k], d = degs[t]; const GEN z = gmael3(dataCR, t, 5, 2); GEN p1 = gzero, p2 = gzero; if (DEBUGLEVEL>1) fprintferr("\n character no: %ld/%ld\n", t,k); if (!matan) matan = ComputeCoeff((GEN)dataCR[t], NN, d, prec); for (n = 1; n <= NN; n++) if ((an = EvalCoeff(z, matan[n], d))) { p1 = gadd(p1, gmul(an, (GEN)cS[n])); p2 = gadd(p2, gmul(gconj(an), (GEN)cT[n])); } gaffect(p1, (GEN)S[t]); gaffect(p2, (GEN)T[t]); FreeMat(matan, NN); avma = av2; } if (DEBUGLEVEL>1) fprintferr("\n"); avma = av1; } if (DEBUGLEVEL) msgtimer("S&T"); avma = av; return rep;} |
rtems_unsigned32 *inttab = (rtems_unsigned32 *)&INTERRUPT_VECTOR; rtems_unsigned32 *intvec = (rtems_unsigned32 *)BSP_MEM_ADDR_ESRAM; | uint32_t *inttab = (uint32_t*)&INTERRUPT_VECTOR; uint32_t *intvec = (uint32_t*)BSP_MEM_ADDR_ESRAM; | Init5206e(void){ extern void CopyDataClearBSSAndStart(unsigned long ramsize); /* Set Module Base Address register */ m68k_set_mbar((MBAR & MCF5206E_MBAR_BA) | MCF5206E_MBAR_V); /* Set System Protection Control Register (SYPCR): * Bus Monitor Enable, Bus Monitor Timing = 1024 clocks, * Software watchdog disabled */ *MCF5206E_SYPCR(MBAR) = MCF5206E_SYPCR_BME | MCF5206E_SYPCR_BMT_1024; /* Set Pin Assignment Register (PAR): * Output Timer 0 (not DREQ) on *TOUT[0] / *DREQ[1] * Input Timer 0 (not DREQ) on *TIN[0] / *DREQ[0] * IRQ, not IPL * UART2 RTS signal (not \RSTO) * PST/DDATA (not PPIO) * *WE (not CS/A) */ *MCF5206E_PAR(MBAR) = MCF5206E_PAR_PAR9_TOUT | MCF5206E_PAR_PAR8_TIN0 | MCF5206E_PAR_PAR7_UART2 | MCF5206E_PAR_PAR6_IRQ | MCF5206E_PAR_PAR5_PST | MCF5206E_PAR_PAR4_DDATA | MCF5206E_PAR_WE0_WE1_WE2_WE3; /* Set SIM Configuration Register (SIMR): * Disable software watchdog timer and bus timeout monitor when * internal freeze signal is asserted. */ *MCF5206E_SIMR(MBAR) = MCF5206E_SIMR_FRZ0 | MCF5206E_SIMR_FRZ1; /* Set Interrupt Mask Register: Disable all interrupts */ *MCF5206E_IMR(MBAR) = 0xFFFF; /* Assign Interrupt Control Registers as it is defined in bsp.h */ *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL1) = (BSP_INTLVL_AVEC1 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC1 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL2) = (BSP_INTLVL_AVEC2 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC2 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL3) = (BSP_INTLVL_AVEC3 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC3 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL4) = (BSP_INTLVL_AVEC4 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC4 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL5) = (BSP_INTLVL_AVEC5 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC5 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL6) = (BSP_INTLVL_AVEC6 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC6 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL7) = (BSP_INTLVL_AVEC7 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_AVEC7 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) = (BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_2) = (BSP_INTLVL_TIMER2 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_TIMER2 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_MBUS) = (BSP_INTLVL_MBUS << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_MBUS << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_1) = (BSP_INTLVL_UART1 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_UART1 << MCF5206E_ICR_IP_S); *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_2) = (BSP_INTLVL_UART2 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_UART2 << MCF5206E_ICR_IP_S); *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_0) = (BSP_INTLVL_DMA0 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_DMA0 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_1) = (BSP_INTLVL_DMA1 << MCF5206E_ICR_IL_S) | (BSP_INTPRIO_DMA1 << MCF5206E_ICR_IP_S) | MCF5206E_ICR_AVEC; /* Software Watchdog timer (not used now) */ *MCF5206E_SWIVR(MBAR) = 0x0F; /* Uninitialized interrupt */ *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY1; *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY2; /* Configuring Chip Selects */ /* CS2: SRAM memory */ *MCF5206E_CSAR(MBAR,2) = BSP_MEM_ADDR_ESRAM >> 16; *MCF5206E_CSMR(MBAR,2) = BSP_MEM_MASK_ESRAM; *MCF5206E_CSCR(MBAR,2) = MCF5206E_CSCR_WS1 | MCF5206E_CSCR_PS_32 | MCF5206E_CSCR_AA | MCF5206E_CSCR_EMAA | MCF5206E_CSCR_WR | MCF5206E_CSCR_RD; /* CS3: GPIO on eLITE board */ *MCF5206E_CSAR(MBAR,3) = BSP_MEM_ADDR_GPIO >> 16; *MCF5206E_CSMR(MBAR,3) = BSP_MEM_MASK_GPIO; *MCF5206E_CSCR(MBAR,3) = MCF5206E_CSCR_WS15 | MCF5206E_CSCR_PS_16 | MCF5206E_CSCR_AA | MCF5206E_CSCR_EMAA | MCF5206E_CSCR_WR | MCF5206E_CSCR_RD; { extern void INTERRUPT_VECTOR(); rtems_unsigned32 *inttab = (rtems_unsigned32 *)&INTERRUPT_VECTOR; rtems_unsigned32 *intvec = (rtems_unsigned32 *)BSP_MEM_ADDR_ESRAM; register int i; for (i = 0; i < 256; i++) { *(intvec++) = *(inttab++); } } m68k_set_vbr(BSP_MEM_ADDR_ESRAM); /* CS0: Flash EEPROM */ *MCF5206E_CSAR(MBAR,0) = BSP_MEM_ADDR_FLASH >> 16; *MCF5206E_CSCR(MBAR,0) = MCF5206E_CSCR_WS3 | MCF5206E_CSCR_AA | MCF5206E_CSCR_PS_16 | MCF5206E_CSCR_EMAA | MCF5206E_CSCR_WR | MCF5206E_CSCR_RD; *MCF5206E_CSMR(MBAR,0) = BSP_MEM_MASK_FLASH; /* * Invalidate the cache and disable it */ mcf5206e_disable_cache(); /* * Setup ACRs so that if cache turned on, periphal accesses * are not messed up. (Non-cacheable, serialized) */ m68k_set_acr0 ( 0 | MCF5206E_ACR_BASE(BSP_MEM_ADDR_ESRAM) | MCF5206E_ACR_MASK(BSP_MEM_MASK_ESRAM) | MCF5206E_ACR_EN | MCF5206E_ACR_SM_ANY ); m68k_set_acr1 ( 0 | MCF5206E_ACR_BASE(BSP_MEM_ADDR_FLASH) | MCF5206E_ACR_MASK(BSP_MEM_MASK_FLASH) | MCF5206E_ACR_EN | MCF5206E_ACR_SM_ANY ); mcf5206e_enable_cache(); /* * Copy data, clear BSS, switch stacks and call boot_card() */ CopyDataClearBSSAndStart (BSP_MEM_SIZE_ESRAM - 0x400);} |
D = diagonal(smith(hnf(MrC))); MQ = concatsp(gmul(H, D), DA); | (void)smithall(hnf(MrC), &U, NULL); MQ = concatsp(gmul(H, U), DA); | InitQuotient0(GEN DA, GEN C){ GEN D, MQ, MrC, H, U, rep; H = gcmp0(C)? DA: C; MrC = gauss(H, DA); D = diagonal(smith(hnf(MrC))); MQ = concatsp(gmul(H, D), DA); D = smithall(hnf(MQ), &U, NULL); rep = cgetg(5, t_VEC); rep[1] = (long)dethnf_i(D); rep[2] = (long)mattodiagonal(D); rep[3] = lcopy(U); rep[4] = lcopy(C); return rep;} |
for (i = 1; i < nb; i++) | setlg(subgrp, nb); for (i = 1; i < nb; i++) | ComputeIndex2Subgroup(GEN bnr, GEN C){ ulong av = avma; long nb, i; GEN D, Mr, U, T, subgrp; disable_dbg(0); Mr = diagonal(gmael(bnr, 5, 2)); D = smithall(gauss(C, Mr), &U, NULL); T = gmul(C,ginv(U)); subgrp = subgrouplist(D, gdeux); nb = lg(subgrp) - 1; for (i = 1; i < nb; i++) /* skip Id which comes last */ subgrp[i] = (long)hnf(concatsp(gmul(T, (GEN)subgrp[i]), Mr)); disable_dbg(-1); return gerepilecopy(av, subgrp);} |
b = centermod(b, gcoeff(x,1,1)); | ideal_two_elt2(GEN nf, GEN x, GEN a){ pari_sp av = avma; GEN cx, b; nf = checknf(nf); a = _algtobasis(nf, a); x = idealhermite_aux(nf,x); if (gcmp0(x)) { if (!gcmp0(a)) err(talker,"element not in ideal in ideal_two_elt2"); avma = av; return gcopy(a); } x = Q_primitive_part(x, &cx); if (cx) a = gdiv(a, cx); if (!hnf_invimage(x, a)) err(talker,"element does not belong to ideal in ideal_two_elt2"); b = mat_ideal_two_elt2(nf, x, a); b = cx? gmul(b,cx): gcopy(b); return gerepileupto(av, b);} |
|
long av=avma,tetpil,i,j,k,n,N, vpol = varn(pol); | ulong av = avma; long i,j,k,n,N, vpol = varn(pol); | rnfpolred(GEN nf, GEN pol, long prec){ long av=avma,tetpil,i,j,k,n,N, vpol = varn(pol); GEN id,id2,newid,newor,p1,p2,al,newpol,w,z; GEN bnf,zk,newideals,ideals,order,neworder; if (typ(pol)!=t_POL) err(typeer,"rnfpolred"); if (typ(nf)!=t_VEC) err(idealer1); switch(lg(nf)) { case 10: bnf = NULL; break; case 11: bnf = nf; nf = checknf((GEN)nf[7]); break; default: err(idealer1); return NULL; /* not reached */ } if (degpol(pol) <= 1) { w=cgetg(2,t_VEC); w[1]=lpolx[vpol]; return w; } id=rnfpseudobasis(nf,pol); N=degpol(nf[1]); if (bnf && gcmp1(gmael3(bnf,8,1,1))) /* if bnf is principal */ { ideals=(GEN)id[2]; n=lg(ideals)-1; order=(GEN)id[1]; newideals=cgetg(n+1,t_VEC); neworder=cgetg(n+1,t_MAT); zk=idmat(N); for (j=1; j<=n; j++) { newideals[j]=(long)zk; p1=cgetg(n+1,t_COL); neworder[j]=(long)p1; p2=(GEN)order[j]; al=(GEN)isprincipalgen(bnf,(GEN)ideals[j])[2]; for (k=1; k<=n; k++) p1[k]=(long)element_mul(nf,(GEN)p2[k],al); } id=cgetg(3,t_VEC); id[1]=(long)neworder; id[2]=(long)newideals; } id2=rnflllgram(nf,pol,id,prec); z=(GEN)id2[1]; newid=(GEN)z[2]; newor=(GEN)z[1]; n=lg(newor)-1; w=cgetg(n+1,t_VEC); for (j=1; j<=n; j++) { p1=(GEN)newid[j]; al=gmul(gcoeff(p1,1,1),(GEN)newor[j]); p1=basistoalg(nf,(GEN)al[n]); for (i=n-1; i; i--) p1=gadd(basistoalg(nf,(GEN)al[i]),gmul(polx[vpol],p1)); newpol=gtopoly(gmodulcp(gtovec(caract2(lift(pol),lift(p1),vpol)), (GEN) nf[1]), vpol); p1 = ggcd(newpol, derivpol(newpol)); if (degpol(p1)>0) { newpol=gdiv(newpol,p1); newpol=gdiv(newpol,leading_term(newpol)); } w[j]=(long)newpol; if (DEBUGLEVEL>=4) outerr(newpol); } tetpil=avma; return gerepile(av,tetpil,gcopy(w));} |
tetpil=avma; return gerepile(av,tetpil,gcopy(w)); | return gerepilecopy(av,w); | rnfpolred(GEN nf, GEN pol, long prec){ long av=avma,tetpil,i,j,k,n,N, vpol = varn(pol); GEN id,id2,newid,newor,p1,p2,al,newpol,w,z; GEN bnf,zk,newideals,ideals,order,neworder; if (typ(pol)!=t_POL) err(typeer,"rnfpolred"); if (typ(nf)!=t_VEC) err(idealer1); switch(lg(nf)) { case 10: bnf = NULL; break; case 11: bnf = nf; nf = checknf((GEN)nf[7]); break; default: err(idealer1); return NULL; /* not reached */ } if (degpol(pol) <= 1) { w=cgetg(2,t_VEC); w[1]=lpolx[vpol]; return w; } id=rnfpseudobasis(nf,pol); N=degpol(nf[1]); if (bnf && gcmp1(gmael3(bnf,8,1,1))) /* if bnf is principal */ { ideals=(GEN)id[2]; n=lg(ideals)-1; order=(GEN)id[1]; newideals=cgetg(n+1,t_VEC); neworder=cgetg(n+1,t_MAT); zk=idmat(N); for (j=1; j<=n; j++) { newideals[j]=(long)zk; p1=cgetg(n+1,t_COL); neworder[j]=(long)p1; p2=(GEN)order[j]; al=(GEN)isprincipalgen(bnf,(GEN)ideals[j])[2]; for (k=1; k<=n; k++) p1[k]=(long)element_mul(nf,(GEN)p2[k],al); } id=cgetg(3,t_VEC); id[1]=(long)neworder; id[2]=(long)newideals; } id2=rnflllgram(nf,pol,id,prec); z=(GEN)id2[1]; newid=(GEN)z[2]; newor=(GEN)z[1]; n=lg(newor)-1; w=cgetg(n+1,t_VEC); for (j=1; j<=n; j++) { p1=(GEN)newid[j]; al=gmul(gcoeff(p1,1,1),(GEN)newor[j]); p1=basistoalg(nf,(GEN)al[n]); for (i=n-1; i; i--) p1=gadd(basistoalg(nf,(GEN)al[i]),gmul(polx[vpol],p1)); newpol=gtopoly(gmodulcp(gtovec(caract2(lift(pol),lift(p1),vpol)), (GEN) nf[1]), vpol); p1 = ggcd(newpol, derivpol(newpol)); if (degpol(p1)>0) { newpol=gdiv(newpol,p1); newpol=gdiv(newpol,leading_term(newpol)); } w[j]=(long)newpol; if (DEBUGLEVEL>=4) outerr(newpol); } tetpil=avma; return gerepile(av,tetpil,gcopy(w));} |
isatty (int fd) | int isatty( int fd ) | isatty (int fd){ struct stat buf; if (fstat (fd, &buf) < 0) return 0; if (S_ISCHR (buf.st_mode)) return 1; return 0;} |
y = cgetr(l); av = avma; t = exp1r_abs(gmul2n(x,1)); affrr(divrr(t, addsr(2,t)), y); avma = av; | av = avma; t = exp1r_abs(gmul2n(x,1)); return gerepileuptoleaf(av, divrr(t, addsr(2,t))); | mpth(GEN x){ long l, s = signe(x); pari_sp av; GEN y, t; if (!s) return realzero_bit(expo(x)); l = lg(x); if (cmprs(x, bit_accuracy(l)) >= 0) { y = realun(l); } else { y = cgetr(l); av = avma; t = exp1r_abs(gmul2n(x,1)); /* exp(|2x|) - 1 */ affrr(divrr(t, addsr(2,t)), y); avma = av; } if (s < 0) setsigne(y, -signe(y)); /* tanh is odd */ return y;} |
if (l > 0) | la = 3.; if (st > 1 && l > 0) | gammanew(GEN s0, int dolog, long prec){ GEN s, u, a, y, res, tes, sig, invn2, p1, nnx, pi, sqrtpi2; long i, lim, nn; pari_sp av, av2, avlim; int funeq = 0; if (DEBUGLEVEL) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (signe(sig) <= 0 || expo(sig) < -1) { if (typ(s) == t_COMPLEX && gexpo((GEN)s[2]) <= 16) funeq = 1; } /* s <--> 1-s */ if (funeq) { s = gsub(gun, s); sig = greal(s); } { /* find "optimal" parameters [lim, nn] */ double ssig = rtodbl(sig); double st = rtodbl(gimag(s)); double la, l,l2,u,v, rlogs, ilogs; dcxlog(ssig,st, &rlogs,&ilogs); /* Re (s - 1/2) log(s) */ u = (ssig - 0.5)*rlogs - st * ilogs; /* Im (s - 1/2) log(s) */ v = (ssig - 0.5)*ilogs + st * rlogs; /* l2 = | (s - 1/2) log(s) - s + log(2Pi)/2 |^2 ~ |lngamma(s))|^2 */ u = u - ssig + log(2.*PI)/2; v = v - st; l2 = u*u + v*v; if (l2 < 0.000001) l2 = 0.000001; l = (pariC2*(prec-2) - log(l2)/2) / 2.; if (l < 0) l = 0.; if (l > 0) { double t = st * PI / l; la = t * log(t); if (la < 3) la = 3.; /* FIXME: heuristic... */ } else la = 3.; /* FIXME: heuristic... */ lim = (long)ceil(l / (1.+ log(la))); if (lim == 0) lim = 1; u = (lim-0.5) * la / PI; l2 = u*u - st*st; if (l2 > 0) { nn = (long)ceil(sqrt(l2) - ssig); if (nn < 1) nn = 1; } else nn = 1; if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld], la = %lf\n",lim,nn,la);#if 0 {/* same: old method */ long e = gexpo(s); double beta; if (e > 1000) { nn = 0; beta = log(pariK4 / (prec-2)) / LOG2 + e; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } else { double alpha = sqrt( dnorm(ssig, st) ); beta = ((bit_accuracy(prec)>>1) * LOG2 / PI) - alpha; if (beta >= 0) nn = (long)(1+pariK2*beta); else nn = 0; if (nn) lim = (long)(1+PI*(alpha+nn)); else { beta = log( pariK4 * alpha / (prec-2) ) / LOG2; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } } nn++; } if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld]\n",lim,nn);#endif } prec++; av2 = avma; avlim = stack_lim(av2,3); y = s; if (typ(s0) == t_INT) { long ss; if (expi(s0) > 20) err(talker, "exponent too large in gamma"); ss = itos(s0); for (i=1; i < nn; i++) { y = mulrs(y, ss + i); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileuptoleaf(av2, y); } } } else for (i=1; i < nn; i++) { y = gmul(y, gaddgs(s,i)); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileupto(av2, y); } } nnx = gaddgs(s, nn); if (DEBUGLEVEL) msgtimer("product from 0 to N-1"); a = ginv(nnx); invn2 = gsqr(a); tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/ if (DEBUGLEVEL) msgtimer("Bernoullis"); for (i = 2*lim-2; i > 1; i -= 2) { u = divrs2_safe(bernreal(i,prec), i-1); /* Bi / i(i-1) */ tes = gadd(u, gmul(invn2,tes)); } if (DEBUGLEVEL) msgtimer("Bernoulli sum"); p1 = gsub(gmul(gsub(nnx, ghalf), glog(nnx,prec)), nnx); p1 = gadd(p1, gmul(tes, a)); pi = mppi(prec); sqrtpi2 = mpsqrt( gmul2n(pi, 1) ); if (funeq) { /* y --> y Pi/(sin(Pi s) * sqrt(2Pi)) */ y = gdiv(gmul(pi,y), gmul(sqrtpi2, gsin(gmul(s,pi), prec))); p1 = gneg(p1); } else /* y --> sqrt(2Pi) / y */ y = gdiv(sqrtpi2, y); if (dolog) { y = gadd(p1, glog(y, prec)); y[2] = (long)red_mod_2z((GEN)y[2], pi); } else y = gmul(gexp(p1, prec), y); gaffect(y, res); avma = av; return res;} |
else la = 3.; | gammanew(GEN s0, int dolog, long prec){ GEN s, u, a, y, res, tes, sig, invn2, p1, nnx, pi, sqrtpi2; long i, lim, nn; pari_sp av, av2, avlim; int funeq = 0; if (DEBUGLEVEL) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (signe(sig) <= 0 || expo(sig) < -1) { if (typ(s) == t_COMPLEX && gexpo((GEN)s[2]) <= 16) funeq = 1; } /* s <--> 1-s */ if (funeq) { s = gsub(gun, s); sig = greal(s); } { /* find "optimal" parameters [lim, nn] */ double ssig = rtodbl(sig); double st = rtodbl(gimag(s)); double la, l,l2,u,v, rlogs, ilogs; dcxlog(ssig,st, &rlogs,&ilogs); /* Re (s - 1/2) log(s) */ u = (ssig - 0.5)*rlogs - st * ilogs; /* Im (s - 1/2) log(s) */ v = (ssig - 0.5)*ilogs + st * rlogs; /* l2 = | (s - 1/2) log(s) - s + log(2Pi)/2 |^2 ~ |lngamma(s))|^2 */ u = u - ssig + log(2.*PI)/2; v = v - st; l2 = u*u + v*v; if (l2 < 0.000001) l2 = 0.000001; l = (pariC2*(prec-2) - log(l2)/2) / 2.; if (l < 0) l = 0.; if (l > 0) { double t = st * PI / l; la = t * log(t); if (la < 3) la = 3.; /* FIXME: heuristic... */ } else la = 3.; /* FIXME: heuristic... */ lim = (long)ceil(l / (1.+ log(la))); if (lim == 0) lim = 1; u = (lim-0.5) * la / PI; l2 = u*u - st*st; if (l2 > 0) { nn = (long)ceil(sqrt(l2) - ssig); if (nn < 1) nn = 1; } else nn = 1; if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld], la = %lf\n",lim,nn,la);#if 0 {/* same: old method */ long e = gexpo(s); double beta; if (e > 1000) { nn = 0; beta = log(pariK4 / (prec-2)) / LOG2 + e; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } else { double alpha = sqrt( dnorm(ssig, st) ); beta = ((bit_accuracy(prec)>>1) * LOG2 / PI) - alpha; if (beta >= 0) nn = (long)(1+pariK2*beta); else nn = 0; if (nn) lim = (long)(1+PI*(alpha+nn)); else { beta = log( pariK4 * alpha / (prec-2) ) / LOG2; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } } nn++; } if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld]\n",lim,nn);#endif } prec++; av2 = avma; avlim = stack_lim(av2,3); y = s; if (typ(s0) == t_INT) { long ss; if (expi(s0) > 20) err(talker, "exponent too large in gamma"); ss = itos(s0); for (i=1; i < nn; i++) { y = mulrs(y, ss + i); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileuptoleaf(av2, y); } } } else for (i=1; i < nn; i++) { y = gmul(y, gaddgs(s,i)); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileupto(av2, y); } } nnx = gaddgs(s, nn); if (DEBUGLEVEL) msgtimer("product from 0 to N-1"); a = ginv(nnx); invn2 = gsqr(a); tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/ if (DEBUGLEVEL) msgtimer("Bernoullis"); for (i = 2*lim-2; i > 1; i -= 2) { u = divrs2_safe(bernreal(i,prec), i-1); /* Bi / i(i-1) */ tes = gadd(u, gmul(invn2,tes)); } if (DEBUGLEVEL) msgtimer("Bernoulli sum"); p1 = gsub(gmul(gsub(nnx, ghalf), glog(nnx,prec)), nnx); p1 = gadd(p1, gmul(tes, a)); pi = mppi(prec); sqrtpi2 = mpsqrt( gmul2n(pi, 1) ); if (funeq) { /* y --> y Pi/(sin(Pi s) * sqrt(2Pi)) */ y = gdiv(gmul(pi,y), gmul(sqrtpi2, gsin(gmul(s,pi), prec))); p1 = gneg(p1); } else /* y --> sqrt(2Pi) / y */ y = gdiv(sqrtpi2, y); if (dolog) { y = gadd(p1, glog(y, prec)); y[2] = (long)red_mod_2z((GEN)y[2], pi); } else y = gmul(gexp(p1, prec), y); gaffect(y, res); avma = av; return res;} |
|
tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); | tes = divrsns(bernreal(2*lim,prec), 2*lim-1); | gammanew(GEN s0, int dolog, long prec){ GEN s, u, a, y, res, tes, sig, invn2, p1, nnx, pi, sqrtpi2; long i, lim, nn; pari_sp av, av2, avlim; int funeq = 0; if (DEBUGLEVEL) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (signe(sig) <= 0 || expo(sig) < -1) { if (typ(s) == t_COMPLEX && gexpo((GEN)s[2]) <= 16) funeq = 1; } /* s <--> 1-s */ if (funeq) { s = gsub(gun, s); sig = greal(s); } { /* find "optimal" parameters [lim, nn] */ double ssig = rtodbl(sig); double st = rtodbl(gimag(s)); double la, l,l2,u,v, rlogs, ilogs; dcxlog(ssig,st, &rlogs,&ilogs); /* Re (s - 1/2) log(s) */ u = (ssig - 0.5)*rlogs - st * ilogs; /* Im (s - 1/2) log(s) */ v = (ssig - 0.5)*ilogs + st * rlogs; /* l2 = | (s - 1/2) log(s) - s + log(2Pi)/2 |^2 ~ |lngamma(s))|^2 */ u = u - ssig + log(2.*PI)/2; v = v - st; l2 = u*u + v*v; if (l2 < 0.000001) l2 = 0.000001; l = (pariC2*(prec-2) - log(l2)/2) / 2.; if (l < 0) l = 0.; if (l > 0) { double t = st * PI / l; la = t * log(t); if (la < 3) la = 3.; /* FIXME: heuristic... */ } else la = 3.; /* FIXME: heuristic... */ lim = (long)ceil(l / (1.+ log(la))); if (lim == 0) lim = 1; u = (lim-0.5) * la / PI; l2 = u*u - st*st; if (l2 > 0) { nn = (long)ceil(sqrt(l2) - ssig); if (nn < 1) nn = 1; } else nn = 1; if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld], la = %lf\n",lim,nn,la);#if 0 {/* same: old method */ long e = gexpo(s); double beta; if (e > 1000) { nn = 0; beta = log(pariK4 / (prec-2)) / LOG2 + e; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } else { double alpha = sqrt( dnorm(ssig, st) ); beta = ((bit_accuracy(prec)>>1) * LOG2 / PI) - alpha; if (beta >= 0) nn = (long)(1+pariK2*beta); else nn = 0; if (nn) lim = (long)(1+PI*(alpha+nn)); else { beta = log( pariK4 * alpha / (prec-2) ) / LOG2; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } } nn++; } if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld]\n",lim,nn);#endif } prec++; av2 = avma; avlim = stack_lim(av2,3); y = s; if (typ(s0) == t_INT) { long ss; if (expi(s0) > 20) err(talker, "exponent too large in gamma"); ss = itos(s0); for (i=1; i < nn; i++) { y = mulrs(y, ss + i); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileuptoleaf(av2, y); } } } else for (i=1; i < nn; i++) { y = gmul(y, gaddgs(s,i)); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileupto(av2, y); } } nnx = gaddgs(s, nn); if (DEBUGLEVEL) msgtimer("product from 0 to N-1"); a = ginv(nnx); invn2 = gsqr(a); tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/ if (DEBUGLEVEL) msgtimer("Bernoullis"); for (i = 2*lim-2; i > 1; i -= 2) { u = divrs2_safe(bernreal(i,prec), i-1); /* Bi / i(i-1) */ tes = gadd(u, gmul(invn2,tes)); } if (DEBUGLEVEL) msgtimer("Bernoulli sum"); p1 = gsub(gmul(gsub(nnx, ghalf), glog(nnx,prec)), nnx); p1 = gadd(p1, gmul(tes, a)); pi = mppi(prec); sqrtpi2 = mpsqrt( gmul2n(pi, 1) ); if (funeq) { /* y --> y Pi/(sin(Pi s) * sqrt(2Pi)) */ y = gdiv(gmul(pi,y), gmul(sqrtpi2, gsin(gmul(s,pi), prec))); p1 = gneg(p1); } else /* y --> sqrt(2Pi) / y */ y = gdiv(sqrtpi2, y); if (dolog) { y = gadd(p1, glog(y, prec)); y[2] = (long)red_mod_2z((GEN)y[2], pi); } else y = gmul(gexp(p1, prec), y); gaffect(y, res); avma = av; return res;} |
u = divrs2_safe(bernreal(i,prec), i-1); | u = divrsns(bernreal(i,prec), i-1); | gammanew(GEN s0, int dolog, long prec){ GEN s, u, a, y, res, tes, sig, invn2, p1, nnx, pi, sqrtpi2; long i, lim, nn; pari_sp av, av2, avlim; int funeq = 0; if (DEBUGLEVEL) (void)timer2(); s = trans_fix_arg(&prec,&s0,&sig,&av,&res); if (signe(sig) <= 0 || expo(sig) < -1) { if (typ(s) == t_COMPLEX && gexpo((GEN)s[2]) <= 16) funeq = 1; } /* s <--> 1-s */ if (funeq) { s = gsub(gun, s); sig = greal(s); } { /* find "optimal" parameters [lim, nn] */ double ssig = rtodbl(sig); double st = rtodbl(gimag(s)); double la, l,l2,u,v, rlogs, ilogs; dcxlog(ssig,st, &rlogs,&ilogs); /* Re (s - 1/2) log(s) */ u = (ssig - 0.5)*rlogs - st * ilogs; /* Im (s - 1/2) log(s) */ v = (ssig - 0.5)*ilogs + st * rlogs; /* l2 = | (s - 1/2) log(s) - s + log(2Pi)/2 |^2 ~ |lngamma(s))|^2 */ u = u - ssig + log(2.*PI)/2; v = v - st; l2 = u*u + v*v; if (l2 < 0.000001) l2 = 0.000001; l = (pariC2*(prec-2) - log(l2)/2) / 2.; if (l < 0) l = 0.; if (l > 0) { double t = st * PI / l; la = t * log(t); if (la < 3) la = 3.; /* FIXME: heuristic... */ } else la = 3.; /* FIXME: heuristic... */ lim = (long)ceil(l / (1.+ log(la))); if (lim == 0) lim = 1; u = (lim-0.5) * la / PI; l2 = u*u - st*st; if (l2 > 0) { nn = (long)ceil(sqrt(l2) - ssig); if (nn < 1) nn = 1; } else nn = 1; if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld], la = %lf\n",lim,nn,la);#if 0 {/* same: old method */ long e = gexpo(s); double beta; if (e > 1000) { nn = 0; beta = log(pariK4 / (prec-2)) / LOG2 + e; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } else { double alpha = sqrt( dnorm(ssig, st) ); beta = ((bit_accuracy(prec)>>1) * LOG2 / PI) - alpha; if (beta >= 0) nn = (long)(1+pariK2*beta); else nn = 0; if (nn) lim = (long)(1+PI*(alpha+nn)); else { beta = log( pariK4 * alpha / (prec-2) ) / LOG2; if (beta > 1.) beta += log(beta)/LOG2; lim = (long)((bit_accuracy(prec)>>1)/beta + 1); } } nn++; } if (DEBUGLEVEL) fprintferr("lim, nn: [%ld, %ld]\n",lim,nn);#endif } prec++; av2 = avma; avlim = stack_lim(av2,3); y = s; if (typ(s0) == t_INT) { long ss; if (expi(s0) > 20) err(talker, "exponent too large in gamma"); ss = itos(s0); for (i=1; i < nn; i++) { y = mulrs(y, ss + i); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileuptoleaf(av2, y); } } } else for (i=1; i < nn; i++) { y = gmul(y, gaddgs(s,i)); if (low_stack(avlim,stack_lim(av2,3))) { if(DEBUGMEM>1) err(warnmem,"gamma"); y = gerepileupto(av2, y); } } nnx = gaddgs(s, nn); if (DEBUGLEVEL) msgtimer("product from 0 to N-1"); a = ginv(nnx); invn2 = gsqr(a); tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/ if (DEBUGLEVEL) msgtimer("Bernoullis"); for (i = 2*lim-2; i > 1; i -= 2) { u = divrs2_safe(bernreal(i,prec), i-1); /* Bi / i(i-1) */ tes = gadd(u, gmul(invn2,tes)); } if (DEBUGLEVEL) msgtimer("Bernoulli sum"); p1 = gsub(gmul(gsub(nnx, ghalf), glog(nnx,prec)), nnx); p1 = gadd(p1, gmul(tes, a)); pi = mppi(prec); sqrtpi2 = mpsqrt( gmul2n(pi, 1) ); if (funeq) { /* y --> y Pi/(sin(Pi s) * sqrt(2Pi)) */ y = gdiv(gmul(pi,y), gmul(sqrtpi2, gsin(gmul(s,pi), prec))); p1 = gneg(p1); } else /* y --> sqrt(2Pi) / y */ y = gdiv(sqrtpi2, y); if (dolog) { y = gadd(p1, glog(y, prec)); y[2] = (long)red_mod_2z((GEN)y[2], pi); } else y = gmul(gexp(p1, prec), y); gaffect(y, res); avma = av; return res;} |
sqrtu2_1(GEN a) | sqrtu2_1(ulong *a) | sqrtu2_1(GEN a){ double beta = sqrt((double)(ulong)a[0]); /* 0.707... ~ 1/sqrt(2) */ return (ulong)(beta * ((1UL << BITS_IN_HALFULONG) * 0.707106781186547524));} |
double beta = sqrt((double)(ulong)a[0]); | double beta = sqrt((double)a[0]); | sqrtu2_1(GEN a){ double beta = sqrt((double)(ulong)a[0]); /* 0.707... ~ 1/sqrt(2) */ return (ulong)(beta * ((1UL << BITS_IN_HALFULONG) * 0.707106781186547524));} |
xl = (GEN)x[l]; hl = (GEN*)h[l]; xk = (GEN)x[k]; hk = (GEN*)h[k]; | xl = (GEN) x[l]; xk = (GEN) x[k]; if (h) { hl = (GEN*)h[l]; hk = (GEN*)h[k]; } | REDI(long k, long l, GEN x, GEN h, GEN L, GEN B, long K, int gram){ long i,lx; GEN q = truedvmdii(addii(B,shifti(gcoeff(L,k,l),1)), shifti(B,1), NULL); GEN *hk,*hl,xk,xl; if (!signe(q)) return; q = negi(q); xl = (GEN)x[l]; hl = (GEN*)h[l]; xk = (GEN)x[k]; hk = (GEN*)h[k]; lx = lg(xl); if (is_pm1(q)) { if (signe(q) > 0) { for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); if (gram) { xk[k] = laddii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = laddii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = laddii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), B); } else { for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); if (gram) { xk[k] = lsubii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = lsubii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = lsubii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), negi(B)); } } else { /* h[,k] += q* h[,l]. x[,k] += q * x[,l]. L[k,] += q* L[l,] */ for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); if (gram) { xk[k] = laddii((GEN)xk[k], mulii(q,(GEN)xl[k])); for(i=1;i<lx;i++) coeff(x,k,i)=xk[i]=laddii((GEN)xk[i],mulii(q,(GEN)xl[i])); } for(i=1;i<l;i++) coeff(L,k,i)=laddii(gcoeff(L,k,i),mulii(q,gcoeff(L,l,i))); coeff(L,k,l) = laddii(gcoeff(L,k,l), mulii(q,B)); } if (!gram) x[k] = (long)ZV_lincomb(gun, q, xk, xl);} |
for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); | if (h) for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); | REDI(long k, long l, GEN x, GEN h, GEN L, GEN B, long K, int gram){ long i,lx; GEN q = truedvmdii(addii(B,shifti(gcoeff(L,k,l),1)), shifti(B,1), NULL); GEN *hk,*hl,xk,xl; if (!signe(q)) return; q = negi(q); xl = (GEN)x[l]; hl = (GEN*)h[l]; xk = (GEN)x[k]; hk = (GEN*)h[k]; lx = lg(xl); if (is_pm1(q)) { if (signe(q) > 0) { for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); if (gram) { xk[k] = laddii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = laddii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = laddii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), B); } else { for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); if (gram) { xk[k] = lsubii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = lsubii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = lsubii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), negi(B)); } } else { /* h[,k] += q* h[,l]. x[,k] += q * x[,l]. L[k,] += q* L[l,] */ for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); if (gram) { xk[k] = laddii((GEN)xk[k], mulii(q,(GEN)xl[k])); for(i=1;i<lx;i++) coeff(x,k,i)=xk[i]=laddii((GEN)xk[i],mulii(q,(GEN)xl[i])); } for(i=1;i<l;i++) coeff(L,k,i)=laddii(gcoeff(L,k,i),mulii(q,gcoeff(L,l,i))); coeff(L,k,l) = laddii(gcoeff(L,k,l), mulii(q,B)); } if (!gram) x[k] = (long)ZV_lincomb(gun, q, xk, xl);} |
for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); | if (h) for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); | REDI(long k, long l, GEN x, GEN h, GEN L, GEN B, long K, int gram){ long i,lx; GEN q = truedvmdii(addii(B,shifti(gcoeff(L,k,l),1)), shifti(B,1), NULL); GEN *hk,*hl,xk,xl; if (!signe(q)) return; q = negi(q); xl = (GEN)x[l]; hl = (GEN*)h[l]; xk = (GEN)x[k]; hk = (GEN*)h[k]; lx = lg(xl); if (is_pm1(q)) { if (signe(q) > 0) { for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); if (gram) { xk[k] = laddii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = laddii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = laddii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), B); } else { for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); if (gram) { xk[k] = lsubii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = lsubii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = lsubii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), negi(B)); } } else { /* h[,k] += q* h[,l]. x[,k] += q * x[,l]. L[k,] += q* L[l,] */ for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); if (gram) { xk[k] = laddii((GEN)xk[k], mulii(q,(GEN)xl[k])); for(i=1;i<lx;i++) coeff(x,k,i)=xk[i]=laddii((GEN)xk[i],mulii(q,(GEN)xl[i])); } for(i=1;i<l;i++) coeff(L,k,i)=laddii(gcoeff(L,k,i),mulii(q,gcoeff(L,l,i))); coeff(L,k,l) = laddii(gcoeff(L,k,l), mulii(q,B)); } if (!gram) x[k] = (long)ZV_lincomb(gun, q, xk, xl);} |
for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); | if (h) for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); | REDI(long k, long l, GEN x, GEN h, GEN L, GEN B, long K, int gram){ long i,lx; GEN q = truedvmdii(addii(B,shifti(gcoeff(L,k,l),1)), shifti(B,1), NULL); GEN *hk,*hl,xk,xl; if (!signe(q)) return; q = negi(q); xl = (GEN)x[l]; hl = (GEN*)h[l]; xk = (GEN)x[k]; hk = (GEN*)h[k]; lx = lg(xl); if (is_pm1(q)) { if (signe(q) > 0) { for (i=1;i<=K;i++) hk[i] = addii(hk[i],hl[i]); if (gram) { xk[k] = laddii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = laddii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = laddii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), B); } else { for (i=1;i<=K;i++) hk[i] = subii(hk[i],hl[i]); if (gram) { xk[k] = lsubii((GEN)xk[k], (GEN)xl[k]); for (i=1;i<lx;i++) coeff(x,k,i) = xk[i] = lsubii((GEN)xk[i], (GEN)xl[i]); } for (i=1;i<l; i++) coeff(L,k,i) = lsubii(gcoeff(L,k,i),gcoeff(L,l,i)); coeff(L,k,l) = laddii(gcoeff(L,k,l), negi(B)); } } else { /* h[,k] += q* h[,l]. x[,k] += q * x[,l]. L[k,] += q* L[l,] */ for(i=1;i<=K;i++) hk[i] = addii(hk[i],mulii(q,hl[i])); if (gram) { xk[k] = laddii((GEN)xk[k], mulii(q,(GEN)xl[k])); for(i=1;i<lx;i++) coeff(x,k,i)=xk[i]=laddii((GEN)xk[i],mulii(q,(GEN)xl[i])); } for(i=1;i<l;i++) coeff(L,k,i)=laddii(gcoeff(L,k,i),mulii(q,gcoeff(L,l,i))); coeff(L,k,l) = laddii(gcoeff(L,k,l), mulii(q,B)); } if (!gram) x[k] = (long)ZV_lincomb(gun, q, xk, xl);} |
swap(h[k-1], h[k]); | if (h) swap(h[k-1], h[k]); | do_SWAPI(GEN x, GEN h, GEN L, GEN B, long kmax, long k, long alpha, GEN fl, int gram){ GEN la,la2,p1,Bk; long i, j, lx; gpmem_t av; if (!fl[k-1]) return 0; av = avma; la = gcoeff(L,k,k-1); la2 = sqri(la); Bk = (GEN)B[k]; if (fl[k]) { GEN q; if (!alpha) return 0; /* only swap non-kernel + kernel vector */ q = addii(la2, mulii((GEN)B[k-1],(GEN)B[k+1])); if (cmpii(mulsi(alpha-1,sqri(Bk)), mulsi(alpha,q)) <= 0) { avma = av; return 0; } B[k] = (long)diviiexact(q, Bk); } /* SWAPI(k-1,k) */ if (DEBUGLEVEL>3 && k==kmax) { /* output diagnostics associated to re-normalized rational quantities */ gpmem_t av1 = avma; GEN d = mulii((GEN)B[k-1],(GEN)B[k+1]); p1 = subii(mulsi(alpha-1, sqri(Bk)), mulsi(alpha, la2)); fprintferr(" (%ld)", expi(p1) - expi(mulsi(alpha, d))); avma = av1; } swap(h[k-1], h[k]); swap(x[k-1], x[k]); lx = lg(x); if (gram) for (j=1; j< lx; j++) swap(coeff(x,k-1,j), coeff(x,k,j)); for (j=1; j<k-1; j++) swap(coeff(L,k-1,j), coeff(L,k,j)) if (fl[k]) { av = avma; for (i=k+1; i<=kmax; i++) { GEN t = gcoeff(L,i,k); p1 = subii(mulii((GEN)B[k+1],gcoeff(L,i,k-1)), mulii(la,t)); p1 = diviiexact(p1, Bk); coeff(L,i,k) = (long)icopy_av(p1,(GEN)av); av = avma = (gpmem_t)coeff(L,i,k); p1 = addii(mulii(la,gcoeff(L,i,k-1)), mulii((GEN)B[k-1],t)); p1 = diviiexact(p1, Bk); coeff(L,i,k-1) = (long)icopy_av(p1,(GEN)av); av = avma = (gpmem_t)coeff(L,i,k-1); } } else if (signe(la)) { p1 = diviiexact(la2, Bk); B[k+1] = B[k] = (long)p1; for (i=k+2; i<=lx; i++) B[i] = (long)diviiexact(mulii(p1,(GEN)B[i]), Bk); for (i=k+1; i<=kmax; i++) coeff(L,i,k-1) = (long)diviiexact(mulii(la,gcoeff(L,i,k-1)), Bk); for (j=k+1; j<kmax; j++) for (i=j+1; i<=kmax; i++) coeff(L,i,j) = (long)diviiexact(mulii(p1,gcoeff(L,i,j)), Bk); } else { for (i=k+1; i<=kmax; i++) { coeff(L,i,k) = coeff(L,i,k-1); coeff(L,i,k-1) = zero; } B[k] = B[k-1]; fl[k] = 1; fl[k-1] = 0; } return 1;} |
vz = NULL; | return NULL; | init_teich(ulong p, GEN q, long prec){ GEN vz, gp = utoi(p); long av = avma, j; if (p == 2UL) vz = NULL; else { /* primitive (p-1)-th root of 1 */ GEN z, z0 = padicsqrtnlift(gun, utoi(p-1), Fp_gener(gp), gp, prec); z = z0; vz = cgetg(p, t_VEC); for (j = 1; j < (long)p-2; j++) { vz[ umodiu(z, p) ] = (long)z; /* z = z0^i */ z = modii(mulii(z, z0), q); } vz[ umodiu(z, p) ] = (long)z; /* z = z0^(p-2) */ vz[1] = un; /* z0^(p-1) */ } return gerepileupto(av, gcopy(vz));} |
while (isdigit(*cp)) | while (isdigit((int)*cp)) | loc_aton(ascii, binary) const char *ascii; u_char *binary;{ const char *cp, *maxcp; u_char *bcp; u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; maxcp = cp + strlen(ascii); lltemp1 = latlon2ul(&cp, &which1); lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { case 3: /* 1 + 2, the only valid combination */ if ((which1 == 1) && (which2 == 2)) { /* normal case */ latit = lltemp1; longit = lltemp2; } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ longit = lltemp1; latit = lltemp2; } else { /* some kind of brokenness */ return (0); } break; default: /* we didn't get one of each */ return (0); } /* altitude */ if (*cp == '-') { altsign = -1; cp++; } if (*cp == '+') cp++; while (isdigit(*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal meters */ cp++; if (isdigit(*cp)) { altfrac = (*cp++ - '0') * 10; if (isdigit(*cp)) { altfrac += (*cp++ - '0'); } } } alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; siz = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; hp = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; vp = precsize_aton(&cp); defaults: bcp = binary; *bcp++ = (u_int8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; PUTLONG(latit,bcp); PUTLONG(longit,bcp); PUTLONG(alt,bcp); return (16); /* size of RR in octets */} |
if (isdigit(*cp)) { | if (isdigit((int)*cp)) { | loc_aton(ascii, binary) const char *ascii; u_char *binary;{ const char *cp, *maxcp; u_char *bcp; u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; maxcp = cp + strlen(ascii); lltemp1 = latlon2ul(&cp, &which1); lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { case 3: /* 1 + 2, the only valid combination */ if ((which1 == 1) && (which2 == 2)) { /* normal case */ latit = lltemp1; longit = lltemp2; } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ longit = lltemp1; latit = lltemp2; } else { /* some kind of brokenness */ return (0); } break; default: /* we didn't get one of each */ return (0); } /* altitude */ if (*cp == '-') { altsign = -1; cp++; } if (*cp == '+') cp++; while (isdigit(*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal meters */ cp++; if (isdigit(*cp)) { altfrac = (*cp++ - '0') * 10; if (isdigit(*cp)) { altfrac += (*cp++ - '0'); } } } alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; siz = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; hp = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; vp = precsize_aton(&cp); defaults: bcp = binary; *bcp++ = (u_int8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; PUTLONG(latit,bcp); PUTLONG(longit,bcp); PUTLONG(alt,bcp); return (16); /* size of RR in octets */} |
while (!isspace(*cp) && (cp < maxcp)) | while (!isspace((int)*cp) && (cp < maxcp)) | loc_aton(ascii, binary) const char *ascii; u_char *binary;{ const char *cp, *maxcp; u_char *bcp; u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; maxcp = cp + strlen(ascii); lltemp1 = latlon2ul(&cp, &which1); lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { case 3: /* 1 + 2, the only valid combination */ if ((which1 == 1) && (which2 == 2)) { /* normal case */ latit = lltemp1; longit = lltemp2; } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ longit = lltemp1; latit = lltemp2; } else { /* some kind of brokenness */ return (0); } break; default: /* we didn't get one of each */ return (0); } /* altitude */ if (*cp == '-') { altsign = -1; cp++; } if (*cp == '+') cp++; while (isdigit(*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal meters */ cp++; if (isdigit(*cp)) { altfrac = (*cp++ - '0') * 10; if (isdigit(*cp)) { altfrac += (*cp++ - '0'); } } } alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; siz = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; hp = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; vp = precsize_aton(&cp); defaults: bcp = binary; *bcp++ = (u_int8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; PUTLONG(latit,bcp); PUTLONG(longit,bcp); PUTLONG(alt,bcp); return (16); /* size of RR in octets */} |
while (isspace(*cp) && (cp < maxcp)) | while (isspace((int)*cp) && (cp < maxcp)) | loc_aton(ascii, binary) const char *ascii; u_char *binary;{ const char *cp, *maxcp; u_char *bcp; u_int32_t latit = 0, longit = 0, alt = 0; u_int32_t lltemp1 = 0, lltemp2 = 0; int altmeters = 0, altfrac = 0, altsign = 1; u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */ u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */ u_int8_t siz = 0x12; /* default = 1e2 cm = 1.00m */ int which1 = 0, which2 = 0; cp = ascii; maxcp = cp + strlen(ascii); lltemp1 = latlon2ul(&cp, &which1); lltemp2 = latlon2ul(&cp, &which2); switch (which1 + which2) { case 3: /* 1 + 2, the only valid combination */ if ((which1 == 1) && (which2 == 2)) { /* normal case */ latit = lltemp1; longit = lltemp2; } else if ((which1 == 2) && (which2 == 1)) { /* reversed */ longit = lltemp1; latit = lltemp2; } else { /* some kind of brokenness */ return (0); } break; default: /* we didn't get one of each */ return (0); } /* altitude */ if (*cp == '-') { altsign = -1; cp++; } if (*cp == '+') cp++; while (isdigit(*cp)) altmeters = altmeters * 10 + (*cp++ - '0'); if (*cp == '.') { /* decimal meters */ cp++; if (isdigit(*cp)) { altfrac = (*cp++ - '0') * 10; if (isdigit(*cp)) { altfrac += (*cp++ - '0'); } } } alt = (10000000 + (altsign * (altmeters * 100 + altfrac))); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; siz = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; hp = precsize_aton(&cp); while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */ cp++; while (isspace(*cp) && (cp < maxcp)) cp++; if (cp >= maxcp) goto defaults; vp = precsize_aton(&cp); defaults: bcp = binary; *bcp++ = (u_int8_t) 0; /* version byte */ *bcp++ = siz; *bcp++ = hp; *bcp++ = vp; PUTLONG(latit,bcp); PUTLONG(longit,bcp); PUTLONG(alt,bcp); return (16); /* size of RR in octets */} |
static char buf[20]; | void __assert(const char *file, int line, const char *msg){ static char buf[20]; static char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot..."; static char assert_msg[] = "assert failed: "; unsigned char ch; const unsigned char *cp; /* * Note we cannot call exit or printf from here, * assert can fail inside ISR too */ if(PC386ConsolePort == PC386_CONSOLE_PORT_CONSOLE) { printk("\nassert failed: %s: ", file); printk("%d: ", line); printk("%s\n\n", msg); printk(exit_msg); while(!_IBMPC_scankey(&ch)); printk("\n\n"); } else { PC386_uart_intr_ctrl(PC386ConsolePort, PC386_UART_INTR_CTRL_DISABLE); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=assert_msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=file; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, ':'); PC386_uart_polled_write(PC386ConsolePort, ' '); sprintf(buf, "%d: ", line); for(cp=buf; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=exit_msg; *cp != 0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_read(PC386ConsolePort); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); } rtemsReboot();} |
|
static char assert_msg[] = "assert failed: "; | void __assert(const char *file, int line, const char *msg){ static char buf[20]; static char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot..."; static char assert_msg[] = "assert failed: "; unsigned char ch; const unsigned char *cp; /* * Note we cannot call exit or printf from here, * assert can fail inside ISR too */ if(PC386ConsolePort == PC386_CONSOLE_PORT_CONSOLE) { printk("\nassert failed: %s: ", file); printk("%d: ", line); printk("%s\n\n", msg); printk(exit_msg); while(!_IBMPC_scankey(&ch)); printk("\n\n"); } else { PC386_uart_intr_ctrl(PC386ConsolePort, PC386_UART_INTR_CTRL_DISABLE); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=assert_msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=file; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, ':'); PC386_uart_polled_write(PC386ConsolePort, ' '); sprintf(buf, "%d: ", line); for(cp=buf; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=exit_msg; *cp != 0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_read(PC386ConsolePort); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); } rtemsReboot();} |
|
if(PC386ConsolePort == PC386_CONSOLE_PORT_CONSOLE) { printk("\nassert failed: %s: ", file); printk("%d: ", line); printk("%s\n\n", msg); printk(exit_msg); while(!_IBMPC_scankey(&ch)); printk("\n\n"); } else { PC386_uart_intr_ctrl(PC386ConsolePort, PC386_UART_INTR_CTRL_DISABLE); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=assert_msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=file; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, ':'); PC386_uart_polled_write(PC386ConsolePort, ' '); sprintf(buf, "%d: ", line); for(cp=buf; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=exit_msg; *cp != 0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_read(PC386ConsolePort); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); } | printk("\nassert failed: %s: ", file); printk("%d: ", line); printk("%s\n\n", msg); printk(exit_msg); ch = BSP_poll_char(); printk("\n\n"); | void __assert(const char *file, int line, const char *msg){ static char buf[20]; static char exit_msg[] = "EXECUTIVE SHUTDOWN! Any key to reboot..."; static char assert_msg[] = "assert failed: "; unsigned char ch; const unsigned char *cp; /* * Note we cannot call exit or printf from here, * assert can fail inside ISR too */ if(PC386ConsolePort == PC386_CONSOLE_PORT_CONSOLE) { printk("\nassert failed: %s: ", file); printk("%d: ", line); printk("%s\n\n", msg); printk(exit_msg); while(!_IBMPC_scankey(&ch)); printk("\n\n"); } else { PC386_uart_intr_ctrl(PC386ConsolePort, PC386_UART_INTR_CTRL_DISABLE); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=assert_msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=file; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, ':'); PC386_uart_polled_write(PC386ConsolePort, ' '); sprintf(buf, "%d: ", line); for(cp=buf; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } for(cp=msg; *cp!=0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); for(cp=exit_msg; *cp != 0; cp++) { PC386_uart_polled_write(PC386ConsolePort, *cp); } PC386_uart_polled_read(PC386ConsolePort); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); PC386_uart_polled_write(PC386ConsolePort, '\r'); PC386_uart_polled_write(PC386ConsolePort, '\n'); } rtemsReboot();} |
u_red_cyclo2n_ip(GEN x, int n) | u_red_cyclo2n_ip(GEN x, long n) | u_red_cyclo2n_ip(GEN x, int n){ long i, pow2 = 1<<(n-1); GEN z; for (i = lg(x)-1; i>pow2; i--) x[i-pow2] -= x[i]; for (; i>0; i--) if (x[i]) break; i += 2; z = cgetg(i, t_POL); z[1] = evalsigne(1); for (i--; i>=2; i--) z[i] = lstoi(x[i-1]); return z;} |
const int efin = lg(taba)-1, lv = R->lv; | const long efin = lg(taba)-1, lv = R->lv; | _powpolmod(Cache *C, GEN jac, Red *R, GEN (*_sqr)(GEN, Red *)){ const GEN taba = C->aall; const GEN tabt = C->tall; const int efin = lg(taba)-1, lv = R->lv; GEN vz, res = jac, pol2 = _sqr(res, R); int f; pari_sp av; vz = cgetg(lv+1, t_VEC); vz[1] = (long)res; for (f=2; f<=lv; f++) vz[f] = (long)_mul((GEN)vz[f-1], pol2, R); av = avma; for (f = efin; f >= 1; f--) { GEN t = (GEN)vz[taba[f]]; int tf = tabt[f]; res = f==efin ? t : _mul(t, res, R); while (tf--) res = _sqr(res, R); if ((f&7) == 0) res = gerepilecopy(av, res); } return res;} |
int f; | long f; | _powpolmod(Cache *C, GEN jac, Red *R, GEN (*_sqr)(GEN, Red *)){ const GEN taba = C->aall; const GEN tabt = C->tall; const int efin = lg(taba)-1, lv = R->lv; GEN vz, res = jac, pol2 = _sqr(res, R); int f; pari_sp av; vz = cgetg(lv+1, t_VEC); vz[1] = (long)res; for (f=2; f<=lv; f++) vz[f] = (long)_mul((GEN)vz[f-1], pol2, R); av = avma; for (f = efin; f >= 1; f--) { GEN t = (GEN)vz[taba[f]]; int tf = tabt[f]; res = f==efin ? t : _mul(t, res, R); while (tf--) res = _sqr(res, R); if ((f&7) == 0) res = gerepilecopy(av, res); } return res;} |
int tf = tabt[f]; | long tf = tabt[f]; | _powpolmod(Cache *C, GEN jac, Red *R, GEN (*_sqr)(GEN, Red *)){ const GEN taba = C->aall; const GEN tabt = C->tall; const int efin = lg(taba)-1, lv = R->lv; GEN vz, res = jac, pol2 = _sqr(res, R); int f; pari_sp av; vz = cgetg(lv+1, t_VEC); vz[1] = (long)res; for (f=2; f<=lv; f++) vz[f] = (long)_mul((GEN)vz[f-1], pol2, R); av = avma; for (f = efin; f >= 1; f--) { GEN t = (GEN)vz[taba[f]]; int tf = tabt[f]; res = f==efin ? t : _mul(t, res, R); while (tf--) res = _sqr(res, R); if ((f&7) == 0) res = gerepilecopy(av, res); } return res;} |
get_jac2(GEN N, ulong q, int k, GEN *j2q, GEN *j3q) | get_jac2(GEN N, ulong q, long k, GEN *j2q, GEN *j3q) | get_jac2(GEN N, ulong q, int k, GEN *j2q, GEN *j3q){ GEN jpq, vpk, tabf, tabg; ulong x, pk, i, qm3s2; if (k == 1) return NULL; compute_fg(q,0, &tabf,&tabg); pk = 1 << k;; vpk = vecsmall_const(pk, 0); qm3s2 = (q-3)>>1; for (x=1; x<=qm3s2; x++) vpk[ tabg[x]%pk + 1 ] += 2; vpk[ (2*tabf[qm3s2+1])%pk + 1 ]++; jpq = u_red_cyclo2n_ip(vpk, k); if (k == 2) return jpq; if (mod8(N) >= 5) { GEN v8 = cgetg(9,t_VECSMALL); for (x=1; x<=8; x++) v8[x] = 0; for (x=1; x<=q-2; x++) v8[ ((2*tabf[x]+tabg[x])&7) + 1 ]++; *j2q = polinflate(gsqr(u_red_cyclo2n_ip(v8,3)), pk>>3); *j2q = red_cyclo2n_ip(*j2q, k); } else *j2q = NULL; for (i=1; i<=pk; i++) vpk[i] = 0; for (x=1; x<=q-2; x++) vpk[ (tabf[x]+tabg[x])%pk + 1 ]++; *j3q = gmul(jpq, u_red_cyclo2n_ip(vpk,k)); *j3q = red_cyclo2n_ip(*j3q, k); return jpq;} |
int lv, lfa, pk, p, e, i, k; | long lv, lfa, pk, p, e, i, k; | calcglobs(Red *R, ulong t, long *pltab, GEN *pP){ GEN fat, P, E, PE; int lv, lfa, pk, p, e, i, k; long ltab, b; Cache **pC; b = bit_accuracy(lgefint(R->N)) - 1; while ( !bittest(R->N,b) ) b--; b++; k = 3; while (((k+1)*(k+2) << (k-1)) < b) k++; *pltab = ltab = (b/k) + 2; R->k = k; R->lv = 1 << (k-1); R->mask = (1UL << k) - 1; fat = factoru(t); P = gel(fat,1); lfa = lg(P); E = gel(fat,2); PE= gel(fat,3); lv = 1; for (i=1; i<lfa; i++) { long pe = PE[i]; if (pe > lv) lv = pe; } pC = (Cache**)cgetg(lv + 1, t_VEC); pC[1] = alloc_cache(); /* to be used as temp in step5() */ for (i = 2; i <= lv; i++) pC[i] = NULL; for (i=1; i<lfa; i++) { pk = p = P[i]; e = E[i]; for (k=1; k<=e; k++, pk*=p) { pC[pk] = alloc_cache(); if (!filltabs(pC[pk], pC[p], R, p,pk, ltab)) return NULL; } } if (DEBUGLEVEL) fprintferr("\n"); *pP = P; return pC;} |
fat = factoru(t); | fat = factoru_pow(t); | calcglobs(Red *R, ulong t, long *pltab, GEN *pP){ GEN fat, P, E, PE; int lv, lfa, pk, p, e, i, k; long ltab, b; Cache **pC; b = bit_accuracy(lgefint(R->N)) - 1; while ( !bittest(R->N,b) ) b--; b++; k = 3; while (((k+1)*(k+2) << (k-1)) < b) k++; *pltab = ltab = (b/k) + 2; R->k = k; R->lv = 1 << (k-1); R->mask = (1UL << k) - 1; fat = factoru(t); P = gel(fat,1); lfa = lg(P); E = gel(fat,2); PE= gel(fat,3); lv = 1; for (i=1; i<lfa; i++) { long pe = PE[i]; if (pe > lv) lv = pe; } pC = (Cache**)cgetg(lv + 1, t_VEC); pC[1] = alloc_cache(); /* to be used as temp in step5() */ for (i = 2; i <= lv; i++) pC[i] = NULL; for (i=1; i<lfa; i++) { pk = p = P[i]; e = E[i]; for (k=1; k<=e; k++, pk*=p) { pC[pk] = alloc_cache(); if (!filltabs(pC[pk], pC[p], R, p,pk, ltab)) return NULL; } } if (DEBUGLEVEL) fprintferr("\n"); *pP = P; return pC;} |
tmp = SERF_BUCKET_SIMPLE_STRING_LEN(in, inl, ctx->sink->allocator); | static int bio_bucket_write(BIO *bio, const char *in, int inl){ serf_ssl_context_t *ctx = bio->ptr; serf_bucket_t *tmp; /* Do we need to copy this data? */ tmp = SERF_BUCKET_SIMPLE_STRING_LEN(in, inl, ctx->sink->allocator); serf_bucket_aggregate_append(ctx->sink, tmp); return inl;} |
|
look_eta2(int k, GEN z) | look_eta2(long k, GEN z) | look_eta2(int k, GEN z){ long d, s; if (typ(z) != t_POL) d = 0; /* t_INT */ else { if (!ismonome(z)) return -1; d = degpol(z); z = (GEN)z[d+2]; /* leading term */ } s = signe(z); if (!s || !is_pm1(z)) return -1; return (s > 0)? d: d + (1<<(k-1));} |
step4a(Cache *C, Red *R, ulong q, int p, int k, GEN jpq) | step4a(Cache *C, Red *R, ulong q, long p, long k, GEN jpq) | step4a(Cache *C, Red *R, ulong q, int p, int k, GEN jpq){ const int pk = u_pow(p,k); int ind; GEN s1, s2, s3; if (!jpq) { GEN tabf, tabg; compute_fg(q,1, &tabf,&tabg); jpq = get_jac(C, q, pk, tabf, tabg); } s1 = autvec_TH(pk, jpq, C->E, C->cyc); s2 = powpolmod(C,R, p,k, s1); s3 = autvec_AL(pk, jpq, C->E, R); s3 = _red(gmul(s3,s2), R); ind = look_eta(C->eta, pk, s3); if (ind < 0) return -1; return (ind%p) != 0;} |
const int pk = u_pow(p,k); int ind; | const long pk = npownn(p,k); long ind; | step4a(Cache *C, Red *R, ulong q, int p, int k, GEN jpq){ const int pk = u_pow(p,k); int ind; GEN s1, s2, s3; if (!jpq) { GEN tabf, tabg; compute_fg(q,1, &tabf,&tabg); jpq = get_jac(C, q, pk, tabf, tabg); } s1 = autvec_TH(pk, jpq, C->E, C->cyc); s2 = powpolmod(C,R, p,k, s1); s3 = autvec_AL(pk, jpq, C->E, R); s3 = _red(gmul(s3,s2), R); ind = look_eta(C->eta, pk, s3); if (ind < 0) return -1; return (ind%p) != 0;} |
step4b(Cache *C, Red *R, ulong q, int k) | step4b(Cache *C, Red *R, ulong q, long k) | step4b(Cache *C, Red *R, ulong q, int k){ const int pk = 1 << k; int ind; GEN s1, s2, s3, j2q, j3q; (void)get_jac2(R->N,q,k, &j2q,&j3q); s1 = autvec_TH(pk, j3q, C->E, C->cyc); s2 = powpolmod(C,R, 2,k, s1); s3 = autvec_AL(pk, j3q, C->E, R); s3 = _red(gmul(s3,s2), R); if (j2q) s3 = _red(gmul(j2q, s3), R); ind = look_eta2(k, s3); if (ind < 0) return -1; if ((ind&1)==0) return 0; if (DEBUGLEVEL>2) C->ctsgt++; s3 = Fp_pow(utoipos(q), R->N2, R->N); return is_m1(s3, R->N);} |
const int pk = 1 << k; int ind; | const long pk = 1 << k; long ind; | step4b(Cache *C, Red *R, ulong q, int k){ const int pk = 1 << k; int ind; GEN s1, s2, s3, j2q, j3q; (void)get_jac2(R->N,q,k, &j2q,&j3q); s1 = autvec_TH(pk, j3q, C->E, C->cyc); s2 = powpolmod(C,R, 2,k, s1); s3 = autvec_AL(pk, j3q, C->E, R); s3 = _red(gmul(s3,s2), R); if (j2q) s3 = _red(gmul(j2q, s3), R); ind = look_eta2(k, s3); if (ind < 0) return -1; if ((ind&1)==0) return 0; if (DEBUGLEVEL>2) C->ctsgt++; s3 = Fp_pow(utoipos(q), R->N2, R->N); return is_m1(s3, R->N);} |
int ind; | long ind; | step4c(Cache *C, Red *R, ulong q){ int ind; GEN s0,s1,s3, jpq = get_jac2(R->N,q,2, NULL,NULL); s0 = sqrmod4(jpq, R); s1 = gmulsg(q,s0); s3 = powpolmod(C,R, 2,2, s1); if (mod4(R->N) == 3) s3 = _red(gmul(s0,s3), R); ind = look_eta2(2, s3); if (ind < 0) return -1; if ((ind&1)==0) return 0; if (DEBUGLEVEL>2) C->ctsgt++; s3 = Fp_pow(utoipos(q), R->N2, R->N); return is_m1(s3, R->N);} |
step5(Cache **pC, Red *R, int p, GEN et, ulong ltab) | step5(Cache **pC, Red *R, long p, GEN et, ulong ltab) | step5(Cache **pC, Red *R, int p, GEN et, ulong ltab){ ulong ct = 1, q; int pk, k, fl = -1; byteptr d = diffptr+2; Cache *C, *Cp; for (q = 3; *d; ) { if (q%p != 1 || umodiu(et,q) == 0) goto repeat; if (umodiu(R->N,q) == 0) return -1; k = u_lval(q-1, p); pk = u_pow(p,k); if (pk < lg(pC) && pC[pk]) { C = pC[pk]; Cp = pC[p]; } else { C = pC[1]; C->matvite = NULL; /* re-init */ Cp = NULL; } if (!filltabs(C, Cp, R, p, pk, ltab)) return 0; R->C = C->cyc; if (p >= 3) fl = step4a(C,R, q,p,k, NULL); else if (k >= 3) fl = step4b(C,R, q,k); else if (k == 2) fl = step4c(C,R, q); else fl = step4d(C,R, q); if (fl == -1) return (int)(-q); if (fl == 1) return ct; ct++; repeat: NEXT_PRIME_VIADIFF(q,d); } err(bugparier,"aprcl test fails! this is highly improbable"); return 0;} |
int pk, k, fl = -1; | long pk, k, fl = -1; | step5(Cache **pC, Red *R, int p, GEN et, ulong ltab){ ulong ct = 1, q; int pk, k, fl = -1; byteptr d = diffptr+2; Cache *C, *Cp; for (q = 3; *d; ) { if (q%p != 1 || umodiu(et,q) == 0) goto repeat; if (umodiu(R->N,q) == 0) return -1; k = u_lval(q-1, p); pk = u_pow(p,k); if (pk < lg(pC) && pC[pk]) { C = pC[pk]; Cp = pC[p]; } else { C = pC[1]; C->matvite = NULL; /* re-init */ Cp = NULL; } if (!filltabs(C, Cp, R, p, pk, ltab)) return 0; R->C = C->cyc; if (p >= 3) fl = step4a(C,R, q,p,k, NULL); else if (k >= 3) fl = step4b(C,R, q,k); else if (k == 2) fl = step4c(C,R, q); else fl = step4d(C,R, q); if (fl == -1) return (int)(-q); if (fl == 1) return ct; ct++; repeat: NEXT_PRIME_VIADIFF(q,d); } err(bugparier,"aprcl test fails! this is highly improbable"); return 0;} |
pk = u_pow(p,k); | pk = npownn(p,k); | step5(Cache **pC, Red *R, int p, GEN et, ulong ltab){ ulong ct = 1, q; int pk, k, fl = -1; byteptr d = diffptr+2; Cache *C, *Cp; for (q = 3; *d; ) { if (q%p != 1 || umodiu(et,q) == 0) goto repeat; if (umodiu(R->N,q) == 0) return -1; k = u_lval(q-1, p); pk = u_pow(p,k); if (pk < lg(pC) && pC[pk]) { C = pC[pk]; Cp = pC[p]; } else { C = pC[1]; C->matvite = NULL; /* re-init */ Cp = NULL; } if (!filltabs(C, Cp, R, p, pk, ltab)) return 0; R->C = C->cyc; if (p >= 3) fl = step4a(C,R, q,p,k, NULL); else if (k >= 3) fl = step4b(C,R, q,k); else if (k == 2) fl = step4c(C,R, q); else fl = step4d(C,R, q); if (fl == -1) return (int)(-q); if (fl == 1) return ct; ct++; repeat: NEXT_PRIME_VIADIFF(q,d); } err(bugparier,"aprcl test fails! this is highly improbable"); return 0;} |
if (fl == -1) return (int)(-q); | if (fl == -1) return (long)(-q); | step5(Cache **pC, Red *R, int p, GEN et, ulong ltab){ ulong ct = 1, q; int pk, k, fl = -1; byteptr d = diffptr+2; Cache *C, *Cp; for (q = 3; *d; ) { if (q%p != 1 || umodiu(et,q) == 0) goto repeat; if (umodiu(R->N,q) == 0) return -1; k = u_lval(q-1, p); pk = u_pow(p,k); if (pk < lg(pC) && pC[pk]) { C = pC[pk]; Cp = pC[p]; } else { C = pC[1]; C->matvite = NULL; /* re-init */ Cp = NULL; } if (!filltabs(C, Cp, R, p, pk, ltab)) return 0; R->C = C->cyc; if (p >= 3) fl = step4a(C,R, q,p,k, NULL); else if (k >= 3) fl = step4b(C,R, q,k); else if (k == 2) fl = step4c(C,R, q); else fl = step4d(C,R, q); if (fl == -1) return (int)(-q); if (fl == 1) return ct; ct++; repeat: NEXT_PRIME_VIADIFF(q,d); } err(bugparier,"aprcl test fails! this is highly improbable"); return 0;} |
errno = ENOSYS; return -1; | off_t status; status = lseek( dirp->dd_fd, loc, SEEK_SET ); if( status == -1 ) return; dirp->dd_loc = 0; | void seekdir( DIR *dirp, long loc){ errno = ENOSYS; return -1;} |
_Thread_Enable_dispatch(); | rtems_status_code rtems_timer_server_fire_after( Objects_Id id, rtems_interval ticks, rtems_timer_service_routine_entry routine, void *user_data){ Timer_Control *the_timer; Objects_Locations location; ISR_Level level; extern Chain_Control _Timer_Ticks_chain; if ( !_Timer_Server ) return RTEMS_INCORRECT_STATE; if ( !routine ) return RTEMS_INVALID_ADDRESS; if ( ticks == 0 ) return RTEMS_INVALID_NUMBER; the_timer = _Timer_Get( id, &location ); switch ( location ) { case OBJECTS_REMOTE: /* should never return this */ return RTEMS_INTERNAL_ERROR; case OBJECTS_ERROR: return RTEMS_INVALID_ID; case OBJECTS_LOCAL: (void) _Watchdog_Remove( &the_timer->Ticker ); _ISR_Disable( level ); /* * Check to see if the watchdog has just been inserted by a * higher priority interrupt. If so, abandon this insert. */ if ( the_timer->Ticker.state != WATCHDOG_INACTIVE ) { _ISR_Enable( level ); return RTEMS_SUCCESSFUL; } /* * OK. Now we now the timer was not rescheduled by an interrupt * so we can atomically initialize it as in use. */ the_timer->the_class = TIMER_INTERVAL_ON_TASK; _Watchdog_Initialize( &the_timer->Ticker, routine, id, user_data ); the_timer->Ticker.initial = ticks; _ISR_Enable( level ); _Timer_Server_stop_ticks_timer(); _Timer_Server_process_ticks_chain(); _Watchdog_Insert( &_Timer_Ticks_chain, &the_timer->Ticker ); _Timer_Server_reset_ticks_timer(); _Thread_Enable_dispatch(); return RTEMS_SUCCESSFUL; } return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */} |
|
if (config->hardware_address != NULL) memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); else memset (sc->arpcom.ac_enaddr, 0, ETHER_ADDR_LEN); | rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config){ int i; struct ne_softc *sc; struct ifnet *ifp; int mtu; /* Find a free driver. */ sc = NULL; for (i = 0; i < NNEDRIVER; ++i) { sc = &ne_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (sc == NULL) { printf ("Too many NE2000 drivers.\n"); return 0; } memset (sc, 0, sizeof *sc); /* Handle the options passed in by the caller. */ if (config->hardware_address != NULL) memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); else memset (sc->arpcom.ac_enaddr, 0, ETHER_ADDR_LEN); if (config->mtu != 0) mtu = config->mtu; else mtu = ETHERMTU; if (config->irno != 0) sc->irno = config->irno; else { /* We use 5 as the default IRQ. */ sc->irno = 5; } if (config->port != 0) sc->port = config->port; else { /* We use 0x300 as the default IO port number. */ sc->port = 0x300; } sc->accept_broadcasts = ! config->ignore_broadcast; /* Set up the network interface. */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "ne"; ifp->if_mtu = mtu; ifp->if_init = ne_init; ifp->if_ioctl = ne_ioctl; ifp->if_start = ne_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* Attach the interface. */ if_attach (ifp); ether_ifattach (ifp); return 1;} |
|
if (config->hardware_address != NULL) memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); else { unsigned char prom[16]; int ia; outport_byte (sc->port + CMDR, MSK_PG0 | MSK_RD2 | MSK_STP); outport_byte (sc->port + DCR, MSK_FT10 | MSK_BMS | MSK_WTS); outport_byte (sc->port + RBCR0, 0); outport_byte (sc->port + RBCR1, 0); outport_byte (sc->port + RCR, MSK_MON); outport_byte (sc->port + TCR, MSK_LOOP); outport_byte (sc->port + IMR, 0); outport_byte (sc->port + ISR, 0xff); ne_read_data (sc, 0, sizeof prom, prom); outport_byte (sc->port + CMDR, MSK_PG0 | MSK_RD2 | MSK_STP); for (ia = 0; ia < ETHER_ADDR_LEN; ++ia) sc->arpcom.ac_enaddr[ia] = prom[ia * 2]; } | rtems_ne_driver_attach (struct rtems_bsdnet_ifconfig *config){ int i; struct ne_softc *sc; struct ifnet *ifp; int mtu; /* Find a free driver. */ sc = NULL; for (i = 0; i < NNEDRIVER; ++i) { sc = &ne_softc[i]; ifp = &sc->arpcom.ac_if; if (ifp->if_softc == NULL) break; } if (sc == NULL) { printf ("Too many NE2000 drivers.\n"); return 0; } memset (sc, 0, sizeof *sc); /* Handle the options passed in by the caller. */ if (config->hardware_address != NULL) memcpy (sc->arpcom.ac_enaddr, config->hardware_address, ETHER_ADDR_LEN); else memset (sc->arpcom.ac_enaddr, 0, ETHER_ADDR_LEN); if (config->mtu != 0) mtu = config->mtu; else mtu = ETHERMTU; if (config->irno != 0) sc->irno = config->irno; else { /* We use 5 as the default IRQ. */ sc->irno = 5; } if (config->port != 0) sc->port = config->port; else { /* We use 0x300 as the default IO port number. */ sc->port = 0x300; } sc->accept_broadcasts = ! config->ignore_broadcast; /* Set up the network interface. */ ifp->if_softc = sc; ifp->if_unit = i + 1; ifp->if_name = "ne"; ifp->if_mtu = mtu; ifp->if_init = ne_init; ifp->if_ioctl = ne_ioctl; ifp->if_start = ne_start; ifp->if_output = ether_output; ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX; if (ifp->if_snd.ifq_maxlen == 0) ifp->if_snd.ifq_maxlen = ifqmaxlen; /* Attach the interface. */ if_attach (ifp); ether_ifattach (ifp); return 1;} |
|
Flx_shift(GEN a, long n, ulong p) | Flx_shift(GEN a, long n) | Flx_shift(GEN a, long n, ulong p){ long i, l = lg(a); GEN b = cgetg_copy(l+n, a); b[1] = a[1]; for (i=0; i<n; i++) b[2+i] = 0; for (i=2; i<l; i++) b[i+n] = a[i]; return b;} |
GEN b = cgetg_copy(l+n, a); | GEN b; if (l==2) return vecsmall_copy(a); b = cgetg(l+n, t_VECSMALL); | Flx_shift(GEN a, long n, ulong p){ long i, l = lg(a); GEN b = cgetg_copy(l+n, a); b[1] = a[1]; for (i=0; i<n; i++) b[2+i] = 0; for (i=2; i<l; i++) b[i+n] = a[i]; return b;} |
static GEN _FlxqX_mul(GEN a,GEN b){return FlxqX_mul(a,b,Tmodulo,modulo);} | static GEN _FlxqX_mul(void *data,GEN a,GEN b) { struct _FlxqX *d=(struct _FlxqX*)data; return FlxqX_mul(a,b,d->T,d->p); } | static GEN _FlxqX_mul(GEN a,GEN b){return FlxqX_mul(a,b,Tmodulo,modulo);} |
modulo = p; Tmodulo = T; return divide_conquer_prod(V, &_FlxqX_mul); | struct _FlxqX d; d.p=p; d.T=T; return divide_conquer_assoc(V, &_FlxqX_mul, (void*)&d); | FlxqXV_prod(GEN V, GEN T, ulong p){ modulo = p; Tmodulo = T; return divide_conquer_prod(V, &_FlxqX_mul);} |
return Flx_renormalize(x, i+1); | return FlxX_renormalize(x, i+1); | FlxqX_from_Kronecker(GEN z, GEN T, ulong p){ long i,j,lx,l, N = (degpol(T)<<1) + 1; GEN x, t = cgetg(N,t_VECSMALL); t[1] = T[1]; l = lg(z); lx = (l-2) / (N-2); x = cgetg(lx+3,t_POL); x[1]=z[1]; for (i=2; i<lx+2; i++) { for (j=2; j<N; j++) t[j] = z[j]; z += (N-2); x[i] = (long)Flx_rem(Flx_renormalize(t,N), T,p); } N = (l-2) % (N-2) + 2; for (j=2; j<N; j++) t[j] = z[j]; x[i] = (long)Flx_rem(Flx_renormalize(t,N), T,p); return Flx_renormalize(x, i+1);} |
else if ( strstr( line->Contents, "@subsubsection" ) ) line->keyword = KEYWORD_SUBSUBSECTION; else if ( strstr( line->Contents, "@raise" ) ) line->keyword = KEYWORD_RAISE; else if ( strstr( line->Contents, "@lower" ) ) line->keyword = KEYWORD_LOWER; | void StripBlanks( void ){ Line_Control *line; Keyword_indices_t index; int indentation; int length; for ( line = (Line_Control *) Lines.first ; !_Chain_Is_last( &line->Node ) ; line = (Line_Control *) line->Node.next ) { /* * Strip white space from the end of each line */ length = strlen( line->Contents ); while ( isspace( line->Contents[ --length ] ) ) line->Contents[ length ] = '\0'; if ( strstr( line->Contents, "@chapter" ) ) line->keyword = KEYWORD_CHAPTER; else if ( strstr( line->Contents, "@chapheading" ) ) line->keyword = KEYWORD_CHAPHEADING; else if ( strstr( line->Contents, "@section" ) ) line->keyword = KEYWORD_SECTION; else if ( strstr( line->Contents, "@subsection" ) ) line->keyword = KEYWORD_SUBSECTION; else line->keyword = KEYWORD_OTHER; } line = AllocateLine(); line->keyword = KEYWORD_END; _Chain_Append( &Lines, &line->Node );} |
|
if (*analyseur == '"') { skipstring(); return 0; } if (*analyseur == '!') { analyseur++; skiptruc(); return 0; } if (*analyseur == '\'') | switch(*analyseur) | skiptruc(void){ long n=0; char *old; if (*analyseur == '"') { skipstring(); return 0; } if (*analyseur == '!') { analyseur++; skiptruc(); return 0; } if (*analyseur == '\'') { analyseur++; check_var_name(); skipentry(); return 0; } if (isalpha((int)*analyseur)) { skipidentifier(); return 0; } if (isdigit((int)*analyseur) || *analyseur== '.') { skipconstante(); return 0; } switch(*analyseur++) { case '(': skipexpr(); match(')'); return 0; case '[': old = analyseur-1; if (*analyseur == ';' && analyseur[1] == ']') /* 0 x 0 matrix */ { analyseur+=2; return 0; } if (*analyseur != ']') { do { n++; skipexpr(); old=analyseur; } while (*analyseur++ == ','); analyseur--; } switch (*analyseur) { case ']': analyseur++; return n; case ';': { long m, norig=n; /* number of elts in first line */ old=analyseur; do { m=n; do { n++; analyseur++; skipexpr(); } while (*analyseur != ';' && *analyseur != ']'); if (n-m != norig) err(talker2,"non rectangular matrix",old,mark.start); } while (*analyseur != ']'); analyseur++; return n; } default: err(talker2,"; or ] expected",old,mark.start); return 0; /* not reached */ } case '%': if (*analyseur == '`') { while (*++analyseur == '`'); return 0; } number(&n); return 0; } err(caracer1,analyseur-1,mark.start); return 0; /* not reached */} |
analyseur++; check_var_name(); skipentry(); return 0; | case '"': skipstring(); return 0; case '!': analyseur++; skiptruc(); return 0; case '&': case '\'': analyseur++; check_var_name(); skipentry(); return 0; | skiptruc(void){ long n=0; char *old; if (*analyseur == '"') { skipstring(); return 0; } if (*analyseur == '!') { analyseur++; skiptruc(); return 0; } if (*analyseur == '\'') { analyseur++; check_var_name(); skipentry(); return 0; } if (isalpha((int)*analyseur)) { skipidentifier(); return 0; } if (isdigit((int)*analyseur) || *analyseur== '.') { skipconstante(); return 0; } switch(*analyseur++) { case '(': skipexpr(); match(')'); return 0; case '[': old = analyseur-1; if (*analyseur == ';' && analyseur[1] == ']') /* 0 x 0 matrix */ { analyseur+=2; return 0; } if (*analyseur != ']') { do { n++; skipexpr(); old=analyseur; } while (*analyseur++ == ','); analyseur--; } switch (*analyseur) { case ']': analyseur++; return n; case ';': { long m, norig=n; /* number of elts in first line */ old=analyseur; do { m=n; do { n++; analyseur++; skipexpr(); } while (*analyseur != ';' && *analyseur != ']'); if (n-m != norig) err(talker2,"non rectangular matrix",old,mark.start); } while (*analyseur != ']'); analyseur++; return n; } default: err(talker2,"; or ] expected",old,mark.start); return 0; /* not reached */ } case '%': if (*analyseur == '`') { while (*++analyseur == '`'); return 0; } number(&n); return 0; } err(caracer1,analyseur-1,mark.start); return 0; /* not reached */} |
rtems_unsigned32 SCV64_Get_Interrupt_Enable() | uint32_t SCV64_Get_Interrupt_Enable() | rtems_unsigned32 SCV64_Get_Interrupt_Enable(){ /* * Return the set of interrupts enabled. */ return SCV64->LIE;} |
rtems_unsigned32 SCV64_Get_Interrupt() | uint32_t SCV64_Get_Interrupt() | rtems_unsigned32 SCV64_Get_Interrupt(){ rtems_unsigned8 data; /* * Put the LIS data into the lower byte of the result */ data = SCV64->LIS; return data;} |
rtems_unsigned8 data; | uint8_t data; | rtems_unsigned32 SCV64_Get_Interrupt(){ rtems_unsigned8 data; /* * Put the LIS data into the lower byte of the result */ data = SCV64->LIS; return data;} |
rtems_unsigned8 data; | uint8_t data; | void SCV64_Generate_DUART_Interrupts() { rtems_unsigned8 data; /* * Set Local Interrupt 5 enable */ data = SCV64->LIE; data |= LOCAL_INTERRUPT_ENABLE_5; SCV64->LIE = data; /* * Set Autovector. */ data = SCV64->IC54; data |= AUTOVECTOR_5; SCV64->IC54 = data;} |
if (APR_STATUS_IS_EOF(status)) { return APR_SUCCESS; } | static apr_status_t serf_deflate_read(serf_bucket_t *bucket, apr_size_t requested, const char **data, apr_size_t *len){ deflate_context_t *ctx = bucket->data; unsigned long compCRC, compLen; apr_status_t status; const char *private_data; apr_size_t private_len; int zRC; while (1) { switch (ctx->state) { case STATE_READING_HEADER: case STATE_READING_VERIFY: status = serf_bucket_read(ctx->stream, ctx->stream_left, &private_data, &private_len); if (SERF_BUCKET_READ_ERROR(status)) { return status; } memcpy(ctx->hdr_buffer + (ctx->stream_size - ctx->stream_left), private_data, private_len); ctx->stream_left -= private_len; if (ctx->stream_left == 0) { ctx->state++; } if (status) { return status; } break; case STATE_HEADER: if (ctx->hdr_buffer[0] != deflate_magic[0] || ctx->hdr_buffer[1] != deflate_magic[1]) { return APR_EGENERAL; } if (ctx->hdr_buffer[3] != 0) { return APR_EGENERAL; } ctx->state++; break; case STATE_VERIFY: /* Do the checksum computation. */ compCRC = getLong(ctx->hdr_buffer); if (ctx->crc != compCRC) { return APR_EGENERAL; } compLen = getLong(ctx->hdr_buffer + 4); if (ctx->zstream.total_out != compLen) { return APR_EGENERAL; } ctx->state++; break; case STATE_INIT: zRC = inflateInit2(&ctx->zstream, ctx->windowSize); if (zRC != Z_OK) { return APR_EGENERAL; } ctx->zstream.next_out = ctx->buffer; ctx->zstream.avail_out = ctx->bufferSize; ctx->state++; break; case STATE_FINISH: inflateEnd(&ctx->zstream); serf_bucket_aggregate_prepend(ctx->stream, ctx->inflate_stream); ctx->inflate_stream = 0; ctx->state++; break; case STATE_INFLATE: /* Do we have anything already uncompressed to read? */ status = serf_bucket_read(ctx->inflate_stream, requested, data, len); if (SERF_BUCKET_READ_ERROR(status)) { return status; } /* Hide EOF. */ if (APR_STATUS_IS_EOF(status)) { status = ctx->stream_status; } if (*len != 0) { return status; } /* We tried; but we have nothing buffered. Fetch more. */ /* It is possible that we maxed out avail_out before * exhausting avail_in; therefore, continue using the * previous buffer. Otherwise, fetch more data from * our stream bucket. */ if (ctx->zstream.avail_in == 0) { /* When we empty our inflated stream, we'll return this * status - this allow us to eventually pass up EAGAINs. */ ctx->stream_status = serf_bucket_read(ctx->stream, ctx->bufferSize, &private_data, &private_len); if (SERF_BUCKET_READ_ERROR(ctx->stream_status)) { return ctx->stream_status; } ctx->zstream.next_in = (unsigned char*)private_data; ctx->zstream.avail_in = private_len; } zRC = Z_OK; while (ctx->zstream.avail_in != 0) { /* We're full, clear out our buffer, reset, and return. */ if (ctx->zstream.avail_out == 0) { serf_bucket_t *tmp; ctx->zstream.next_out = ctx->buffer; private_len = ctx->bufferSize - ctx->zstream.avail_out; ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, private_len); /* FIXME: There probably needs to be a free func. */ tmp = SERF_BUCKET_SIMPLE_STRING_LEN((char *)ctx->buffer, private_len, bucket->allocator); serf_bucket_aggregate_append(ctx->inflate_stream, tmp); ctx->zstream.avail_out = ctx->bufferSize; break; } zRC = inflate(&ctx->zstream, Z_NO_FLUSH); if (zRC == Z_STREAM_END) { serf_bucket_t *tmp; private_len = ctx->bufferSize - ctx->zstream.avail_out; ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, private_len); /* FIXME: There probably needs to be a free func. */ tmp = SERF_BUCKET_SIMPLE_STRING_LEN((char *)ctx->buffer, private_len, bucket->allocator); serf_bucket_aggregate_append(ctx->inflate_stream, tmp); ctx->zstream.avail_out = ctx->bufferSize; /* Push back the remaining data to be read. */ tmp = serf_bucket_aggregate_create(bucket->allocator); serf_bucket_aggregate_prepend(tmp, ctx->stream); ctx->stream = tmp; /* We now need to take the remaining avail_in and * throw it in ctx->stream so our next read picks it up. */ tmp = SERF_BUCKET_SIMPLE_STRING_LEN(ctx->zstream.next_in, ctx->zstream.avail_in, bucket->allocator); serf_bucket_aggregate_prepend(ctx->stream, tmp); switch (ctx->format) { case SERF_DEFLATE_GZIP: ctx->stream_left = ctx->stream_size = DEFLATE_VERIFY_SIZE; ctx->state++; break; case SERF_DEFLATE_DEFLATE: /* Deflate does not have a verify footer. */ ctx->state = STATE_FINISH; break; default: abort(); } break; } if (zRC != Z_OK) { return APR_EGENERAL; } } /* Okay, we've inflated. Try to read. */ status = serf_bucket_read(ctx->inflate_stream, requested, data, len); /* Hide EOF. */ if (APR_STATUS_IS_EOF(status)) { status = ctx->stream_status; } return status; case STATE_DONE: /* We're done inflating. Use our finished buffer. */ return serf_bucket_read(ctx->stream, requested, data, len); default: abort(); } } return APR_SUCCESS;} |
|
if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } | static apr_status_t serf_headers_peek(serf_bucket_t *bucket, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } /* note that select_value() will ensure ctx->cur_read is set for below */ select_value(ctx, data, len); /* if we're on the last header, and the last part of it, then EOF */ if (ctx->cur_read->next == NULL && ctx->state == READ_CRLF) return APR_EOF; return APR_SUCCESS;} |
|
if (ctx->cur_read->next == NULL && ctx->state == READ_CRLF) | if (ctx->state == READ_DONE || ctx->state == READ_TERM) | static apr_status_t serf_headers_peek(serf_bucket_t *bucket, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } /* note that select_value() will ensure ctx->cur_read is set for below */ select_value(ctx, data, len); /* if we're on the last header, and the last part of it, then EOF */ if (ctx->cur_read->next == NULL && ctx->state == READ_CRLF) return APR_EOF; return APR_SUCCESS;} |
if (ctx->state == READ_DONE) { *len = 0; | select_value(ctx, data, &avail); if (ctx->state == READ_DONE) | static apr_status_t serf_headers_read(serf_bucket_t *bucket, apr_size_t requested, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; apr_size_t avail; if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } select_value(ctx, data, &avail); if (requested >= avail) { /* return everything from this chunk */ *len = avail; /* we consumed this chunk. advance the state. */ return consume_chunk(ctx); } /* return just the amount requested, and advance our pointer */ *len = requested; ctx->amt_read += requested; /* there is more that can be read immediately */ return APR_SUCCESS;} |
} select_value(ctx, data, &avail); | static apr_status_t serf_headers_read(serf_bucket_t *bucket, apr_size_t requested, const char **data, apr_size_t *len){ headers_context_t *ctx = bucket->data; apr_size_t avail; if (ctx->state == READ_DONE) { *len = 0; return APR_EOF; } select_value(ctx, data, &avail); if (requested >= avail) { /* return everything from this chunk */ *len = avail; /* we consumed this chunk. advance the state. */ return consume_chunk(ctx); } /* return just the amount requested, and advance our pointer */ *len = requested; ctx->amt_read += requested; /* there is more that can be read immediately */ return APR_SUCCESS;} |
|
rtems_unsigned32 value | uint32_t value | rtems_symbol_value_lookup_exact( rtems_symbol_table_t *table, rtems_unsigned32 value ){ rtems_unsigned32 s; rtems_symbol_t *sp; if (table == 0) { table = rtems_monitor_symbols; if (table == 0) return NULL; } if (table->sorted) { sp = rtems_symbol_value_lookup(table, value); if ( rtems_symbol_value(sp) == value ) return sp; else return NULL; /* not an exact match */ } for (s = 0, sp = table->addresses; s < table->next; s++, sp++) { if ( sp->value == value ) return sp; } return NULL;} |
rtems_unsigned32 s; | uint32_t s; | rtems_symbol_value_lookup_exact( rtems_symbol_table_t *table, rtems_unsigned32 value ){ rtems_unsigned32 s; rtems_symbol_t *sp; if (table == 0) { table = rtems_monitor_symbols; if (table == 0) return NULL; } if (table->sorted) { sp = rtems_symbol_value_lookup(table, value); if ( rtems_symbol_value(sp) == value ) return sp; else return NULL; /* not an exact match */ } for (s = 0, sp = table->addresses; s < table->next; s++, sp++) { if ( sp->value == value ) return sp; } return NULL;} |
float dx,dy,dyvy; | float dx,dy; | static void lineargradient(SDL_svg_context *c, void *_span, int y){float cx,cy;float vx,vy;float f;float dx,dy,dyvy;int dp;int policy;int x, w, coverage; x=((FT_Span *)_span)->x; w=((FT_Span *)_span)->len; coverage=((FT_Span *)_span)->coverage; policy = c->gradient_policy; cx=c->gradient_p1.x; cy=c->gradient_p1.y; vx=c->gradient_p2.x - cx; vy=c->gradient_p2.y - cy; f=vx*vx+vy*vy; dy=y-cy; dyvy = dy*vy; while(w--) { dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; if(policy == SVG_GRADIENT_SPREAD_PAD) { if(dp<0) dp=0; if(dp>NUM_GRADIENT_COLORS-1) dp=NUM_GRADIENT_COLORS-1; } else if(policy == SVG_GRADIENT_SPREAD_REPEAT) { dp&=(NUM_GRADIENT_COLORS-1); } else // SVG_GRADIENT_SPREAD_REFLECT { if(dp&NUM_GRADIENT_COLORS) dp^=(NUM_GRADIENT_COLORS-1); dp&=(NUM_GRADIENT_COLORS-1); } c->colordot(c->surface, x++, y, c->gradient_colors[dp], coverage); }} |
f=vx*vx+vy*vy; | f=(vx*vx+vy*vy); | static void lineargradient(SDL_svg_context *c, void *_span, int y){float cx,cy;float vx,vy;float f;float dx,dy,dyvy;int dp;int policy;int x, w, coverage; x=((FT_Span *)_span)->x; w=((FT_Span *)_span)->len; coverage=((FT_Span *)_span)->coverage; policy = c->gradient_policy; cx=c->gradient_p1.x; cy=c->gradient_p1.y; vx=c->gradient_p2.x - cx; vy=c->gradient_p2.y - cy; f=vx*vx+vy*vy; dy=y-cy; dyvy = dy*vy; while(w--) { dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; if(policy == SVG_GRADIENT_SPREAD_PAD) { if(dp<0) dp=0; if(dp>NUM_GRADIENT_COLORS-1) dp=NUM_GRADIENT_COLORS-1; } else if(policy == SVG_GRADIENT_SPREAD_REPEAT) { dp&=(NUM_GRADIENT_COLORS-1); } else // SVG_GRADIENT_SPREAD_REFLECT { if(dp&NUM_GRADIENT_COLORS) dp^=(NUM_GRADIENT_COLORS-1); dp&=(NUM_GRADIENT_COLORS-1); } c->colordot(c->surface, x++, y, c->gradient_colors[dp], coverage); }} |
dy=y-cy; dyvy = dy*vy; | xp = x + c->e; yp = y + c->f; dx = c->a * xp + c->b * yp - cx; dy = c->c * xp + c->d * yp - cy; | static void lineargradient(SDL_svg_context *c, void *_span, int y){float cx,cy;float vx,vy;float f;float dx,dy,dyvy;int dp;int policy;int x, w, coverage; x=((FT_Span *)_span)->x; w=((FT_Span *)_span)->len; coverage=((FT_Span *)_span)->coverage; policy = c->gradient_policy; cx=c->gradient_p1.x; cy=c->gradient_p1.y; vx=c->gradient_p2.x - cx; vy=c->gradient_p2.y - cy; f=vx*vx+vy*vy; dy=y-cy; dyvy = dy*vy; while(w--) { dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; if(policy == SVG_GRADIENT_SPREAD_PAD) { if(dp<0) dp=0; if(dp>NUM_GRADIENT_COLORS-1) dp=NUM_GRADIENT_COLORS-1; } else if(policy == SVG_GRADIENT_SPREAD_REPEAT) { dp&=(NUM_GRADIENT_COLORS-1); } else // SVG_GRADIENT_SPREAD_REFLECT { if(dp&NUM_GRADIENT_COLORS) dp^=(NUM_GRADIENT_COLORS-1); dp&=(NUM_GRADIENT_COLORS-1); } c->colordot(c->surface, x++, y, c->gradient_colors[dp], coverage); }} |
dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; | dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dy*vy)/f; | static void lineargradient(SDL_svg_context *c, void *_span, int y){float cx,cy;float vx,vy;float f;float dx,dy,dyvy;int dp;int policy;int x, w, coverage; x=((FT_Span *)_span)->x; w=((FT_Span *)_span)->len; coverage=((FT_Span *)_span)->coverage; policy = c->gradient_policy; cx=c->gradient_p1.x; cy=c->gradient_p1.y; vx=c->gradient_p2.x - cx; vy=c->gradient_p2.y - cy; f=vx*vx+vy*vy; dy=y-cy; dyvy = dy*vy; while(w--) { dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; if(policy == SVG_GRADIENT_SPREAD_PAD) { if(dp<0) dp=0; if(dp>NUM_GRADIENT_COLORS-1) dp=NUM_GRADIENT_COLORS-1; } else if(policy == SVG_GRADIENT_SPREAD_REPEAT) { dp&=(NUM_GRADIENT_COLORS-1); } else // SVG_GRADIENT_SPREAD_REFLECT { if(dp&NUM_GRADIENT_COLORS) dp^=(NUM_GRADIENT_COLORS-1); dp&=(NUM_GRADIENT_COLORS-1); } c->colordot(c->surface, x++, y, c->gradient_colors[dp], coverage); }} |
dx+=c->a; dy+=c->c; | static void lineargradient(SDL_svg_context *c, void *_span, int y){float cx,cy;float vx,vy;float f;float dx,dy,dyvy;int dp;int policy;int x, w, coverage; x=((FT_Span *)_span)->x; w=((FT_Span *)_span)->len; coverage=((FT_Span *)_span)->coverage; policy = c->gradient_policy; cx=c->gradient_p1.x; cy=c->gradient_p1.y; vx=c->gradient_p2.x - cx; vy=c->gradient_p2.y - cy; f=vx*vx+vy*vy; dy=y-cy; dyvy = dy*vy; while(w--) { dx = x - cx; dp=(NUM_GRADIENT_COLORS-1) *(dx*vx + dyvy)/f; if(policy == SVG_GRADIENT_SPREAD_PAD) { if(dp<0) dp=0; if(dp>NUM_GRADIENT_COLORS-1) dp=NUM_GRADIENT_COLORS-1; } else if(policy == SVG_GRADIENT_SPREAD_REPEAT) { dp&=(NUM_GRADIENT_COLORS-1); } else // SVG_GRADIENT_SPREAD_REFLECT { if(dp&NUM_GRADIENT_COLORS) dp^=(NUM_GRADIENT_COLORS-1); dp&=(NUM_GRADIENT_COLORS-1); } c->colordot(c->surface, x++, y, c->gradient_colors[dp], coverage); }} |
|
unsigned16 value) | uint16_t value) | ide_controller_write_register(rtems_device_minor_number minor, int reg, unsigned16 value){ IDE_Controller_Table[minor].fns->ctrl_reg_write(minor, reg, value);} |
GEN y; if (!vz) return teich(x); y = (typ(x) == t_PADIC)? gtrunc(x): x; if (divise(y, p)) return gzero; return (GEN)vz[itos(modii(y, p))]; | return (GEN)vz[itos(modii(lift(x), p))]; | quickteich(GEN vz, GEN p, GEN x){ GEN y; if (!vz) return teich(x); y = (typ(x) == t_PADIC)? gtrunc(x): x; if (divise(y, p)) return gzero; return (GEN)vz[itos(modii(y, p))];} |
long j1,k1, tetpil = avma; | long j1,k1; | rowred(GEN a, GEN rmod){ long j,k,pro, c = lg(a), r = lg(a[1]); long av=avma, lim=stack_lim(av,1); GEN q; for (j=1; j<r; j++) { for (k=j+1; k<c; k++) while (signe(gcoeff(a,j,k))) { q=rquot(gcoeff(a,j,j),gcoeff(a,j,k)); pro=(long)mtran((GEN)a[j],(GEN)a[k],q,rmod, j); a[j]=a[k]; a[k]=pro; } if (signe(gcoeff(a,j,j)) < 0) for (k=j; k<r; k++) coeff(a,k,j)=lnegi(gcoeff(a,k,j)); for (k=1; k<j; k++) { q=rquot(gcoeff(a,j,k),gcoeff(a,j,j)); a[k]=(long)mtran((GEN)a[k],(GEN)a[j],q,rmod, k); } if (low_stack(lim, stack_lim(av,1))) { long j1,k1, tetpil = avma; GEN p1 = a; if(DEBUGMEM>1) err(warnmem,"rowred j=%ld", j); p1 = gerepile(av,tetpil,gcopy(a)); for (j1=1; j1<r; j1++) for (k1=1; k1<c; k1++) coeff(a,j1,k1) = coeff(p1,j1,k1); } }} |
p1 = gerepile(av,tetpil,gcopy(a)); | p1 = gerepilecopy(av,a); | rowred(GEN a, GEN rmod){ long j,k,pro, c = lg(a), r = lg(a[1]); long av=avma, lim=stack_lim(av,1); GEN q; for (j=1; j<r; j++) { for (k=j+1; k<c; k++) while (signe(gcoeff(a,j,k))) { q=rquot(gcoeff(a,j,j),gcoeff(a,j,k)); pro=(long)mtran((GEN)a[j],(GEN)a[k],q,rmod, j); a[j]=a[k]; a[k]=pro; } if (signe(gcoeff(a,j,j)) < 0) for (k=j; k<r; k++) coeff(a,k,j)=lnegi(gcoeff(a,k,j)); for (k=1; k<j; k++) { q=rquot(gcoeff(a,j,k),gcoeff(a,j,j)); a[k]=(long)mtran((GEN)a[k],(GEN)a[j],q,rmod, k); } if (low_stack(lim, stack_lim(av,1))) { long j1,k1, tetpil = avma; GEN p1 = a; if(DEBUGMEM>1) err(warnmem,"rowred j=%ld", j); p1 = gerepile(av,tetpil,gcopy(a)); for (j1=1; j1<r; j1++) for (k1=1; k1<c; k1++) coeff(a,j1,k1) = coeff(p1,j1,k1); } }} |