You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(p<=1){r=p?*av:0; ROTF(r); DQ(m, MC(v+jd,u+js,e-k); if(!jt->fill)MC(v+kd,u+ks,k); elsemvc(k,v+kd,atomsize,jt->fillv); u+=e; v+=e;);} // move fill last in case inplace
// special case: if a is atomic 0, and cells of w are not atomic
118
127
if((wcr!=0)&(((ar|IAV(a)[0])==0)))RRETARG(w); // 0 |. y, return y
119
-
if(((1-acr)|((-af)&(-acr|(wf-1))))<0)Rrank2ex(a,w,DUMMYSELF,MIN(acr,1),wcr,acr,wcr,jtrotate); // if multiple a-lists per cell, or a has frame and (a cell is not an atom or w has no frame) handle rank by using " for it
128
+
// We support IRS in a limited way. We revert to the rank loop if:
129
+
// 1 cell-rank of a>1 (we have to replicate w)
130
+
// 2 a has frame, if: cell-rank of a > 0 (we have to match cells of a)
131
+
// OR frame of w does not equal frame of a (agreement has already been checked in the caller, if IRS)
132
+
// (in the case where a and w frames are equal, we apply each atom of a to one cell of w since a cell-rank is 0)
133
+
if(((1-acr)|((-af)&(-acr|-(af^wf))))<0)Rrank2ex(a,w,DUMMYSELF,MIN(acr,1),wcr,acr,wcr,jtrotate); // revert if we can't match a and w easily
120
134
if(((wcr-1)&(1-p))<0){RZ(w=reshape(apip(shape(w),apv(p,1L,0L)),w)); wr=wcr=p;} // if cell is an atom, extend it up to #axes being rotated !wcr && p>1
RZ(w=setfv(w,w)); u=CAV(w); wn=AN(w); s=AS(w); k=bpnoun(AT(w)); // set fill value if given
124
-
GA(z,AT(w),wn,wr,s); v=CAV(z);
136
+
av=AV(a); z=0; // init no result allocated
137
+
if(jt->fill){
138
+
// if there is fill, we can do the rotate inplace
139
+
RZ(w=setfv(w,w)); // set fill value if given
140
+
z=ASGNINPLACESGN(SGNIF(jtinplace,JTINPLACEWX),w)?w:z; // inplace allowed, just one cell, result rank (an) <= current rank (so rank fits), usecount is right
141
+
}
142
+
u=CAV(w); wn=AN(w); s=AS(w); k=bpnoun(AT(w));
143
+
if(z==0)GA(z,AT(w),wn,wr,s); v=CAV(z); // allocate result area, unless we are inplacing into w
125
144
if(!wn)Rz;
126
145
PROD(m,wf,s); PROD(d,wr-wf-1,s+wf+1); SETICFR(w,wf,wcr,n); // m=#cells of w, n=#items per cell d=#atoms per item of cell
127
-
rot(m,d,n,k,1>=p?AN(a):1L,av,u,v);
146
+
rot(m,d,n,k,1>=p?AN(a):1L,av,u,v);// rotate first axis
128
147
if(1<p){
129
-
GA(y,AT(w),wn,wr,s); u=CAV(y);
148
+
// more than 1 axis: we ping-pong between buffers as we go down the axes
149
+
GA(y,AT(w),wn,wr,s); u=CAV(y); // scaf not needed if there is fill
130
150
b=0; s+=wf;
131
151
DO(p-1, m*=n; n=*++s; PROD(d,wr-wf-i-2,s+1); rot(m,d,n,k,1L,av+i+1,b?u:v,b?v:u); b^=1;); // s has moved past the frame
0 commit comments