rem
stringlengths
0
83.5k
add
stringlengths
0
223k
context
stringlengths
10
471k
meta
stringlengths
120
236
return 0; /* to remove warning */
Thread _Thread_Idle_body( unsigned32 ignored ){ for( ; ; ) { asm volatile( "mfmsr 3; oris 3,3,4; sync; mtmsr 3; isync; ori 3,3,0; ori 3,3,0" ); }}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/89fcd5caf364cd26be84209ef2b7e1db29bf5638/bspstart.c/clean/c/src/lib/libbsp/powerpc/mpc8260ads/startup/bspstart.c
F->subFB = yes; F->pow = NULL; return 1;
gunclone(F->subFB); F->subFB = gclone(yes); F->pow = NULL; avma = av; return 1;
subFB_increase(FB_t *F, GEN nf, long step){ GEN yes, D = (GEN)nf[3]; long i, iyes, lv = F->KC + 1, minsFB = lg(F->subFB)-1 + step; yes = cgetg(minsFB+1, t_VECSMALL); iyes = 1; for (i = 1; i < lv; i++) { long t = F->perm[i]; if (!ok_subFB(F, t, D)) continue; yes[iyes++] = t; if (iyes > minsFB) break; } if (i == lv) return 0; F->subFB = yes; F->pow = NULL; return 1;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/e9dea2d1eb35d2f95e3e5d7d83fe2a403ce6dd76/buch2.c/clean/src/basemath/buch2.c
F->pow = NULL; avma = av; return 1;
F->newpow = 1; avma = av; return 1;
subFB_change(FB_t *F, GEN nf, GEN L_jid){ GEN yes, D = (GEN)nf[3]; long i, iyes, minsFB, chg = F->sfb_chg, lv = F->KC + 1, l = lg(F->subFB)-1; pari_sp av = avma; switch (chg) { case sfb_INCREASE: minsFB = l + 1; break; default: minsFB = l; break; } if (DEBUGLEVEL) fprintferr("*** Changing sub factor base\n"); yes = cgetg(minsFB+1, t_VECSMALL); iyes = 1; if (L_jid) { for (i = 1; i < lg(L_jid); i++) { long t = L_jid[i]; if (!ok_subFB(F, t, D)) continue; yes[iyes++] = t; if (iyes > minsFB) break; } } else i = 1; if (iyes <= minsFB) { for ( ; i < lv; i++) { long t = F->perm[i]; if (!ok_subFB(F, t, D)) continue; yes[iyes++] = t; if (iyes > minsFB) break; } if (i == lv) return 0; } if (gegal(F->subFB, yes)) { if (chg != sfb_UNSUITABLE) F->sfb_chg = 0; } else { gunclone(F->subFB); F->subFB = gclone(yes); F->sfb_chg = 0; } F->pow = NULL; avma = av; return 1;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
pari_sp ltop, lim; long i,k,lx = lg(x); if (lx == 1) return gen_1; if (lx == 2) return gcopy(gel(x,1)); x = shallowcopy(x); k = lx; ltop=avma; lim = stack_lim(ltop,1); while (k > 2) { if (DEBUGLEVEL>7) fprintferr("prod: remaining objects %ld\n",k-1); lx = k; k = 1; for (i=1; i<lx-1; i+=2) gel(x,k++) = mul(gel(x,i),gel(x,i+1)); if (i < lx) x[k++] = x[i]; if (low_stack(lim,stack_lim(av,1))) gerepilecoeffs(ltop,x+1,k-1); } return gel(x,1);
return divide_conquer_assoc(x, _domul, (void *)mul);
divide_conquer_prod(GEN x, GEN (*mul)(GEN,GEN)){ pari_sp ltop, lim; long i,k,lx = lg(x); if (lx == 1) return gen_1; if (lx == 2) return gcopy(gel(x,1)); x = shallowcopy(x); k = lx; ltop=avma; lim = stack_lim(ltop,1); while (k > 2) { if (DEBUGLEVEL>7) fprintferr("prod: remaining objects %ld\n",k-1); lx = k; k = 1; for (i=1; i<lx-1; i+=2) gel(x,k++) = mul(gel(x,i),gel(x,i+1)); if (i < lx) x[k++] = x[i]; if (low_stack(lim,stack_lim(av,1))) gerepilecoeffs(ltop,x+1,k-1); } return gel(x,1);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d5847452a0a61f4b94c584ee5aed865e7709a077/polarit2.c/clean/src/basemath/polarit2.c
printf( "gettimeofday: %s", ctime( &tv.tv_sec ) );
a_time_t = tv.tv_sec; /* ctime() takes a time_t */ printf( "gettimeofday: %s", ctime( &a_time_t) );
void check_a_tod( rtems_time_of_day *the_tod){ rtems_status_code status; rtems_time_of_day new_tod; time_t a_time_t; struct timeval tv; struct tm *a_tm; int result; int i = 0; print_time( "rtems_clock_set ", the_tod, "\n" ); status = rtems_clock_set( the_tod ); assert( !status ); do { status = rtems_clock_get( RTEMS_CLOCK_GET_TOD, &new_tod ); assert( !status ); print_time( "rtems_clock_get ", &new_tod, "\n" ); /* now do the posix time gets */ result = gettimeofday( &tv, 0 ); assert( result == 0 ); printf( "gettimeofday: %s", ctime( &tv.tv_sec ) ); a_time_t = time( 0 ); printf( "time: %s", ctime( &a_time_t ) ); a_tm = localtime( &a_time_t ); printf( "localtime: %s", asctime( a_tm ) ); a_tm = gmtime( &a_time_t ); printf( "gmtime: %s\n", asctime( a_tm ) ); status = rtems_task_wake_after( 5 * TICKS_PER_SECOND ); i++; } while( i < 6 );}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/bfded728ec4c912f666df94867c118a1004b0165/test.c/clean/testsuites/psxtests/psxtime/test.c
if (k > 0) xp = gmul(xp, gpuigs(p1, k)); else xm = gmul(xm, gpuigs(p1,-k));
if (k > 0) xp = gmul(xp, gpowgs(p1, k)); else xm = gmul(xm, gpowgs(p1,-k));
bnfissunit(GEN bnf,GEN suni,GEN x){ long lB, cH, i, k, ls; gpmem_t tetpil, av = avma; GEN den,gen,S,v,p1,xp,xm,xb,N,HB,perm; bnf = checkbnf(bnf); if (typ(suni)!=t_VEC || lg(suni)!=7) err(typeer,"bnfissunit"); switch (typ(x)) { case t_INT: case t_FRAC: case t_FRACN: case t_POL: case t_COL: x = basistoalg(bnf,x); break; case t_POLMOD: break; default: err(typeer,"bnfissunit"); } if (gcmp0(x)) return cgetg(1,t_COL); S = (GEN) suni[6]; ls=lg(S); if (ls==1) return isunit(bnf,x); p1 = (GEN)suni[2]; perm = (GEN)p1[1]; HB = (GEN)p1[2]; den = (GEN)p1[3]; cH = lg(HB[1]) - 1; lB = lg(HB) - cH; xb = algtobasis(bnf,x); p1 = Q_denom(xb); N = mulii(gnorm(gmul(x,p1)), p1); /* relevant primes divide N */ v = cgetg(ls, t_VECSMALL); for (i=1; i<ls; i++) { GEN P = (GEN)S[i]; v[i] = (resii(N, (GEN)P[1]) == gzero)? element_val(bnf,xb,P): 0; } /* here, x = S v */ p1 = cgetg(ls, t_COL); for (i=1; i<ls; i++) p1[i] = lstoi(v[perm[i]]); /* p1 = v o perm */ v = gmul(HB, p1); for (i=1; i<=cH; i++) { GEN w = gdiv((GEN)v[i], den); if (typ(w) != t_INT) { avma = av; return cgetg(1,t_COL); } v[i] = (long)w; } p1 += cH; p1[0] = evaltyp(t_COL) | evallg(lB); v = concatsp(v, p1); /* append bottom of p1 (= [0 Id] part) */ xp = gun; xm = gun; gen = (GEN)suni[1]; for (i=1; i<ls; i++) { k = -itos((GEN)v[i]); if (!k) continue; p1 = basistoalg(bnf, (GEN)gen[i]); if (k > 0) xp = gmul(xp, gpuigs(p1, k)); else xm = gmul(xm, gpuigs(p1,-k)); } if (xp != gun) x = gmul(x,xp); if (xm != gun) x = gdiv(x,xm); p1 = isunit(bnf,x); if (lg(p1)==1) { avma = av; return cgetg(1,t_COL); } tetpil=avma; return gerepile(av,tetpil,concat(p1,v));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a5e638b286f7f0b1bfa207e5d061bdc61536732e/buch4.c/clean/src/basemath/buch4.c
} else if (rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh))
} else if ((rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh)))
route_output(m, so) register struct mbuf *m; struct socket *so;{ register struct rt_msghdr *rtm = 0; register struct rtentry *rt = 0; struct rtentry *saved_nrt = 0; struct radix_node_head *rnh; struct rt_addrinfo info; int len, error = 0; struct ifnet *ifp = 0; struct ifaddr *ifa = 0;#define senderr(e) { error = e; goto flush;} if (m == 0 || ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == 0)) return (ENOBUFS); if ((m->m_flags & M_PKTHDR) == 0) panic("route_output"); len = m->m_pkthdr.len; if (len < sizeof(*rtm) || len != mtod(m, struct rt_msghdr *)->rtm_msglen) { dst = 0; senderr(EINVAL); } R_Malloc(rtm, struct rt_msghdr *, len); if (rtm == 0) { dst = 0; senderr(ENOBUFS); } m_copydata(m, 0, len, (caddr_t)rtm); if (rtm->rtm_version != RTM_VERSION) { dst = 0; senderr(EPROTONOSUPPORT); } info.rti_addrs = rtm->rtm_addrs; if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { dst = 0; senderr(EINVAL); } if (dst == 0 || (dst->sa_family >= AF_MAX) || (gate != 0 && (gate->sa_family >= AF_MAX))) senderr(EINVAL); if (genmask) { struct radix_node *t; t = rn_addmask((caddr_t)genmask, 0, 1); if (t && Bcmp(genmask, t->rn_key, *(u_char *)genmask) == 0) genmask = (struct sockaddr *)(t->rn_key); else senderr(ENOBUFS); } switch (rtm->rtm_type) { case RTM_ADD: if (gate == 0) senderr(EINVAL); error = rtrequest(RTM_ADD, dst, gate, netmask, rtm->rtm_flags, &saved_nrt); if (error == 0 && saved_nrt) { rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &saved_nrt->rt_rmx); saved_nrt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits); saved_nrt->rt_rmx.rmx_locks |= (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks); saved_nrt->rt_refcnt--; saved_nrt->rt_genmask = genmask; } break; case RTM_DELETE: error = rtrequest(RTM_DELETE, dst, gate, netmask, rtm->rtm_flags, &saved_nrt); if (error == 0) { if ((rt = saved_nrt)) rt->rt_refcnt++; goto report; } break; case RTM_GET: case RTM_CHANGE: case RTM_LOCK: if ((rnh = rt_tables[dst->sa_family]) == 0) { senderr(EAFNOSUPPORT); } else if (rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh)) rt->rt_refcnt++; else senderr(ESRCH); switch(rtm->rtm_type) { case RTM_GET: report: dst = rt_key(rt); gate = rt->rt_gateway; netmask = rt_mask(rt); genmask = rt->rt_genmask; if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { ifp = rt->rt_ifp; if (ifp) { ifpaddr = ifp->if_addrlist->ifa_addr; ifaaddr = rt->rt_ifa->ifa_addr; rtm->rtm_index = ifp->if_index; } else { ifpaddr = 0; ifaaddr = 0; } } len = rt_msg2(rtm->rtm_type, &info, (caddr_t)0, (struct walkarg *)0); if (len > rtm->rtm_msglen) { struct rt_msghdr *new_rtm; R_Malloc(new_rtm, struct rt_msghdr *, len); if (new_rtm == 0) senderr(ENOBUFS); Bcopy(rtm, new_rtm, rtm->rtm_msglen); Free(rtm); rtm = new_rtm; } (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, (struct walkarg *)0); rtm->rtm_flags = rt->rt_flags; rtm->rtm_rmx = rt->rt_rmx; rtm->rtm_addrs = info.rti_addrs; break; case RTM_CHANGE: if (gate && (error = rt_setgate(rt, rt_key(rt), gate))) senderr(error); /* * If they tried to change things but didn't specify * the required gateway, then just use the old one. * This can happen if the user tries to change the * flags on the default route without changing the * default gateway. Changing flags still doesn't work. */ if ((rt->rt_flags & RTF_GATEWAY) && !gate) gate = rt->rt_gateway; /* new gateway could require new ifaddr, ifp; flags may also be different; ifp may be specified by ll sockaddr when protocol address is ambiguous */ if (ifpaddr && (ifa = ifa_ifwithnet(ifpaddr)) && (ifp = ifa->ifa_ifp) && (ifaaddr || gate)) ifa = ifaof_ifpforaddr(ifaaddr ? ifaaddr : gate, ifp); else if ((ifaaddr && (ifa = ifa_ifwithaddr(ifaaddr))) || (gate && (ifa = ifa_ifwithroute(rt->rt_flags, rt_key(rt), gate)))) ifp = ifa->ifa_ifp; if (ifa) { register struct ifaddr *oifa = rt->rt_ifa; if (oifa != ifa) { if (oifa && oifa->ifa_rtrequest) oifa->ifa_rtrequest(RTM_DELETE, rt, gate); IFAFREE(rt->rt_ifa); rt->rt_ifa = ifa; ifa->ifa_refcnt++; rt->rt_ifp = ifp; } } rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &rt->rt_rmx); if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, gate); if (genmask) rt->rt_genmask = genmask; /* * Fall into */ case RTM_LOCK: rt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits); rt->rt_rmx.rmx_locks |= (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks); break; } break; default: senderr(EOPNOTSUPP); }flush: if (rtm) { if (error) rtm->rtm_errno = error; else rtm->rtm_flags |= RTF_DONE; } if (rt) rtfree(rt); { register struct rawcb *rp = 0; /* * Check to see if we don't want our own messages. */ if ((so->so_options & SO_USELOOPBACK) == 0) { if (route_cb.any_count <= 1) { if (rtm) Free(rtm); m_freem(m); return (error); } /* There is another listener, so construct message */ rp = sotorawcb(so); } if (rtm) { m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm); Free(rtm); } if (rp) rp->rcb_proto.sp_family = 0; /* Avoid us */ if (dst) route_proto.sp_protocol = dst->sa_family; raw_input(m, &route_proto, &route_src, &route_dst); if (rp) rp->rcb_proto.sp_family = PF_ROUTE; } return (error);}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/rtsock.c/buggy/c/src/exec/libnetworking/net/rtsock.c
} else if (rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh))
} else if ((rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh)))
rt_msg1 __P((int, struct rt_addrinfo *));static int rt_msg2 __P((int, struct rt_addrinfo *, caddr_t, struct walkarg *));static int rt_xaddrs __P((caddr_t, caddr_t, struct rt_addrinfo *));static int sysctl_dumpentry __P((struct radix_node *rn, void *vw));static int sysctl_iflist __P((int af, struct walkarg *w));static int route_output __P((struct mbuf *, struct socket *));static int route_usrreq __P((struct socket *, int, struct mbuf *, struct mbuf *, struct mbuf *));static void rt_setmetrics __P((u_long, struct rt_metrics *, struct rt_metrics *));/* Sleazy use of local variables throughout file, warning!!!! */#define dst info.rti_info[RTAX_DST]#define gate info.rti_info[RTAX_GATEWAY]#define netmask info.rti_info[RTAX_NETMASK]#define genmask info.rti_info[RTAX_GENMASK]#define ifpaddr info.rti_info[RTAX_IFP]#define ifaaddr info.rti_info[RTAX_IFA]#define brdaddr info.rti_info[RTAX_BRD]/*ARGSUSED*/static introute_usrreq(so, req, m, nam, control) register struct socket *so; int req; struct mbuf *m, *nam, *control;{ register int error = 0; register struct rawcb *rp = sotorawcb(so); int s; if (req == PRU_ATTACH) { MALLOC(rp, struct rawcb *, sizeof(*rp), M_PCB, M_WAITOK); so->so_pcb = (caddr_t)rp; if (so->so_pcb) bzero(so->so_pcb, sizeof(*rp)); } if (req == PRU_DETACH && rp) { int af = rp->rcb_proto.sp_protocol; if (af == AF_INET) route_cb.ip_count--; else if (af == AF_IPX) route_cb.ipx_count--; else if (af == AF_NS) route_cb.ns_count--; else if (af == AF_ISO) route_cb.iso_count--; route_cb.any_count--; } s = splnet(); error = raw_usrreq(so, req, m, nam, control); rp = sotorawcb(so); if (req == PRU_ATTACH && rp) { int af = rp->rcb_proto.sp_protocol; if (error) { free((caddr_t)rp, M_PCB); splx(s); return (error); } if (af == AF_INET) route_cb.ip_count++; else if (af == AF_IPX) route_cb.ipx_count++; else if (af == AF_NS) route_cb.ns_count++; else if (af == AF_ISO) route_cb.iso_count++; rp->rcb_faddr = &route_src; route_cb.any_count++; soisconnected(so); so->so_options |= SO_USELOOPBACK; } splx(s); return (error);}/*ARGSUSED*/static introute_output(m, so) register struct mbuf *m; struct socket *so;{ register struct rt_msghdr *rtm = 0; register struct rtentry *rt = 0; struct rtentry *saved_nrt = 0; struct radix_node_head *rnh; struct rt_addrinfo info; int len, error = 0; struct ifnet *ifp = 0; struct ifaddr *ifa = 0;#define senderr(e) { error = e; goto flush;} if (m == 0 || ((m->m_len < sizeof(long)) && (m = m_pullup(m, sizeof(long))) == 0)) return (ENOBUFS); if ((m->m_flags & M_PKTHDR) == 0) panic("route_output"); len = m->m_pkthdr.len; if (len < sizeof(*rtm) || len != mtod(m, struct rt_msghdr *)->rtm_msglen) { dst = 0; senderr(EINVAL); } R_Malloc(rtm, struct rt_msghdr *, len); if (rtm == 0) { dst = 0; senderr(ENOBUFS); } m_copydata(m, 0, len, (caddr_t)rtm); if (rtm->rtm_version != RTM_VERSION) { dst = 0; senderr(EPROTONOSUPPORT); } info.rti_addrs = rtm->rtm_addrs; if (rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info)) { dst = 0; senderr(EINVAL); } if (dst == 0 || (dst->sa_family >= AF_MAX) || (gate != 0 && (gate->sa_family >= AF_MAX))) senderr(EINVAL); if (genmask) { struct radix_node *t; t = rn_addmask((caddr_t)genmask, 0, 1); if (t && Bcmp(genmask, t->rn_key, *(u_char *)genmask) == 0) genmask = (struct sockaddr *)(t->rn_key); else senderr(ENOBUFS); } switch (rtm->rtm_type) { case RTM_ADD: if (gate == 0) senderr(EINVAL); error = rtrequest(RTM_ADD, dst, gate, netmask, rtm->rtm_flags, &saved_nrt); if (error == 0 && saved_nrt) { rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &saved_nrt->rt_rmx); saved_nrt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits); saved_nrt->rt_rmx.rmx_locks |= (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks); saved_nrt->rt_refcnt--; saved_nrt->rt_genmask = genmask; } break; case RTM_DELETE: error = rtrequest(RTM_DELETE, dst, gate, netmask, rtm->rtm_flags, &saved_nrt); if (error == 0) { if ((rt = saved_nrt)) rt->rt_refcnt++; goto report; } break; case RTM_GET: case RTM_CHANGE: case RTM_LOCK: if ((rnh = rt_tables[dst->sa_family]) == 0) { senderr(EAFNOSUPPORT); } else if (rt = (struct rtentry *) rnh->rnh_lookup(dst, netmask, rnh)) rt->rt_refcnt++; else senderr(ESRCH); switch(rtm->rtm_type) { case RTM_GET: report: dst = rt_key(rt); gate = rt->rt_gateway; netmask = rt_mask(rt); genmask = rt->rt_genmask; if (rtm->rtm_addrs & (RTA_IFP | RTA_IFA)) { ifp = rt->rt_ifp; if (ifp) { ifpaddr = ifp->if_addrlist->ifa_addr; ifaaddr = rt->rt_ifa->ifa_addr; rtm->rtm_index = ifp->if_index; } else { ifpaddr = 0; ifaaddr = 0; } } len = rt_msg2(rtm->rtm_type, &info, (caddr_t)0, (struct walkarg *)0); if (len > rtm->rtm_msglen) { struct rt_msghdr *new_rtm; R_Malloc(new_rtm, struct rt_msghdr *, len); if (new_rtm == 0) senderr(ENOBUFS); Bcopy(rtm, new_rtm, rtm->rtm_msglen); Free(rtm); rtm = new_rtm; } (void)rt_msg2(rtm->rtm_type, &info, (caddr_t)rtm, (struct walkarg *)0); rtm->rtm_flags = rt->rt_flags; rtm->rtm_rmx = rt->rt_rmx; rtm->rtm_addrs = info.rti_addrs; break; case RTM_CHANGE: if (gate && (error = rt_setgate(rt, rt_key(rt), gate))) senderr(error); /* * If they tried to change things but didn't specify * the required gateway, then just use the old one. * This can happen if the user tries to change the * flags on the default route without changing the * default gateway. Changing flags still doesn't work. */ if ((rt->rt_flags & RTF_GATEWAY) && !gate) gate = rt->rt_gateway; /* new gateway could require new ifaddr, ifp; flags may also be different; ifp may be specified by ll sockaddr when protocol address is ambiguous */ if (ifpaddr && (ifa = ifa_ifwithnet(ifpaddr)) && (ifp = ifa->ifa_ifp) && (ifaaddr || gate)) ifa = ifaof_ifpforaddr(ifaaddr ? ifaaddr : gate, ifp); else if ((ifaaddr && (ifa = ifa_ifwithaddr(ifaaddr))) || (gate && (ifa = ifa_ifwithroute(rt->rt_flags, rt_key(rt), gate)))) ifp = ifa->ifa_ifp; if (ifa) { register struct ifaddr *oifa = rt->rt_ifa; if (oifa != ifa) { if (oifa && oifa->ifa_rtrequest) oifa->ifa_rtrequest(RTM_DELETE, rt, gate); IFAFREE(rt->rt_ifa); rt->rt_ifa = ifa; ifa->ifa_refcnt++; rt->rt_ifp = ifp; } } rt_setmetrics(rtm->rtm_inits, &rtm->rtm_rmx, &rt->rt_rmx); if (rt->rt_ifa && rt->rt_ifa->ifa_rtrequest) rt->rt_ifa->ifa_rtrequest(RTM_ADD, rt, gate); if (genmask) rt->rt_genmask = genmask; /* * Fall into */ case RTM_LOCK: rt->rt_rmx.rmx_locks &= ~(rtm->rtm_inits); rt->rt_rmx.rmx_locks |= (rtm->rtm_inits & rtm->rtm_rmx.rmx_locks); break; } break; default: senderr(EOPNOTSUPP); }flush: if (rtm) { if (error) rtm->rtm_errno = error; else rtm->rtm_flags |= RTF_DONE; } if (rt) rtfree(rt); { register struct rawcb *rp = 0; /* * Check to see if we don't want our own messages. */ if ((so->so_options & SO_USELOOPBACK) == 0) { if (route_cb.any_count <= 1) { if (rtm) Free(rtm); m_freem(m); return (error); } /* There is another listener, so construct message */ rp = sotorawcb(so); } if (rtm) { m_copyback(m, 0, rtm->rtm_msglen, (caddr_t)rtm); Free(rtm); } if (rp) rp->rcb_proto.sp_family = 0; /* Avoid us */ if (dst) route_proto.sp_protocol = dst->sa_family; raw_input(m, &route_proto, &route_src, &route_dst); if (rp) rp->rcb_proto.sp_family = PF_ROUTE; } return (error);}static voidrt_setmetrics(which, in, out) u_long which; register struct rt_metrics *in, *out;{#define metric(f, e) if (which & (f)) out->e = in->e; metric(RTV_RPIPE, rmx_recvpipe); metric(RTV_SPIPE, rmx_sendpipe); metric(RTV_SSTHRESH, rmx_ssthresh); metric(RTV_RTT, rmx_rtt); metric(RTV_RTTVAR, rmx_rttvar); metric(RTV_HOPCOUNT, rmx_hopcount); metric(RTV_MTU, rmx_mtu); metric(RTV_EXPIRE, rmx_expire);#undef metric}#define ROUNDUP(a) \ ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) : sizeof(long))#define ADVANCE(x, n) (x += ROUNDUP((n)->sa_len))/* * Extract the addresses of the passed sockaddrs. * Do a little sanity checking so as to avoid bad memory references. * This data is derived straight from userland. */static intrt_xaddrs(cp, cplim, rtinfo) register caddr_t cp, cplim; register struct rt_addrinfo *rtinfo;{ register struct sockaddr *sa; register int i; bzero(rtinfo->rti_info, sizeof(rtinfo->rti_info)); for (i = 0; (i < RTAX_MAX) && (cp < cplim); i++) { if ((rtinfo->rti_addrs & (1 << i)) == 0) continue; sa = (struct sockaddr *)cp; /* * It won't fit. */ if ( (cp + sa->sa_len) > cplim ) { return (EINVAL); } /* * there are no more.. quit now * If there are more bits, they are in error. * I've seen this. route(1) can evidently generate these. * This causes kernel to core dump. * for compatibility, If we see this, point to a safe address. */ if (sa->sa_len == 0) { rtinfo->rti_info[i] = &sa_zero; return (0); /* should be EINVAL but for compat */ } /* accept it */ rtinfo->rti_info[i] = sa; ADVANCE(cp, sa); } return (0);}static struct mbuf *rt_msg1(type, rtinfo) int type; register struct rt_addrinfo *rtinfo;{ register struct rt_msghdr *rtm; register struct mbuf *m; register int i; register struct sockaddr *sa; int len, dlen; m = m_gethdr(M_DONTWAIT, MT_DATA); if (m == 0) return (m); switch (type) { case RTM_DELADDR: case RTM_NEWADDR: len = sizeof(struct ifa_msghdr); break; case RTM_IFINFO: len = sizeof(struct if_msghdr); break; default: len = sizeof(struct rt_msghdr); } if (len > MHLEN) panic("rt_msg1"); m->m_pkthdr.len = m->m_len = len; m->m_pkthdr.rcvif = 0; rtm = mtod(m, struct rt_msghdr *); bzero((caddr_t)rtm, len); for (i = 0; i < RTAX_MAX; i++) { if ((sa = rtinfo->rti_info[i]) == NULL) continue; rtinfo->rti_addrs |= (1 << i); dlen = ROUNDUP(sa->sa_len); m_copyback(m, len, dlen, (caddr_t)sa); len += dlen; } if (m->m_pkthdr.len != len) { m_freem(m); return (NULL); } rtm->rtm_msglen = len; rtm->rtm_version = RTM_VERSION; rtm->rtm_type = type; return (m);}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/rtsock.c/buggy/c/src/exec/libnetworking/net/rtsock.c
S = init_pow_q_mod_pT(X, q, u, T, p);
S = init_spec_FqXQ_pow(X, q, u, T, p);
FqX_sqf_split(GEN *t0, GEN q, GEN T, GEN p){ GEN *t = t0, u = *t, v, S, g, X; long d, dg, N = degpol(u); if (N == 1) return 1; v = X = polx[varn(u)]; S = init_pow_q_mod_pT(X, q, u, T, p); for (d=1; d <= N>>1; d++) { v = spec_FqXQ_pow(v, S, T, p); g = FqX_gcd(gsub(v,X),u, T,p); dg = degpol(g); if (dg <= 0) continue; /* all factors of g have degree d */ *t = g; FqX_split(t, d, q, S, T, p); t += dg / d; N -= dg; if (N) { u = FqX_div(u,g, T,p); v = FqX_rem(v,u, T,p); } } if (N) *t++ = u; return t - t0;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0653bf4e80ffba66b9dad8b9b9bf38de88f14841/polarit1.c/clean/src/basemath/polarit1.c
rtems_unsigned32 real_trap;
uint32_t real_trap;
rtems_isr bsp_spurious_handler( rtems_vector_number trap, CPU_Interrupt_frame *isf){ char line[ 80 ]; rtems_unsigned32 real_trap; real_trap = SPARC_REAL_TRAP_NUMBER(trap); strcpy(line, "Unexpected trap (0x ) at address 0x "); line[ 19 ] = digits[ real_trap >> 4 ]; line[ 20 ] = digits[ real_trap & 0xf ]; itos(isf->tpc, &line[36]); DEBUG_puts( line ); switch (real_trap) { /* * First the ones defined by the basic architecture */ case 0x00: DEBUG_puts( "reset" ); break; case 0x01: DEBUG_puts( "instruction access exception" ); break; case 0x02: DEBUG_puts( "illegal instruction" ); break; case 0x03: DEBUG_puts( "privileged instruction" ); break; case 0x04: DEBUG_puts( "fp disabled" ); break; case 0x07: DEBUG_puts( "memory address not aligned" ); break; case 0x08: DEBUG_puts( "fp exception" ); break; case 0x09: strcpy(line, "data access exception at 0x " ); itos(ERC32_MEC.First_Failing_Address, &line[27]); DEBUG_puts( line ); break; case 0x0A: DEBUG_puts( "tag overflow" ); break; /* * Then the ones defined by the ERC32 in particular */ case ERC32_TRAP_TYPE( ERC32_INTERRUPT_MASKED_ERRORS ): DEBUG_puts( "ERC32_INTERRUPT_MASKED_ERRORS" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_1 ): DEBUG_puts( "ERC32_INTERRUPT_EXTERNAL_1" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_2 ): DEBUG_puts( "ERC32_INTERRUPT_EXTERNAL_2" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_A_RX_TX ): DEBUG_puts( "ERC32_INTERRUPT_UART_A_RX_TX" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_B_RX_TX ): DEBUG_puts( "ERC32_INTERRUPT_UART_A_RX_TX" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_CORRECTABLE_MEMORY_ERROR ): DEBUG_puts( "ERC32_INTERRUPT_CORRECTABLE_MEMORY_ERROR" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_UART_ERROR ): DEBUG_puts( "ERC32_INTERRUPT_UART_ERROR" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_DMA_ACCESS_ERROR ): DEBUG_puts( "ERC32_INTERRUPT_DMA_ACCESS_ERROR" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_DMA_TIMEOUT ): DEBUG_puts( "ERC32_INTERRUPT_DMA_TIMEOUT" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_3 ): DEBUG_puts( "ERC32_INTERRUPT_EXTERNAL_3" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_4 ): DEBUG_puts( "ERC32_INTERRUPT_EXTERNAL_4" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_GENERAL_PURPOSE_TIMER ): DEBUG_puts( "ERC32_INTERRUPT_GENERAL_PURPOSE_TIMER" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_REAL_TIME_CLOCK ): DEBUG_puts( "ERC32_INTERRUPT_REAL_TIME_CLOCK" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_EXTERNAL_5 ): DEBUG_puts( "ERC32_INTERRUPT_EXTERNAL_5" ); break; case ERC32_TRAP_TYPE( ERC32_INTERRUPT_WATCHDOG_TIMEOUT ): DEBUG_puts( "ERC32_INTERRUPT_WATCHDOG_TIMEOUT" ); break; default: break; } /* * What else can we do but stop ... */ asm volatile( "mov 1, %g1; ta 0x0" );}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/1be1e913564b73bf50ce1aa58c003e564ddae83a/spurious.c/clean/c/src/lib/libbsp/sparc/erc32/startup/spurious.c
rtems_unsigned32 trap; unsigned32 level = 15; unsigned32 mask;
uint32_t trap; uint32_t level = 15; uint32_t mask;
void bsp_spurious_initialize(){ rtems_unsigned32 trap; unsigned32 level = 15; unsigned32 mask; sparc_disable_interrupts(level); mask = ERC32_MEC.Interrupt_Mask; for ( trap=0 ; trap<256 ; trap++ ) { /* * Skip window overflow, underflow, and flush as well as software * trap 0 which we will use as a shutdown. Also avoid trap 0x70 - 0x7f * which cannot happen and where some of the space is used to pass * paramaters to the program. */ if (( trap == 5 || trap == 6 ) || (( trap >= 0x11 ) && ( trap <= 0x1f )) || (( trap >= 0x70 ) && ( trap <= 0x83 ))) continue; set_vector( (rtems_isr_entry) bsp_spurious_handler, SPARC_SYNCHRONOUS_TRAP( trap ), 1 ); } ERC32_MEC.Interrupt_Mask = mask; sparc_enable_interrupts(level);}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/1be1e913564b73bf50ce1aa58c003e564ddae83a/spurious.c/clean/c/src/lib/libbsp/sparc/erc32/startup/spurious.c
else vmeUniverse0PciIrqLine = irqline;
vmeUniverseFindPciBase( int instance, volatile LERegister **pbase ){int bus,dev,fun;pci_ulong busaddr;unsigned char irqline; if (BSP_PCI_FIND_DEVICE( PCI_VENDOR_TUNDRA, PCI_DEVICE_UNIVERSEII, instance, &bus, &dev, &fun)) return -1; if (BSP_PCI_CONFIG_IN_LONG(bus,dev,fun,PCI_UNIVERSE_BASE0,&busaddr)) return -1; if ((unsigned long)(busaddr) & 1) { /* it's IO space, try BASE1 */ if (BSP_PCI_CONFIG_IN_LONG(bus,dev,fun,PCI_UNIVERSE_BASE1,&busaddr) || ((unsigned long)(busaddr) & 1)) return -1; } *pbase=(volatile LERegister*)PCI_TO_LOCAL_ADDR(busaddr); if (BSP_PCI_CONFIG_IN_BYTE(bus,dev,fun,PCI_INTERRUPT_LINE,&irqline)) return -1; else vmeUniverse0PciIrqLine = irqline; return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/784e792a04c600b79d535ad81a5ba32b4f4de33e/vmeUniverse.c/clean/c/src/lib/libbsp/shared/vmeUniverse/vmeUniverse.c
return 0;
/* Enable PCI master and memory access */ BSP_PCI_CONFIG_IN_SHORT(bus, dev, fun, PCI_COMMAND, &wrd); BSP_PCI_CONFIG_OUT_SHORT(bus, dev, fun, PCI_COMMAND, wrd | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); return irqline;
vmeUniverseFindPciBase( int instance, volatile LERegister **pbase ){int bus,dev,fun;pci_ulong busaddr;unsigned char irqline; if (BSP_PCI_FIND_DEVICE( PCI_VENDOR_TUNDRA, PCI_DEVICE_UNIVERSEII, instance, &bus, &dev, &fun)) return -1; if (BSP_PCI_CONFIG_IN_LONG(bus,dev,fun,PCI_UNIVERSE_BASE0,&busaddr)) return -1; if ((unsigned long)(busaddr) & 1) { /* it's IO space, try BASE1 */ if (BSP_PCI_CONFIG_IN_LONG(bus,dev,fun,PCI_UNIVERSE_BASE1,&busaddr) || ((unsigned long)(busaddr) & 1)) return -1; } *pbase=(volatile LERegister*)PCI_TO_LOCAL_ADDR(busaddr); if (BSP_PCI_CONFIG_IN_BYTE(bus,dev,fun,PCI_INTERRUPT_LINE,&irqline)) return -1; else vmeUniverse0PciIrqLine = irqline; return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/784e792a04c600b79d535ad81a5ba32b4f4de33e/vmeUniverse.c/clean/c/src/lib/libbsp/shared/vmeUniverse/vmeUniverse.c
uprintf(f,"%s %s %s %s",
uprintf(f,"%s %s %s %s",
showUniversePort( int ismaster, int portno, volatile LERegister *preg, void *parm){ FILE *f=parm ? (FILE *)parm : stdout; unsigned long cntrl, start, bound, offst, mask; cntrl = READ_LE0(preg++);#undef TSILL#ifdef TSILL uprintf(stderr,"showUniversePort: *(0x%08x): 0x%08x\n",preg-1,cntrl);#endif#undef TSILL /* skip this port if disabled */ if (!(cntrl & (ismaster ? UNIV_MCTL_EN : UNIV_SCTL_EN))) return 0; /* for the master `start' is the PCI address, * for the slave `start' is the VME address */ mask = ~PORT_UNALIGNED(0xffffffff,portno); start = READ_LE0(preg++)&mask; bound = READ_LE0(preg++)&mask; offst = READ_LE0(preg++)&mask; offst+=start; /* calc start on the other bus */ if (ismaster) { uprintf(f,"%d: 0x%08lx 0x%08lx 0x%08lx ", portno,offst,bound-start,start); } else { uprintf(f,"%d: 0x%08lx 0x%08lx 0x%08lx ", portno,start,bound-start,offst); } switch (cntrl & UNIV_CTL_VAS) { case UNIV_CTL_VAS16: uprintf(f,"A16, "); break; case UNIV_CTL_VAS24: uprintf(f,"A24, "); break; case UNIV_CTL_VAS32: uprintf(f,"A32, "); break; default: uprintf(f,"A??, "); break; } if (ismaster) { uprintf(f,"%s, %s", cntrl&UNIV_MCTL_PGM ? "Pgm" : "Dat", cntrl&UNIV_MCTL_SUPER ? "Sup" : "Usr"); } else { uprintf(f,"%s %s %s %s", cntrl&UNIV_SCTL_PGM ? "Pgm," : " ", cntrl&UNIV_SCTL_DAT ? "Dat," : " ", cntrl&UNIV_SCTL_SUPER ? "Sup," : " ", cntrl&UNIV_SCTL_USER ? "Usr" : ""); } uprintf(f,"\n"); return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/784e792a04c600b79d535ad81a5ba32b4f4de33e/vmeUniverse.c/clean/c/src/lib/libbsp/shared/vmeUniverse/vmeUniverse.c
if (!vmeUniverse0BaseAddr && vmeUniverseInit()) return -1; if ((local_addr & 7) != (vme_addr & 7)) { uprintf(stderr,"vmeUniverseStartDMA: misaligned addresses\n"); return -1; } { /* help the compiler allocate registers */ register volatile LERegister *b=vmeUniverse0BaseAddr; register unsigned long dgcsoff=UNIV_REGOFF_DGCS,dgcs; dgcs=READ_LE(b, dgcsoff); /* clear status and make sure CHAIN is clear */ dgcs &= ~UNIV_DGCS_CHAIN; WRITE_LE(dgcs, b, dgcsoff); WRITE_LE(local_addr, b, UNIV_REGOFF_DLA); WRITE_LE(vme_addr, b, UNIV_REGOFF_DVA); WRITE_LE(count, b, UNIV_REGOFF_DTBC); dgcs |= UNIV_DGCS_GO; EIEIO_REG; /* make sure GO is written after everything else */ WRITE_LE(dgcs, b, dgcsoff); } SYNC; /* enforce command completion */ return 0;
DFLT_BASE; /* vmeUniverseStartDMAXX doesn't check for a valid base address for efficiency reasons */ return vmeUniverseStartDMAXX(base, local_addr, vme_addr, count);
vmeUniverseStartDMA( unsigned long local_addr, unsigned long vme_addr, unsigned long count){ if (!vmeUniverse0BaseAddr && vmeUniverseInit()) return -1; if ((local_addr & 7) != (vme_addr & 7)) { uprintf(stderr,"vmeUniverseStartDMA: misaligned addresses\n"); return -1; } { /* help the compiler allocate registers */ register volatile LERegister *b=vmeUniverse0BaseAddr; register unsigned long dgcsoff=UNIV_REGOFF_DGCS,dgcs; dgcs=READ_LE(b, dgcsoff); /* clear status and make sure CHAIN is clear */ dgcs &= ~UNIV_DGCS_CHAIN; WRITE_LE(dgcs, b, dgcsoff); WRITE_LE(local_addr, b, UNIV_REGOFF_DLA); WRITE_LE(vme_addr, b, UNIV_REGOFF_DVA); WRITE_LE(count, b, UNIV_REGOFF_DTBC); dgcs |= UNIV_DGCS_GO; EIEIO_REG; /* make sure GO is written after everything else */ WRITE_LE(dgcs, b, dgcsoff); } SYNC; /* enforce command completion */ return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/784e792a04c600b79d535ad81a5ba32b4f4de33e/vmeUniverse.c/clean/c/src/lib/libbsp/shared/vmeUniverse/vmeUniverse.c
: "=r"(p) : "r"(p) : "r0"
: "=r"(p) : "0"(p) : "r0"
vmeUniverseCvtToLE(unsigned long *ptr, unsigned long num){#if !defined(__LITTLE_ENDIAN__) || (__LITTLE_ENDIAN__ != 1)register unsigned long *p=ptr+num; while (p > ptr) {#if (defined(_ARCH_PPC) || defined(__PPC__) || defined(__PPC)) && (__BIG_ENDIAN__ == 1) __asm__ __volatile__( "lwzu 0, -4(%0)\n" "stwbrx 0, 0, %0\n" : "=r"(p) : "r"(p) : "r0" );#elif defined(__rtems__) p--; st_le32(p, *p);#else#error "vmeUniverse: endian conversion not implemented for this architecture"#endif }#endif}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/784e792a04c600b79d535ad81a5ba32b4f4de33e/vmeUniverse.c/clean/c/src/lib/libbsp/shared/vmeUniverse/vmeUniverse.c
GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]);
GEN y, a, cx, xZ; long N = degpol(nf[1]);
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); pari_sp av, tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gen_1; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { cx = gerepilecopy(av,cx); gel(y,1) = cx; gel(y,2) = gscalcol_i(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++; } if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); }END: a = centermod(a, xZ); tetpil = avma; gel(y,1) = gmul(xZ,cx); gel(y,2) = gmul(a, cx); gerepilecoeffssp(av,tetpil,y+1,2); return y;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; }
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); pari_sp av, tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gen_1; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { cx = gerepilecopy(av,cx); gel(y,1) = cx; gel(y,2) = gscalcol_i(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++; } if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); }END: a = centermod(a, xZ); tetpil = avma; gel(y,1) = gmul(xZ,cx); gel(y,2) = gmul(a, cx); gerepilecoeffssp(av,tetpil,y+1,2); return y;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++)
if (N < 6) a = get_random_a(nf, x, xZ); else
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); pari_sp av, tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gen_1; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { cx = gerepilecopy(av,cx); gel(y,1) = cx; gel(y,2) = gscalcol_i(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++; } if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); }END: a = centermod(a, xZ); tetpil = avma; gel(y,1) = gmul(xZ,cx); gel(y,2) = gmul(a, cx); gerepilecoeffssp(av,tetpil,y+1,2); return y;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++;
const long lim = 47; GEN a1, fa = auxdecomp(xZ, lim), P = gel(fa,1), E = gel(fa,2); long l = lg(P)-1; a1 = powgi(gel(P, l), gel(E, l)); if (cmpis(a1, lim) <= 0) a = idealapprfact_i(nf, idealfactor(nf,x), 1); else if (equalii(xZ, a1)) a = get_random_a(nf, x, xZ); else { GEN A0, A1, a0, u0, u1, v0, v1, pi0, pi1, t, u; a0 = diviiexact(xZ, a1); A0 = hnfmodid(x, a0); /* smooth part of x */ A1 = hnfmodid(x, a1); /* cofactor */ pi0 = idealapprfact_i(nf, idealfactor(nf,A0), 1); pi1 = get_random_a(nf, A1, a1); (void)bezout(a0, a1, &v0,&v1); u0 = gmul(a0, v0); u1 = gmul(a1, v1); t = gmul(pi0, u1); gel(t,1) = gadd(gel(t,1), u0); u = gmul(pi1, u0); gel(u,1) = gadd(gel(u,1), u1); a = element_muli(nf, centermod(u, xZ), centermod(t, xZ)); }
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); pari_sp av, tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gen_1; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { cx = gerepilecopy(av,cx); gel(y,1) = cx; gel(y,2) = gscalcol_i(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++; } if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); }END: a = centermod(a, xZ); tetpil = avma; gel(y,1) = gmul(xZ,cx); gel(y,2) = gmul(a, cx); gerepilecoeffssp(av,tetpil,y+1,2); return y;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); } END:
mat_ideal_two_elt(GEN nf, GEN x){ GEN y,a,beta,cx,xZ,mul; long i,lm, N = degpol(nf[1]); pari_sp av, tetpil; y = cgetg(3,t_VEC); av = avma; if (lg(x[1]) != N+1) err(typeer,"ideal_two_elt"); if (N == 2) { gel(y,1) = gcopy(gcoeff(x,1,1)); gel(y,2) = gcopy(gel(x,2)); return y; } x = Q_primitive_part(x, &cx); if (!cx) cx = gen_1; if (lg(x) != N+1) x = idealhermite_aux(nf,x); xZ = gcoeff(x,1,1); if (gcmp1(xZ)) { cx = gerepilecopy(av,cx); gel(y,1) = cx; gel(y,2) = gscalcol_i(cx, N); return y; } a = NULL; /* gcc -Wall */ beta= cgetg(N+1, t_VEC); mul = cgetg(N+1, t_VEC); lm = 1; /* = lg(mul) */ /* look for a in x such that a O/xZ = x O/xZ */ for (i=2; i<=N; i++) { pari_sp av1 = avma; GEN t, y = eltmul_get_table(nf, gel(x,i)); t = FpM_red(y, xZ); if (gcmp0(t)) { avma = av1; continue; } if (ok_elt(x,xZ, t)) { a = gel(x,i); break; } beta[lm]= x[i]; /* mul[i] = { canonical generators for x[i] O/xZ as Z-module } */ gel(mul,lm) = t; lm++; } if (i > N) { GEN z = cgetg(lm, t_VECSMALL); pari_sp av1; ulong c = 0; setlg(mul, lm); setlg(beta,lm); if (DEBUGLEVEL>3) fprintferr("ideal_two_elt, hard case:\n"); for(av1=avma;;avma=av1) { if (++c == 100) { if (DEBUGLEVEL>3) fprintferr("using approximation theorem\n"); a = mat_ideal_two_elt2(nf, x, xZ); goto END; } for (a=NULL,i=1; i<lm; i++) { long t = random_bits(4) - 7; /* in [-7,8] */ z[i] = t; a = addmul_mat(a, t, gel(mul,i)); } /* a = matrix (NOT HNF) of ideal generated by beta.z in O/xZ */ if (a && ok_elt(x,xZ, a)) break; } for (a=NULL,i=1; i<lm; i++) a = addmul_col(a, z[i], gel(beta,i)); }END: a = centermod(a, xZ); tetpil = avma; gel(y,1) = gmul(xZ,cx); gel(y,2) = gmul(a, cx); gerepilecoeffssp(av,tetpil,y+1,2); return y;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
y=gun; ms=gneg_i(s); p1=cgetr(prec+1);
y=gun; ms=gneg_i(s); p1=cgetr(prec+1); p2=gun;
czeta(GEN s, long prec){ long av,n,p,n1,l,flag1,flag2,flag3,i,i2; double st,sp,sn,ssig,ns,alpha,beta,maxbeta,xinf; GEN y,z,res,sig,ms,p1,p2,p3,p31,pitemp; l=precision(s); if (typ(s)==t_COMPLEX) { if (!l) l=prec; res=cgetg(3,t_COMPLEX); res[1]=lgetr(l); res[2]=lgetr(l); av=avma; p1=cgetg(3,t_COMPLEX); p1[1]=lgetr(l+1); p1[2]=lgetr(l+1); gaffect(s,p1); s=p1; sig=(GEN)s[1]; } else { res = cgetr(l); av=avma; p1=cgetr(l+1); affrr(s,p1); sig=s=p1; } if (signe(sig)>0 && expo(sig)>-2) flag1 = 0; else { if (gcmp0(gimag(s)) && gcmp0(gfrac(gmul2n(sig,-1)))) { if (gcmp0(sig)) gaffect(gneg_i(ghalf),res); else gaffsg(0,res); avma=av; return res; } flag1=1; s=gsub(gun,s); sig=greal(s); } ssig=rtodbl(sig); st=fabs(rtodbl(gimag(s))); maxbeta = pow(3.0,-2.5); if (st) { ns = ssig*ssig + st*st; alpha=pariC2*(prec-2)-0.39-0.5*(ssig-1.0)*log(ns)-log(ssig)+ssig*2*pariC1; beta=(alpha+ssig)/st-atan(ssig/st); if (beta<=0) { if (ssig>=1.0) { p=0; sn=sqrt(ns); n=(long)(ceil(exp(pariC2*(prec-2)/ssig)*pow(sn/(2*ssig),1.0/ssig))); } else { p=1; sn=ssig+1; n=(long)ceil(sqrt(sn*sn+st*st)/(2*PI)); } } else { if (beta<maxbeta) xinf=beta+pow(3*beta,1.0/3.0); else { double eps=0.0087, x00 = beta+PI/2.0, y00,x11; for(;;) { y00=x00*x00; x11=(beta+atan(x00))*(1+y00)/y00-1/x00; if (x00-x11 < eps) break; x00 = x11; } xinf=x11; } sp=1.0-ssig+st*xinf; if (sp>0) { p=(long)ceil(sp/2.0); sn=ssig+2*p-1; n=(long)ceil(sqrt(sn*sn+st*st)/(2*PI)); } else { p=0; sn=sqrt(ns); n=(long)ceil(exp(pariC2*(prec-2)/ssig)*pow(sn/(2*ssig),1.0/ssig)); } } } else { beta=pariC2*(prec-2)+0.61+ssig*2*pariC1-ssig*log(ssig); if (beta>0) { p=(long)ceil(beta/2.0); sn=ssig+2*p-1; n=(long)ceil(sqrt(sn*sn+st*st)/(2*PI)); } else { p=0; sn=sqrt(ssig*ssig+st*st); n=(long)ceil(exp(pariC2*(prec-2)/ssig)*pow(sn/(2*ssig),1.0/ssig)); } } if (n < 46340) { flag2=1; n1=n*n; } else flag2=0; y=gun; ms=gneg_i(s); p1=cgetr(prec+1); for (i=2; i<=n; i++) { affsr(i,p1); p2 = gexp(gmul(ms,mplog(p1)), prec+1); y = gadd(y,p2); } flag3 = (2*p < 46340); mpbern(p,prec+1); p31=cgetr(prec+1); z=gzero; for (i=p; i>=1; i--) { i2=i<<1; p1=gmul(gaddsg(i2-1,s),gaddsg(i2,s)); p1=flag3? gdivgs(p1,i2*(i2+1)): gdivgs(gdivgs(p1,i2),i2+1); p1=flag2? gdivgs(p1,n1): gdivgs(gdivgs(p1,n),n); p3 = bern(i); if (bernzone[2]>prec+1) { affrr(p3,p31); p3=p31; } z=gadd(divrs(p3,i),gmul(p1,z)); } p1=gsub(gdivsg(n,gsubgs(s,1)),ghalf); z=gmul(gadd(p1,gmul(s,gdivgs(z,n<<1))),p2); y = gadd(y,z); if (flag1) { pitemp=mppi(prec+1); setexpo(pitemp,2); y=gmul(gmul(y,ggamma(s,prec+1)),gpui(pitemp,ms,prec+1)); setexpo(pitemp,0); y=gmul2n(gmul(y,gcos(gmul(pitemp,s),prec+1)),1); } gaffect(y,res); avma=av; return res;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88886e5d9c3a9681343a9c35e7d0ffe1e3588045/trans3.c/buggy/src/basemath/trans3.c
if (typ(x) != t_MAT) err(typeer,"minim0");
if (typ(a) != t_MAT) err(typeer,"minim0");
minim0(GEN a, GEN BORNE, GEN STOCKMAX, long flag){ GEN x,res,p1,u,r,L,gnorme,invp,V; long n = lg(a), i, j, k, s, maxrank; pari_sp av0 = avma, av1, av, lim; double p,maxnorm,BOUND,*v,*y,*z,**q, eps = 0.000001; BORNE = gfloor(BORNE); if (typ(BORNE) != t_INT || typ(STOCKMAX) != t_INT) err(typeer, "minim0"); if (typ(x) != t_MAT) err(typeer,"minim0"); maxrank = 0; res = V = invp = NULL; /* gcc -Wall */ switch(flag) { case min_FIRST: if (gcmp0(BORNE)) err(talker,"bound = 0 in minim2"); res = cgetg(3,t_VEC); break; case min_ALL: res = cgetg(4,t_VEC); break; case min_PERF: break; case min_VECSMALL: case min_VECSMALL2: maxrank = itos(BORNE); if (maxrank <= 0) return cgetg(1, t_VECSMALL); res = const_vecsmall(maxrank, 0); if (flag == min_VECSMALL2) BORNE = shifti(BORNE,1); if (gcmp0(BORNE)) return res; break; default: err(talker, "incorrect flag in minim0"); } if (n == 1) { switch(flag) { case min_FIRST: avma=av0; return cgetg(1,t_VEC); case min_VECSMALL: case min_VECSMALL2: return res; case min_PERF: avma=av0; return gen_0; } gel(res,1) = gel(res,2) = gen_0; gel(res,3) = cgetg(1,t_MAT); return res; } av = avma; minim_alloc(n, &q, &x, &y, &z, &v); av1 = avma; u = lllgramint(a); if (lg(u) != n) err(talker,"not a definite form in minim0"); a = qf_base_change(a,u,1); n--; a = mat_to_MP(a, DEFAULTPREC); r = sqred1(a); for (j=1; j<=n; j++) { v[j] = rtodbl(gcoeff(r,j,j)); for (i=1; i<j; i++) q[i][j] = rtodbl(gcoeff(r,i,j)); } if (flag==min_PERF || gcmp0(BORNE)) { double c, b = rtodbl(gcoeff(a,1,1)); for (i=2; i<=n; i++) { c = rtodbl(gcoeff(a,i,i)); if (c < b) b = c; } BOUND = b+eps; BORNE = ground(dbltor(BOUND)); maxnorm = -1.; /* don't update maxnorm */ } else { BOUND = gtodouble(BORNE)+eps; maxnorm = 0.; } switch(flag) { case min_ALL: maxrank = itos(STOCKMAX); if (maxrank < 0) err(talker,"negative number of vectors in minim0"); L = new_chunk(1+maxrank); break; case min_PERF: BORNE = gerepileupto(av1,BORNE); maxrank = (n*(n+1)) >> 1; L = const_vecsmall(maxrank, 0); V = cgetg(1+maxrank, t_VECSMALL); } s = 0; av1 = avma; lim = stack_lim(av1,1); k = n; y[n] = z[n] = 0; x[n] = (long)sqrt(BOUND/v[n]); if (flag == min_PERF) invp = matid(maxrank); for(;;x[1]--) { do { if (k>1) { long l = k-1; z[l] = 0; for (j=k; j<=n; j++) z[l] += q[l][j]*x[j]; p = (double)x[k] + z[k]; y[l] = y[k] + p*p*v[k]; x[l] = (long)floor(sqrt((BOUND-y[l])/v[l])-z[l]); k = l; } for(;;) { p = (double)x[k] + z[k]; if (y[k] + p*p*v[k] <= BOUND) break; k++; x[k]--; } } while (k > 1); if (! x[1] && y[1]<=eps) break; p = (double)x[1] + z[1]; p = y[1] + p*p*v[1]; /* norm(x) */ if (maxnorm >= 0) { if (flag == min_FIRST) { gel(res,2) = gerepileupto(av, ZM_zc_mul(u,x)); av = avma; gel(res,1) = gerepileupto(av, ground(dbltor(p))); return res; } if (p > maxnorm) maxnorm = p; } else { pari_sp av2 = avma; gnorme = ground(dbltor(p)); if (gcmp(gnorme,BORNE) >= 0) avma = av2; else { BOUND=gtodouble(gnorme)+eps; s=0; affii(gnorme,BORNE); avma = av1; if (flag == min_PERF) invp = matid(maxrank); } } s++; switch(flag) { case min_ALL: if (s<=maxrank) { p1 = new_chunk(n+1); gel(L,s) = p1; for (i=1; i<=n; i++) p1[i] = x[i]; } break; case min_VECSMALL: { ulong norm = (ulong)(p + 0.5); res[norm]++; } break; case min_VECSMALL2: { ulong norm = (ulong)(p + 0.5); if ((norm&1) == 0) res[norm>>1]++; } break; case min_PERF: { long I=1; pari_sp av2=avma; for (i=1; i<=n; i++) for (j=i; j<=n; j++,I++) V[I] = x[i]*x[j]; if (! addcolumntomatrix(V,invp,L)) { if (DEBUGLEVEL>1) { fprintferr("."); flusherr(); } s--; avma=av2; continue; } if (DEBUGLEVEL>1) { fprintferr("*"); flusherr(); } if (s == maxrank) { if (DEBUGLEVEL>1) { fprintferr("\n"); flusherr(); } avma=av0; return stoi(s); } if (low_stack(lim, stack_lim(av1,1))) { if(DEBUGMEM>1) err(warnmem,"minim0, rank>=%ld",s); invp = gerepilecopy(av1, invp); } } } } switch(flag) { case min_FIRST: avma=av0; return cgetg(1,t_VEC); case min_VECSMALL: case min_VECSMALL2: avma=av; return res; case min_PERF: if (DEBUGLEVEL>1) { fprintferr("\n"); flusherr(); } avma=av0; return stoi(s); } k = min(s,maxrank); r = (maxnorm >= 0) ? ground(dbltor(maxnorm)): BORNE; L[0] = evaltyp(t_MAT) | evallg(k + 1); for (j=1; j<=k; j++) gel(L,j) = ZM_zc_mul(u, gel(L,j)); gerepileall(av, 2, &r, &L); gel(res,1) = stoi(s<<1); gel(res,2) = r; gel(res,3) = L; return res;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/5122ee80aa4b80497f7d3ca0b825888448ac278d/bibli1.c/clean/src/basemath/bibli1.c
char buffer[256];
void canonical_input( struct termios *tp ){ char c, first_time = TRUE; printf( "\nTesting canonical input\n\n" ); printf( "Setting line to canonical input mode.\n" ); tp->c_lflag = ISIG | ICANON | ECHO | ECHONL | ECHOK | ECHOE | ECHOPRT | ECHOCTL | IEXTEN; tp->c_iflag = BRKINT | ICRNL | IXON | IMAXBEL; if( tcsetattr( fileno( stdin ), TCSADRAIN, tp ) < 0 ) { perror( "canonical_input(): tcsetattr() failed" ); exit( 1 ); } while ( ( c = getchar () ) != '\n'); printf( "Testing getchar(). Type some text followed by carriage return\n" ); printf( "Each character you entered will be echoed back to you\n\n" ); while ( ( c = getchar () ) != '\n') { if( first_time ) { printf( "\nYou typed:\n"); first_time = FALSE; } printf( "%c", c ); } printf( "\n\nCanonical input test done.\n" );}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/8ef38186faea3d9b5e6f0f1242f668cb7e7a3d52/init.c/buggy/c/src/tests/libtests/termios/init.c
if (N==1) { S=cgetg(2,t_VEC); S[1]=(long)polx[v0]; return S; }
if (N==1) return _vec(polx[v0]);
conjugates(GEN pol){ long av,tetpil,N,i,j,pp,bound_primes,nbprimes,longT,v0,flL,f,longTnew,*tab,nop; GEN T,S,p1,p2,p,dpol,modunp,polp,xbar,frobp,frob,d,B,nf; byteptr di; if (DEBUGLEVEL>2){ fprintferr("** Entree dans conjugates\n"); flusherr(); } if (typ(pol)==t_POL) nf = NULL; else { nf = checknf(pol); pol=(GEN)nf[1]; } av=avma; N=deg(pol); v0=varn(pol); if (N==1) { S=cgetg(2,t_VEC); S[1]=(long)polx[v0]; return S; } if (N==2) { S=cgetg(3,t_VEC); S[1]=(long)polx[v0]; S[2]=lsub(gneg(polx[v0]),(GEN)pol[3]); tetpil=avma; return gerepile(av,tetpil,gcopy(S)); } dpol=absi(discsr(pol)); if (DEBUGLEVEL>2) { fprintferr("discriminant du polynome: "); outerr(dpol); } d = nf? (GEN)nf[4]: compute_denom(dpol); if (DEBUGLEVEL>2) { fprintferr("facteur carre du discriminant: "); outerr(d); } B=compute_bound_for_lift(pol,dpol,d); if (DEBUGLEVEL>2) { fprintferr("borne pour les lifts: "); outerr(B); } /* sous GRH il faut en fait 3.47*log(dpol) */ p1=gfloor(glog(dpol,DEFAULTPREC)); bound_primes=itos(p1); if (DEBUGLEVEL>2) { fprintferr("borne pour les premiers: %ld\n",bound_primes); flusherr(); } nbprimes=itos(gfloor(gmul(dbltor(1.25506), gdiv(p1,glog(p1,DEFAULTPREC))))); if (DEBUGLEVEL>2) { fprintferr("borne pour le nombre de premiers: %ld\n",nbprimes); flusherr(); } S=cgetg(nbprimes+1,t_VEC); di=diffptr; pp=*di; i=0; while (pp<=bound_primes) { if (smodis(dpol,pp)) { i++; S[i]=lstoi(pp); } pp = pp + (*(++di)); } for (j=i+1; j<=nbprimes; j++) S[j]=zero; nbprimes=i; tab=new_chunk(nbprimes+1); for (i=1; i<=nbprimes; i++) tab[i]=0; if (DEBUGLEVEL>2) { fprintferr("nombre de premiers: %ld\n",nbprimes); fprintferr("table des premiers: "); outerr(S); } T=cgetg(N+1,t_VEC); T[1]=(long)polx[v0]; for (i=2; i<=N; i++) T[i]=zero; longT=1; if (DEBUGLEVEL>2) { fprintferr("table initiale: "); outerr(T); } for(;;) { do { do { nop = 1+itos(shifti(mulss(mymyrand(),nbprimes),-(BITS_IN_RANDOM-1))); } while (tab[nop]); tab[nop]=1; p=(GEN)S[nop]; if (DEBUGLEVEL>2) { fprintferr("\nnombre premier: "); outerr(p); } modunp=gmodulsg(1,p); polp=gmul(modunp,pol); xbar=gmodulcp(gmul(polx[v0],modunp),polp); frobp=gpui(xbar,p,4); if (DEBUGLEVEL>2) { fprintferr("frobenius mod p: "); outerr(frobp); } flL=isinlistmodp(T,longT,frobp,p); if (DEBUGLEVEL>2){ fprintferr("flL: %ld\n",flL); flusherr(); } } while (flL); f=minimalexponent(T,longT,frobp,p,N); if (DEBUGLEVEL>2){ fprintferr("exposant minimum: %ld\n",f); flusherr(); } frob=frobenius(pol,frobp,p,B,d); if (DEBUGLEVEL>2) { fprintferr("frobenius: "); outerr(frob); }/* Ce passage n'est vrai que si le corps est abelien !! */ longTnew=longT; p2=gmodulcp(frob,pol); for (i=1; i<=longTnew; i++) for (j=1; j<f; j++) { p1=lift(gsubst((GEN)T[i],v0,gpuigs(p2,j))); if (DEBUGLEVEL>2) { fprintferr("test de la puissance (%ld,%ld): ",i,j); outerr(p1); } if (!isinlist(T,longTnew,p1)) { longT++; T[longT]=(long)p1; if (longT==N) { if (DEBUGLEVEL>2) { fprintferr("** Sortie de conjugates\n"); flusherr(); } tetpil=avma; return gerepile(av,tetpil,gcopy(T)); } } } if (DEBUGLEVEL>2) { fprintferr("nouvelle table: "); outerr(T); } }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c
S=cgetg(3,t_VEC); S[1]=(long)polx[v0]; S[2]=lsub(gneg(polx[v0]),(GEN)pol[3]);
S=cgetg(3,t_VEC); S[1] = (long)polx[v0]; S[2] = lsub(gneg(polx[v0]),(GEN)pol[3]);
conjugates(GEN pol){ long av,tetpil,N,i,j,pp,bound_primes,nbprimes,longT,v0,flL,f,longTnew,*tab,nop; GEN T,S,p1,p2,p,dpol,modunp,polp,xbar,frobp,frob,d,B,nf; byteptr di; if (DEBUGLEVEL>2){ fprintferr("** Entree dans conjugates\n"); flusherr(); } if (typ(pol)==t_POL) nf = NULL; else { nf = checknf(pol); pol=(GEN)nf[1]; } av=avma; N=deg(pol); v0=varn(pol); if (N==1) { S=cgetg(2,t_VEC); S[1]=(long)polx[v0]; return S; } if (N==2) { S=cgetg(3,t_VEC); S[1]=(long)polx[v0]; S[2]=lsub(gneg(polx[v0]),(GEN)pol[3]); tetpil=avma; return gerepile(av,tetpil,gcopy(S)); } dpol=absi(discsr(pol)); if (DEBUGLEVEL>2) { fprintferr("discriminant du polynome: "); outerr(dpol); } d = nf? (GEN)nf[4]: compute_denom(dpol); if (DEBUGLEVEL>2) { fprintferr("facteur carre du discriminant: "); outerr(d); } B=compute_bound_for_lift(pol,dpol,d); if (DEBUGLEVEL>2) { fprintferr("borne pour les lifts: "); outerr(B); } /* sous GRH il faut en fait 3.47*log(dpol) */ p1=gfloor(glog(dpol,DEFAULTPREC)); bound_primes=itos(p1); if (DEBUGLEVEL>2) { fprintferr("borne pour les premiers: %ld\n",bound_primes); flusherr(); } nbprimes=itos(gfloor(gmul(dbltor(1.25506), gdiv(p1,glog(p1,DEFAULTPREC))))); if (DEBUGLEVEL>2) { fprintferr("borne pour le nombre de premiers: %ld\n",nbprimes); flusherr(); } S=cgetg(nbprimes+1,t_VEC); di=diffptr; pp=*di; i=0; while (pp<=bound_primes) { if (smodis(dpol,pp)) { i++; S[i]=lstoi(pp); } pp = pp + (*(++di)); } for (j=i+1; j<=nbprimes; j++) S[j]=zero; nbprimes=i; tab=new_chunk(nbprimes+1); for (i=1; i<=nbprimes; i++) tab[i]=0; if (DEBUGLEVEL>2) { fprintferr("nombre de premiers: %ld\n",nbprimes); fprintferr("table des premiers: "); outerr(S); } T=cgetg(N+1,t_VEC); T[1]=(long)polx[v0]; for (i=2; i<=N; i++) T[i]=zero; longT=1; if (DEBUGLEVEL>2) { fprintferr("table initiale: "); outerr(T); } for(;;) { do { do { nop = 1+itos(shifti(mulss(mymyrand(),nbprimes),-(BITS_IN_RANDOM-1))); } while (tab[nop]); tab[nop]=1; p=(GEN)S[nop]; if (DEBUGLEVEL>2) { fprintferr("\nnombre premier: "); outerr(p); } modunp=gmodulsg(1,p); polp=gmul(modunp,pol); xbar=gmodulcp(gmul(polx[v0],modunp),polp); frobp=gpui(xbar,p,4); if (DEBUGLEVEL>2) { fprintferr("frobenius mod p: "); outerr(frobp); } flL=isinlistmodp(T,longT,frobp,p); if (DEBUGLEVEL>2){ fprintferr("flL: %ld\n",flL); flusherr(); } } while (flL); f=minimalexponent(T,longT,frobp,p,N); if (DEBUGLEVEL>2){ fprintferr("exposant minimum: %ld\n",f); flusherr(); } frob=frobenius(pol,frobp,p,B,d); if (DEBUGLEVEL>2) { fprintferr("frobenius: "); outerr(frob); }/* Ce passage n'est vrai que si le corps est abelien !! */ longTnew=longT; p2=gmodulcp(frob,pol); for (i=1; i<=longTnew; i++) for (j=1; j<f; j++) { p1=lift(gsubst((GEN)T[i],v0,gpuigs(p2,j))); if (DEBUGLEVEL>2) { fprintferr("test de la puissance (%ld,%ld): ",i,j); outerr(p1); } if (!isinlist(T,longTnew,p1)) { longT++; T[longT]=(long)p1; if (longT==N) { if (DEBUGLEVEL>2) { fprintferr("** Sortie de conjugates\n"); flusherr(); } tetpil=avma; return gerepile(av,tetpil,gcopy(T)); } } } if (DEBUGLEVEL>2) { fprintferr("nouvelle table: "); outerr(T); } }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/59af7aa1a95aeb4e670f3d2cf01cd1e105edb8c4/subfield.c/buggy/src/modules/subfield.c
for (i=1; i<=n; i++)
for (i=1+(j==1); i<=n; i++)
mathilbert(long n) /* Hilbert matrix of order n */{ long i,j; GEN a,p; if (n<0) n = 0; p = cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p[j]=lgetg(n+1,t_COL); for (i=1; i<=n; i++) { a=cgetg(3,t_FRAC); a[1]=un; a[2]=lstoi(i+j-1); coeff(p,i,j)=(long)a; } } return p;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/89677bb9dc30e3d27a61c604a2db88c307cf9a3c/bibli2.c/buggy/src/basemath/bibli2.c
if ( n ) mael(p,1,1)=un;
mathilbert(long n) /* Hilbert matrix of order n */{ long i,j; GEN a,p; if (n<0) n = 0; p = cgetg(n+1,t_MAT); for (j=1; j<=n; j++) { p[j]=lgetg(n+1,t_COL); for (i=1; i<=n; i++) { a=cgetg(3,t_FRAC); a[1]=un; a[2]=lstoi(i+j-1); coeff(p,i,j)=(long)a; } } return p;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/89677bb9dc30e3d27a61c604a2db88c307cf9a3c/bibli2.c/buggy/src/basemath/bibli2.c
/* case PPC_604r: -- same value as PPC_750 */
case PPC_604r:
int mpc60x_vector_is_valid(rtems_vector vector){ switch (current_ppc_cpu) { case PPC_7400: case PPC_750: if (!mpc750_vector_is_valid(vector)) { return 0; } break; case PPC_604: case PPC_604e: /* case PPC_604r: -- same value as PPC_750 */ if (!mpc604_vector_is_valid(vector)) { return 0; } break; case PPC_603: case PPC_603e: case PPC_603ev: if (!mpc603_vector_is_valid(vector)) { return 0; } break; default: printk("Please complete libcpu/powerpc/mpc6xx/raw_exception.c\n"); printk("current_ppc_cpu = %x\n", current_ppc_cpu); return 0; } return 1;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/d49389adb995168842d8f5b967945f6bbb281244/raw_exception.c/buggy/c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
printk("Please complete libcpu/powerpc/mpc6xx/raw_exception.c\n");
printk("Please complete libcpu/powerpc/mpc6xx/exceptions/raw_exception.c\n");
int mpc60x_vector_is_valid(rtems_vector vector){ switch (current_ppc_cpu) { case PPC_7400: case PPC_750: if (!mpc750_vector_is_valid(vector)) { return 0; } break; case PPC_604: case PPC_604e: /* case PPC_604r: -- same value as PPC_750 */ if (!mpc604_vector_is_valid(vector)) { return 0; } break; case PPC_603: case PPC_603e: case PPC_603ev: if (!mpc603_vector_is_valid(vector)) { return 0; } break; default: printk("Please complete libcpu/powerpc/mpc6xx/raw_exception.c\n"); printk("current_ppc_cpu = %x\n", current_ppc_cpu); return 0; } return 1;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/d49389adb995168842d8f5b967945f6bbb281244/raw_exception.c/buggy/c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
/* * Please fill this for MVME2307 */ printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n");
switch(vector) { case ASM_RESET_VECTOR: /* fall through */ case ASM_MACH_VECTOR: case ASM_PROT_VECTOR: case ASM_ISI_VECTOR: case ASM_EXT_VECTOR: case ASM_ALIGN_VECTOR: case ASM_PROG_VECTOR: case ASM_FLOAT_VECTOR: case ASM_DEC_VECTOR: case ASM_SYS_VECTOR: case ASM_TRACE_VECTOR: case ASM_PERFMON_VECTOR: return 1; case ASM_IMISS_VECTOR: /* fall through */ case ASM_DLMISS_VECTOR: case ASM_DSMISS_VECTOR: return 0; case ASM_ADDR_VECTOR: /* fall through */ case ASM_SYSMGMT_VECTOR: return 1; case ASM_ITM_VECTOR: return 0; }
int mpc604_vector_is_valid(rtems_vector vector){ /* * Please fill this for MVME2307 */ printk("Please complete libcpu/powerpc/XXX/raw_exception.c\n"); return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/95273a610ff4ed4f4cf78d20a99f6a32acec8841/raw_exception.c/clean/c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
GEN q, bas, invbas, mul, dK, nf, fa, g, e, dx = absi(ZX_disc(x));
GEN q, bas, invbas, mul, dK, nf, g, e, dx = absi(ZX_disc(x));
padicff(GEN x,GEN p,long pr){ pari_sp av = avma; GEN q, bas, invbas, mul, dK, nf, fa, g, e, dx = absi(ZX_disc(x)); long n = degpol(x), v = Z_pvalrem(dx,p,&q); nf = cgetg(10,t_VEC); nf[1] = (long)x; if (is_pm1(q)) { e = mkcol(utoi(v)); g = mkcol(p); } else { e = mkcol2(stoi(v), gen_1); g = mkcol2(p, q); } fa = cgetg(3,t_MAT); fa[1] = (long)g; fa[2] = (long)e; bas = nfbasis(x, &dK, 0, fa); nf[3] = (long)dK; nf[4] = dvdii( diviiexact(dx, dK), p )? (long)p: (long)gen_1; invbas = QM_inv(RgXV_to_RgM(bas,n), gen_1); mul = get_mul_table(x,bas,invbas); nf[7]=(long)bas; nf[8]=(long)invbas; nf[9]=(long)mul; nf[2]=nf[5]=nf[6]= (long)gen_0; return gerepileupto(av,padicff2(nf,p,pr));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0653bf4e80ffba66b9dad8b9b9bf38de88f14841/polarit1.c/clean/src/basemath/polarit1.c
e = mkcol2(stoi(v), gen_1);
e = mkcol2(utoi(v), gen_1);
padicff(GEN x,GEN p,long pr){ pari_sp av = avma; GEN q, bas, invbas, mul, dK, nf, fa, g, e, dx = absi(ZX_disc(x)); long n = degpol(x), v = Z_pvalrem(dx,p,&q); nf = cgetg(10,t_VEC); nf[1] = (long)x; if (is_pm1(q)) { e = mkcol(utoi(v)); g = mkcol(p); } else { e = mkcol2(stoi(v), gen_1); g = mkcol2(p, q); } fa = cgetg(3,t_MAT); fa[1] = (long)g; fa[2] = (long)e; bas = nfbasis(x, &dK, 0, fa); nf[3] = (long)dK; nf[4] = dvdii( diviiexact(dx, dK), p )? (long)p: (long)gen_1; invbas = QM_inv(RgXV_to_RgM(bas,n), gen_1); mul = get_mul_table(x,bas,invbas); nf[7]=(long)bas; nf[8]=(long)invbas; nf[9]=(long)mul; nf[2]=nf[5]=nf[6]= (long)gen_0; return gerepileupto(av,padicff2(nf,p,pr));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0653bf4e80ffba66b9dad8b9b9bf38de88f14841/polarit1.c/clean/src/basemath/polarit1.c
fa = cgetg(3,t_MAT); fa[1] = (long)g; fa[2] = (long)e; bas = nfbasis(x, &dK, 0, fa);
bas = nfbasis(x, &dK, 0, mkmat2(g,e));
padicff(GEN x,GEN p,long pr){ pari_sp av = avma; GEN q, bas, invbas, mul, dK, nf, fa, g, e, dx = absi(ZX_disc(x)); long n = degpol(x), v = Z_pvalrem(dx,p,&q); nf = cgetg(10,t_VEC); nf[1] = (long)x; if (is_pm1(q)) { e = mkcol(utoi(v)); g = mkcol(p); } else { e = mkcol2(stoi(v), gen_1); g = mkcol2(p, q); } fa = cgetg(3,t_MAT); fa[1] = (long)g; fa[2] = (long)e; bas = nfbasis(x, &dK, 0, fa); nf[3] = (long)dK; nf[4] = dvdii( diviiexact(dx, dK), p )? (long)p: (long)gen_1; invbas = QM_inv(RgXV_to_RgM(bas,n), gen_1); mul = get_mul_table(x,bas,invbas); nf[7]=(long)bas; nf[8]=(long)invbas; nf[9]=(long)mul; nf[2]=nf[5]=nf[6]= (long)gen_0; return gerepileupto(av,padicff2(nf,p,pr));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0653bf4e80ffba66b9dad8b9b9bf38de88f14841/polarit1.c/clean/src/basemath/polarit1.c
top_of_used_memory = (rtems_unsigned32) &end + 0x1000;
top_of_used_memory = (uint32_t) &end + 0x1000;
int rx_boot_card( int argc, char **argv, char **environp){ extern int end; top_of_used_memory = (rtems_unsigned32) &end + 0x1000; if ((argc > 0) && argv && argv[0]) rtems_progname = argv[0]; else rtems_progname = "RTEMS/RP"; boot_card(argc, argv);}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/1d5c9757d724075bf9f4592a400ac3edba38b8d0/bspstart.c/buggy/c/src/lib/libbsp/i960/rxgen960/startup/bspstart.c
long group,omax;
long group;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
Fpe=cgetg(lg(Fp), t_VECSMALL);
Fpe=cgetg(np+1, t_VECSMALL);
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
if ( Fp[np] == 3 && Fe[np] == 1 ) group |= ga_ext_2;
if ( Fp[np] == 3 && Fe[np] == 1 ) group |= ga_ext_2;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
omax=0;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
|| (nbtest < nbmax && order != n && (nbtest <=8 || order != (n>>1))) || (n == 24 && O[6] == 0 && O[4] == 0))
|| (nbtest < nbmax && order != n && (nbtest <=8 || order != (n>>1))) || (n == 24 && O[6] == 0 && O[4] == 0))
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
long o,norm_o;
long o,norm_o=1;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
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
if (o % order == 0) { /*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--)
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
norm_o = 1; for (i = np; i > 0; i--) { if (o % Fpe[i] == 0) norm_o *= Fpe[i]; else break; }
if (o % Fpe[i] == 0) norm_o *= Fpe[i]; else break;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
if (norm_o != 1)
} if (norm_o != 1) { if (!(group&ga_all_normal) || o > order || (o == order && (plift == 0 || norm_o > deg)))
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
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];
deg = norm_o;
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
/* 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]))
/* This is to avoid looping on non-wss group. To be checked for large groups. */ 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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/440762184b16fece84642e8381efc1c815eca86e/galconj.c/buggy/src/basemath/galconj.c
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base2.c/clean/src/basemath/base2.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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/d69ed6d8e7bab8aead997a49557e9f1f7b600854/buch2.c/clean/src/basemath/buch2.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
{ /* we'll sort ideals by norm (flag excluded ideals with "zero") */
{ /* we'll sort ideals by norm (excluded ideals = "zero") */
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
/* take the first (wrt norm) n ideals, and put them first */
/* take the first (non excluded) n ideals (wrt norm), put them first, and * sort the rest by increasing norm */
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/57053d514f841efa1b4cd798bf32179239d2d44f/buch2.c/clean/src/basemath/buch2.c
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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
*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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
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); }}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/0cc3eaa87c099dca803fc47d981245cd409b2484/base1.c/clean/src/basemath/base1.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/4fedb725a485039bb8dc1210c2d85733501b6a04/compat.c/clean/src/language/compat.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/ca252a435a59197d50fa8a9ccf26136e9220e6e4/buch2.c/clean/src/basemath/buch2.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/baac875f4b6a3a9a0118a1de76c84b64fba7ad34/stark.c/buggy/src/modules/stark.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/baac875f4b6a3a9a0118a1de76c84b64fba7ad34/stark.c/buggy/src/modules/stark.c
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);}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/b7044dc94e1e4ee9f69ad6841e60c9602d5ea86b/init5206e.c/buggy/c/src/lib/libbsp/m68k/mcf5206elite/startup/init5206e.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/baac875f4b6a3a9a0118a1de76c84b64fba7ad34/stark.c/buggy/src/modules/stark.c
for (i = 1; i < nb; i++) /* skip Id which comes last */
setlg(subgrp, nb); /* skip Id which comes last */ 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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/baac875f4b6a3a9a0118a1de76c84b64fba7ad34/stark.c/buggy/src/modules/stark.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/88a5ea098bd3f806f055886045cbd51a60cc0863/base4.c/clean/src/basemath/base4.c
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base2.c/clean/src/basemath/base2.c
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/7168973a923818508c45aa17d871c53e9225fad1/base2.c/clean/src/basemath/base2.c
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;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/662678d1d9aa92862d72fa7d25fc07cf6333ade0/isatty.c/buggy/c/src/exec/libcsupport/src/isatty.c
isatty (int fd){ struct stat buf; if (fstat (fd, &buf) < 0) return 0; if (S_ISCHR (buf.st_mode)) return 1; return 0;}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/662678d1d9aa92862d72fa7d25fc07cf6333ade0/isatty.c/buggy/c/src/exec/libcsupport/src/isatty.c
y = cgetr(l); av = avma; t = exp1r_abs(gmul2n(x,1)); /* exp(|2x|) - 1 */ affrr(divrr(t, addsr(2,t)), y); avma = av;
av = avma; t = exp1r_abs(gmul2n(x,1)); /* exp(|2x|) - 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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/a0d8bd4ca3992fcf4e709bbc857cacac191dae1b/trans2.c/buggy/src/basemath/trans2.c
if (l > 0)
la = 3.; /* FIXME: heuristic... */ 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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6980ff95453fe1bef68879e96b2264324521e2c2/trans2.c/buggy/src/basemath/trans2.c
if (la < 3) la = 3.; /* FIXME: heuristic... */
if (la < 3) 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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6980ff95453fe1bef68879e96b2264324521e2c2/trans2.c/buggy/src/basemath/trans2.c
else la = 3.; /* FIXME: heuristic... */
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6980ff95453fe1bef68879e96b2264324521e2c2/trans2.c/buggy/src/basemath/trans2.c
tes = divrs2_safe(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/
tes = divrsns(bernreal(2*lim,prec), 2*lim-1); /* B2l / (2l-1) 2l*/
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6980ff95453fe1bef68879e96b2264324521e2c2/trans2.c/buggy/src/basemath/trans2.c
u = divrs2_safe(bernreal(i,prec), i-1); /* Bi / i(i-1) */
u = divrsns(bernreal(i,prec), i-1); /* Bi / i(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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/6980ff95453fe1bef68879e96b2264324521e2c2/trans2.c/buggy/src/basemath/trans2.c
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/dae47a1f7d6a2266233d6d7c62243c2ac55ce87e/mp.c/clean/src/kernel/none/mp.c
double beta = sqrt((double)(ulong)a[0]); /* 0.707... ~ 1/sqrt(2) */
double beta = sqrt((double)a[0]); /* 0.707... ~ 1/sqrt(2) */
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/dae47a1f7d6a2266233d6d7c62243c2ac55ce87e/mp.c/clean/src/kernel/none/mp.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/87b498f0e4b8ff8c197c46ce153c7a1251370828/bibli1.c/clean/src/basemath/bibli1.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/87b498f0e4b8ff8c197c46ce153c7a1251370828/bibli1.c/clean/src/basemath/bibli1.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/87b498f0e4b8ff8c197c46ce153c7a1251370828/bibli1.c/clean/src/basemath/bibli1.c
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);}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/87b498f0e4b8ff8c197c46ce153c7a1251370828/bibli1.c/clean/src/basemath/bibli1.c
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;}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/87b498f0e4b8ff8c197c46ce153c7a1251370828/bibli1.c/clean/src/basemath/bibli1.c
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));}
2195 /local/tlutelli/issta_data/temp/c/2005_temp/2005/2195/75bbe23ab8ce138cca18cb88feeca14172e80520/trans3.c/clean/src/basemath/trans3.c
#elif (defined (GEN68360_WITH_SRAM)) /* *************************************************** * Generic Standalone Motorola 68360 * * As described in MC68360 User's Manual * * But uses SRAM instead of DRAM * * CS0* - 512kx8 flash memory * * CS1* - 512kx32 static RAM * *************************************************** */ /* * Step 7: Deal with clock synthesizer * HARDWARE: * Change if you're not using an external oscillator which * oscillates at the system clock rate. */ m360.clkocr = 0x8F; /* No more writes, no clock outputs */ m360.pllcr = 0xD000; /* PLL, no writes, no prescale, no LPSTOP slowdown, PLL X1 */ m360.cdvcr = 0x8000; /* No more writes, no clock division */ /* * Step 8: Initialize system protection * Enable watchdog * Watchdog causes system reset * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) * Enable double bus fault monitor * Enable bus monitor for external cycles * 1024 clocks for external timeout */ m360.sypcr = 0xEC; /* * Step 9: Clear parameter RAM and reset communication processor module */ for (i = 0 ; i < 192 ; i += sizeof (long)) { *((long *)((char *)&m360 + 0xC00 + i)) = 0; *((long *)((char *)&m360 + 0xD00 + i)) = 0; *((long *)((char *)&m360 + 0xE00 + i)) = 0; *((long *)((char *)&m360 + 0xF00 + i)) = 0; } M360ExecuteRISC (M360_CR_RST); /* * Step 10: Write PEPAR * SINTOUT not used (CPU32+ mode) * CF1MODE=00 (CONFIG1 input) * IPIPE1* * WE0* - WE3* * OE* output * CAS2* - CAS3* * CAS0* - CAS1* * CS7* * AVEC* * HARDWARE: * Change if you are using a different memory configuration * (static RAM, external address multiplexing, etc). */ m360.pepar = 0x0080; /* * Step 11: Set up GMR * */ m360.gmr = 0x0; /* * Step 11a: Remap 512Kx8 flash memory on CS0* * 2 wait states * Make it read-only for now */ m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | M360_MEMC_BR_V; m360.memc[0].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB | M360_MEMC_OR_8BIT; /* * Step 12: Set up main memory * 512Kx32 SRAM on CS1* * 0 wait states */ m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V; m360.memc[1].or = M360_MEMC_OR_WAITS(0) | M360_MEMC_OR_2MB | M360_MEMC_OR_32BIT; /* * Step 13: Copy the exception vector table to system RAM */ m68k_get_vbr (vbr); for (i = 0; i < 256; ++i) M68Kvec[i] = vbr[i]; m68k_set_vbr (M68Kvec); /* * Step 14: More system initialization * SDCR (Serial DMA configuration register) * Enable SDMA during FREEZE * Give SDMA priority over all interrupt handlers * Set DMA arbiration level to 4 * CICR (CPM interrupt configuration register): * SCC1 requests at SCCa position * SCC2 requests at SCCb position * SCC3 requests at SCCc position * SCC4 requests at SCCd position * Interrupt request level 4 * Maintain original priority order * Vector base 128 * SCCs priority grouped at top of table */ m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | (4 << 13) | (0x1F << 8) | (128); /* * Step 15: Set module configuration register * Disable timers during FREEZE * Enable bus monitor during FREEZE * BCLRO* arbitration level 3 * No show cycles * User/supervisor access * Bus clear interrupt service level 7 * SIM60 interrupt sources higher priority than CPM */ m360.mcr = 0x4C7F;
void _Init68360 (void){ int i; m68k_isr_entry *vbr; extern void _CopyDataClearBSSAndStart (void);#if (defined (__mc68040__)) /* ******************************************* * Motorola 68040 and companion-mode 68360 * ******************************************* */ /* * Step 6: Is this a power-up reset? * For now we just ignore this and do *all* the steps * Someday we might want to: * if (Hard, Loss of Clock, Power-up) * Do all steps * else if (Double bus fault, watchdog or soft reset) * Skip to step 12 * else (must be a reset command) * Skip to step 14 */ /* * Step 7: Deal with clock synthesizer * HARDWARE: * Change if you're not using an external 25 MHz oscillator. */ m360.clkocr = 0x83; /* No more writes, full-power CLKO2 */ m360.pllcr = 0xD000; /* PLL, no writes, no prescale, no LPSTOP slowdown, PLL X1 */ m360.cdvcr = 0x8000; /* No more writes, no clock division */ /* * Step 8: Initialize system protection * Enable watchdog * Watchdog causes system reset * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) * Enable double bus fault monitor * Enable bus monitor for external cycles * 1024 clocks for external timeout */ m360.sypcr = 0xEC; /* * Step 9: Clear parameter RAM and reset communication processor module */ for (i = 0 ; i < 192 ; i += sizeof (long)) { *((long *)((char *)&m360 + 0xC00 + i)) = 0; *((long *)((char *)&m360 + 0xD00 + i)) = 0; *((long *)((char *)&m360 + 0xE00 + i)) = 0; *((long *)((char *)&m360 + 0xF00 + i)) = 0; } M360ExecuteRISC (M360_CR_RST); /* * Step 10: Write PEPAR * SINTOUT standard M68000 family interrupt level encoding * CF1MODE=10 (BCLRO* output) * No RAS1* double drive * A31 - A28 * AMUX output * CAS2* - CAS3* * CAS0* - CAS1* * CS7* * AVEC* */ m360.pepar = 0x3440; /* * Step 11: Remap Chip Select 0 (CS0*), set up GMR */ /* * 512 addresses per DRAM page (256K DRAM chips) * 70 nsec DRAM * 180 nsec ROM (3 wait states) */ m360.gmr = M360_GMR_RCNT(23) | M360_GMR_RFEN | M360_GMR_RCYC(0) | M360_GMR_PGS(1) | M360_GMR_DPS_32BIT | M360_GMR_NCS | M360_GMR_TSS40; m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | M360_MEMC_BR_V; m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | M360_MEMC_OR_32BIT; /* * Step 12: Initialize the system RAM */ /* * Set up option/base registers * 1M DRAM * 70 nsec DRAM * Enable burst mode * No parity checking * Wait for chips to power up * Perform 8 read cycles */ m360.memc[1].or = M360_MEMC_OR_TCYC(0) | M360_MEMC_OR_1MB | M360_MEMC_OR_DRAM; m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_BACK40 | M360_MEMC_BR_V; for (i = 0; i < 50000; i++) continue; for (i = 0; i < 8; ++i) *((volatile unsigned long *)(unsigned long)&_RamBase); /* * Step 13: Copy the exception vector table to system RAM */ m68k_get_vbr (vbr); for (i = 0; i < 256; ++i) M68Kvec[i] = vbr[i]; m68k_set_vbr (M68Kvec); /* * Step 14: More system initialization * SDCR (Serial DMA configuration register) * Enable SDMA during FREEZE * Give SDMA priority over all interrupt handlers * Set DMA arbiration level to 4 * CICR (CPM interrupt configuration register): * SCC1 requests at SCCa position * SCC2 requests at SCCb position * SCC3 requests at SCCc position * SCC4 requests at SCCd position * Interrupt request level 4 * Maintain original priority order * Vector base 128 * SCCs priority grouped at top of table */ m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | (4 << 13) | (0x1F << 8) | (128); /* * Step 15: Set module configuration register * Bus request MC68040 Arbitration ID 3 * Bus asynchronous timing mode (work around bug in Rev. B) * Arbitration asynchronous timing mode * Disable timers during FREEZE * Disable bus monitor during FREEZE * BCLRO* arbitration level 3 * No show cycles * User/supervisor access * Bus clear in arbitration ID level 3 * SIM60 interrupt sources higher priority than CPM */ m360.mcr = 0x6000EC3F;#elif (defined (M68360_ATLAS_HSB)) /* ****************************************** * Standalone Motorola 68360 -- ATLAS HSB * ****************************************** */ /* * Step 6: Is this a power-up reset? * For now we just ignore this and do *all* the steps * Someday we might want to: * if (Hard, Loss of Clock, Power-up) * Do all steps * else if (Double bus fault, watchdog or soft reset) * Skip to step 12 * else (must be a CPU32+ reset command) * Skip to step 14 */ /* * Step 7: Deal with clock synthesizer * HARDWARE: * Change if you're not using an external 25 MHz oscillator. */ m360.clkocr = 0x8F; /* No more writes, no clock outputs */ m360.pllcr = 0xD000; /* PLL, no writes, no prescale, no LPSTOP slowdown, PLL X1 */ m360.cdvcr = 0x8000; /* No more writes, no clock division */ /* * Step 8: Initialize system protection * Enable watchdog * Watchdog causes system reset * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) * Enable double bus fault monitor * Enable bus monitor for external cycles * 1024 clocks for external timeout */ m360.sypcr = 0xEC; /* * Step 9: Clear parameter RAM and reset communication processor module */ for (i = 0 ; i < 192 ; i += sizeof (long)) { *((long *)((char *)&m360 + 0xC00 + i)) = 0; *((long *)((char *)&m360 + 0xD00 + i)) = 0; *((long *)((char *)&m360 + 0xE00 + i)) = 0; *((long *)((char *)&m360 + 0xF00 + i)) = 0; } M360ExecuteRISC (M360_CR_RST); /* * Step 10: Write PEPAR * SINTOUT not used (CPU32+ mode) * CF1MODE=00 (CONFIG1 input) * RAS1* double drive * WE0* - WE3* * OE* output * CAS2* - CAS3* * CAS0* - CAS1* * CS7* * AVEC* * HARDWARE: * Change if you are using a different memory configuration * (static RAM, external address multiplexing, etc). */ m360.pepar = 0x0180; /* * Step 11: Remap Chip Select 0 (CS0*), set up GMR */ m360.gmr = M360_GMR_RCNT(12) | M360_GMR_RFEN | M360_GMR_RCYC(0) | M360_GMR_PGS(1) | M360_GMR_DPS_32BIT | M360_GMR_DWQ | M360_GMR_GAMX; m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | M360_MEMC_BR_V; m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | M360_MEMC_OR_8BIT; /* * Step 12: Initialize the system RAM */ /* first bank 1MByte DRAM */ m360.memc[1].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB | M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM; m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V; /* second bank 1MByte DRAM */ m360.memc[2].or = M360_MEMC_OR_TCYC(2) | M360_MEMC_OR_1MB | M360_MEMC_OR_PGME | M360_MEMC_OR_DRAM; m360.memc[2].br = ((unsigned long)&_RamBase + 0x100000) | M360_MEMC_BR_V; /* flash rom socket U6 on CS5 */ m360.memc[5].br = (unsigned long)ATLASHSB_ROM_U6 | M360_MEMC_BR_WP | M360_MEMC_BR_V; m360.memc[5].or = M360_MEMC_OR_WAITS(2) | M360_MEMC_OR_512KB | M360_MEMC_OR_8BIT; /* CSRs on CS7 */ m360.memc[7].or = M360_MEMC_OR_TCYC(4) | M360_MEMC_OR_64KB | M360_MEMC_OR_8BIT; m360.memc[7].br = ATLASHSB_ESR | 0x01; for (i = 0; i < 50000; i++) continue; for (i = 0; i < 8; ++i) *((volatile unsigned long *)(unsigned long)&_RamBase); /* * Step 13: Copy the exception vector table to system RAM */ m68k_get_vbr (vbr); for (i = 0; i < 256; ++i) M68Kvec[i] = vbr[i]; m68k_set_vbr (M68Kvec); /* * Step 14: More system initialization * SDCR (Serial DMA configuration register) * Enable SDMA during FREEZE * Give SDMA priority over all interrupt handlers * Set DMA arbiration level to 4 * CICR (CPM interrupt configuration register): * SCC1 requests at SCCa position * SCC2 requests at SCCb position * SCC3 requests at SCCc position * SCC4 requests at SCCd position * Interrupt request level 4 * Maintain original priority order * Vector base 128 * SCCs priority grouped at top of table */ m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | (4 << 13) | (0x1F << 8) | (128); /* * Step 15: Set module configuration register * Disable timers during FREEZE * Enable bus monitor during FREEZE * BCLRO* arbitration level 3 * No show cycles * User/supervisor access * Bus clear interrupt service level 7 * SIM60 interrupt sources higher priority than CPM */ m360.mcr = 0x4C7F;#else /* *************************************************** * Generic Standalone Motorola 68360 * * As described in MC68360 User's Manual * * Atlas ACE360 * *************************************************** */ /* * Step 6: Is this a power-up reset? * For now we just ignore this and do *all* the steps * Someday we might want to: * if (Hard, Loss of Clock, Power-up) * Do all steps * else if (Double bus fault, watchdog or soft reset) * Skip to step 12 * else (must be a CPU32+ reset command) * Skip to step 14 */ /* * Step 7: Deal with clock synthesizer * HARDWARE: * Change if you're not using an external 25 MHz oscillator. */ m360.clkocr = 0x8F; /* No more writes, no clock outputs */ m360.pllcr = 0xD000; /* PLL, no writes, no prescale, no LPSTOP slowdown, PLL X1 */ m360.cdvcr = 0x8000; /* No more writes, no clock division */ /* * Step 8: Initialize system protection * Enable watchdog * Watchdog causes system reset * Next-to-slowest watchdog timeout (21 seconds with 25 MHz oscillator) * Enable double bus fault monitor * Enable bus monitor for external cycles * 1024 clocks for external timeout */ m360.sypcr = 0xEC; /* * Step 9: Clear parameter RAM and reset communication processor module */ for (i = 0 ; i < 192 ; i += sizeof (long)) { *((long *)((char *)&m360 + 0xC00 + i)) = 0; *((long *)((char *)&m360 + 0xD00 + i)) = 0; *((long *)((char *)&m360 + 0xE00 + i)) = 0; *((long *)((char *)&m360 + 0xF00 + i)) = 0; } M360ExecuteRISC (M360_CR_RST); /* * Step 10: Write PEPAR * SINTOUT not used (CPU32+ mode) * CF1MODE=00 (CONFIG1 input) * RAS1* double drive * WE0* - WE3* * OE* output * CAS2* - CAS3* * CAS0* - CAS1* * CS7* * AVEC* * HARDWARE: * Change if you are using a different memory configuration * (static RAM, external address multiplexing, etc). */ m360.pepar = 0x0180; /* * Step 11: Remap Chip Select 0 (CS0*), set up GMR * 32-bit DRAM * Internal DRAM address multiplexing * 60 nsec DRAM * 180 nsec ROM (3 wait states) * 15.36 usec DRAM refresh interval * The DRAM page size selection is not modified since this * startup code may be running in a bootstrap PROM or in * a program downloaded by the bootstrap PROM. */ m360.gmr = (m360.gmr & 0x001C0000) | M360_GMR_RCNT(23) | M360_GMR_RFEN | M360_GMR_RCYC(0) | M360_GMR_DPS_32BIT | M360_GMR_NCS | M360_GMR_GAMX; m360.memc[0].br = (unsigned long)&_RomBase | M360_MEMC_BR_WP | M360_MEMC_BR_V; m360.memc[0].or = M360_MEMC_OR_WAITS(3) | M360_MEMC_OR_1MB | M360_MEMC_OR_8BIT; /* * Step 12: Initialize the system RAM * Do this only if the DRAM has not already been set up */ if ((m360.memc[1].br & M360_MEMC_BR_V) == 0) { /* * Set up GMR DRAM page size, option and base registers * Assume 16Mbytes of DRAM * 60 nsec DRAM */ m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(5); m360.memc[1].or = M360_MEMC_OR_TCYC(0) | M360_MEMC_OR_16MB | M360_MEMC_OR_DRAM; m360.memc[1].br = (unsigned long)&_RamBase | M360_MEMC_BR_V; /* * Wait for chips to power up * Perform 8 read cycles */ for (i = 0; i < 50000; i++) continue; for (i = 0; i < 8; ++i) *((volatile unsigned long *)(unsigned long)&_RamBase); /* * Determine memory size (1, 4, or 16 Mbytes) * Set GMR DRAM page size appropriately. * The OR is left at 16 Mbytes. The bootstrap PROM places its * .data and .bss segments at the top of the 16 Mbyte space. * A 1 Mbyte or 4 Mbyte DRAM will show up several times in * the memory map, but will work with the same bootstrap PROM. */ *(volatile char *)&_RamBase = 0; *((volatile char *)&_RamBase+0x00C01800) = 1; if (*(volatile char *)&_RamBase) { m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(1); } else { *((volatile char *)&_RamBase+0x00801000) = 1; if (*(volatile char *)&_RamBase) { m360.gmr = (m360.gmr & ~0x001C0000) | M360_GMR_PGS(3); } } /* * Enable parity checking */ m360.memc[1].br |= M360_MEMC_BR_PAREN; } /* * Step 13: Copy the exception vector table to system RAM */ m68k_get_vbr (vbr); for (i = 0; i < 256; ++i) M68Kvec[i] = vbr[i]; m68k_set_vbr (M68Kvec); /* * Step 14: More system initialization * SDCR (Serial DMA configuration register) * Enable SDMA during FREEZE * Give SDMA priority over all interrupt handlers * Set DMA arbiration level to 4 * CICR (CPM interrupt configuration register): * SCC1 requests at SCCa position * SCC2 requests at SCCb position * SCC3 requests at SCCc position * SCC4 requests at SCCd position * Interrupt request level 4 * Maintain original priority order * Vector base 128 * SCCs priority grouped at top of table */ m360.sdcr = M360_SDMA_SISM_7 | M360_SDMA_SAID_4; m360.cicr = (3 << 22) | (2 << 20) | (1 << 18) | (0 << 16) | (4 << 13) | (0x1F << 8) | (128); /* * Step 15: Set module configuration register * Disable timers during FREEZE * Enable bus monitor during FREEZE * BCLRO* arbitration level 3 * No show cycles * User/supervisor access * Bus clear interrupt service level 7 * SIM60 interrupt sources higher priority than CPM */ m360.mcr = 0x4C7F;#endif /* * Copy data, clear BSS, switch stacks and call main() */ _CopyDataClearBSSAndStart ();}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/66fe6be6cd52c386a60ad77d5791198970d8495c/init68360.c/clean/c/src/lib/libbsp/m68k/gen68360/startup/init68360.c
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
while (!isspace((int)*cp) && (cp < maxcp)) /* if trailing garbage or m */
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */
while (!isspace((int)*cp) && (cp < maxcp)) /* if trailing garbage or m */
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c
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 */}
10355 /local/tlutelli/issta_data/temp/c/2005_temp/2005/10355/ff0f694d466fb114c185bf464811658f97d012f1/res_debug.c/clean/c/src/exec/libnetworking/libc/res_debug.c