Skip to content

Commit

Permalink
128!:5 to support qp
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryHRich committed Nov 24, 2024
1 parent f826bf9 commit 1487a64
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 3 additions & 2 deletions jsrc/cu.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,10 @@ F2(jtunder){F2PREFIP;A x,wvb=w;AF f1,f2;B b,b1;C c,uid;I gside=-1;V*u,*v;
u=FAV(a); // point to u in u&.v. v is f1&g1 or (f1 g1 h1)
if(b1=CSLASH==(uid=u->id)){x=u->fgh[0]; if(AT(x)&VERB){u=FAV(x);uid=u->id;}else uid=0;} // uid=id of u; b1=u is x/, then uid=id of x cases: f&.{f1&g1 or (f1 g1 h1)} b1=0 f/&.{f1&g1 or (f1 g1 h1)} b1=1
b=CBDOT==uid&&(x=u->fgh[1],(((AR(x)-1)&SGNIF(AT(x),INTX))<0)&&BETWEENC(IAV(x)[0],16,32)); // b if f=m b. or m b./ where m is atomic int 16<=m<=32
C vv=IDD(v->fgh[1]); //
if(CIOTA==vv&&(!c)&&equ(ds(CALP),v->fgh[0])){ // w is {a.&i. or (a. i. ][)}
C vv=IDD(v->fgh[1]); // id of g1
if(CIOTA==vv&&(!c)&&equ(ds(CALP),v->fgh[0])){ // w is {a.&i. or (a. i. ][)} scaf use addr of a.
f1=b&b1?jtbitwiseinsertchar:jtunderai1; // m b./ &. {a.&i. or (a. i. ][)} or f &. {a.&i. or (a. i. ][)}
// scaf lose underai1; add {&.(a.&i.)
f2=((uid^CMIN)>>1)+b1?f2:(AF)jtcharfn2; f2=b>b1?(AF)jtbitwisechar:f2; // {>. or <.} &. {a.&i. or (a. i. ][)} or m b. &. {a.&i. or (a. i. ][)}
flag&=~(VJTFLGOK1|VJTFLGOK2); // not perfect, but ok
}
Expand Down
4 changes: 2 additions & 2 deletions jsrc/xb.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ F1(jtltrim){I stride,ln,lh,n,ar,*pi;A z=0;C *u,*v;I as[63];
// w is a box, result is 1 if it contains a NaN
static B jtisnanq(J jt,A w){
ARGCHK1(w);
if(AT(w)&FL+CMPX){D *v=DAV(w); DQ(AN(w)<<((AT(w)>>CMPXX)&1), if(_isnan(v[i]))R 1;);} // if there might be a NaN, return if there is one
if(AT(w)&FL+CMPX+QP){D *v=DAV(w); I stride=AT(w)&QP?2:1; DQ(AN(w)<<((AT(w)>>CMPXX)&1), if(_isnan(*v))R 1; v+=stride;);} // if there might be a NaN, return if there is one
else if(AT(w)&BOX){A *v=AAV(w); STACKCHKOFL DQ(AN(w), if(isnanq(C(v[i])))R 1;);} // if boxed, check each one recursively; ensure no stack overflow
// other types never have NaN
R 0; // if we get here, there must be no NaN
Expand All @@ -737,7 +737,7 @@ F1(jtisnan){A*wv,z;B*u;D*v;I n,t;
n=AN(w); t=AT(w);
ASSERT(!ISSPARSE(t),EVNONCE);
I zr=AR(w); GATV(z,B01,n,AR(w),AS(w)); u=BAVn(zr,z);
if (t&FL){v=DAV(w); DQ(n, *u++=_isnan(*v++););} // float - check each atom
if (t&FL+QP){v=DAV(w); I stride=t&FL?1:2; DQ(n, *u++=_isnan(*v); v+=stride;);} // float/qp - check each atom (high part for qp)
else if(t&CMPX){v=DAV(w); DQ(n, *u++=_isnan(v[0])|_isnan(v[1]); v+=2;);} // complex - check each half
else if(t&BOX){wv=AAV(w); DO(n, *u++=isnanq(C(wv[i]));); RE(0);} // boxed - check contents
else mvc(n,u,MEMSET00LEN,MEMSET00); // other types are never NaN
Expand Down
6 changes: 6 additions & 0 deletions test/g128x5.ijs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ b=: (#x) ?@$ 2
x=: (-~0j1)+_. (I.b)}x
b -: isnan x

0 1 0 -: 128!:5 (11) c. 0 _. 5
0 0 0 1 0 -: 128!:5 (11) c. 0 3 4 _. 5
0 1 0 -: 128!:5 ] 0;(11 c. _.);5
0 1 0 -: 128!:5 ] 0;(11 c. 0 0 0 0 0 0 _.);5


'valence error' -: 0 (128!:5) etx 3 4 5
'valence error' -: 1 (128!:5) etx 3 4 5

Expand Down

0 comments on commit 1487a64

Please sign in to comment.