diff --git a/pv.c b/pv.c index 53937eb..8c1ec67 100644 --- a/pv.c +++ b/pv.c @@ -85,7 +85,7 @@ static I jtdcase(J jt,I xi,V*v){ /* 5 s f t */ TACT(jtvdyad){A fs,sf,xt,yt;B xl,xr,yl,yr;I xi=-1,yi=-1;TA x,y,z={one};V*u=0,*v=0; - fs=stack[e-1].a; x=stack[b]; y=stack[e]; sf=swapc(fs); + fs=stack[e-1].a; x=stack[b]; y=stack[e]; sf=swap(fs); if(xt=tine(x.t)){xi=tvi(x.t); u=VAV(xt); if(0>xi&&CFORK==u->id){xi=tvi(u->f); if(0>xi)xi=tvi(u->h);}} if(yt=tine(y.t)){yi=tvi(y.t); v=VAV(yt); if(0>yi&&CFORK==v->id){yi=tvi(v->f); if(0>yi)yi=tvi(v->h);}} if(fs==ds(CLEFT)){if(xt)z.t=xt; else z.a=x.a; R z;} diff --git a/vz.c b/vz.c index 74b6b97..95ab337 100644 --- a/vz.c +++ b/vz.c @@ -92,10 +92,13 @@ ZF2(jtzrem){D a,b,d;Z q; R zminus(v,ztymes(u,q)); } -ZF2(jtzgcd){D a,b;Z t,z; +ZF2(jtzgcd){D a,b,d;Z q,t,z; ZASSERT(!(ZINF(u)||ZINF(v)),EVNAN); while(ZNZ(u)){ - t=zrem(u,v); if(t.re>v.re/2)t.re-=v.re; if(t.im>v.im/2)t.im-=v.im; + d=u.re*u.re+u.im*u.im; + a=u.re*v.re+u.im*v.im; q.re=tfloor(0.5+a/d); + b=u.re*v.im-u.im*v.re; q.im=tfloor(0.5+b/d); + t=zminus(v,ztymes(u,q)); v.re=u.re; v.im=u.im; u.re=t.re; u.im=t.im; } z.re=a=v.re; z.im=b=v.im;