Skip to content

Commit b2c9875

Browse files
committed
Fix erroneous memcpy
1 parent c43438d commit b2c9875

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

jsrc/vf.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ F2(jtrotate){A origw=w,z;C *u,*v;I acr,af,ar,*av,d,k,m,n,p,*s,wcr,wf,wn,wr;
137137
if(jt->fill){
138138
// if there is fill, we can do the rotate inplace
139139
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
140+
z=0&&ASGNINPLACESGN(SGNIF(jtinplace,JTINPLACEWX),w)?w:z; // could inplace if source & target of unfilled area don't overlap. Better to try extension a la apip
141141
}
142142
u=CAV(w); wn=AN(w); s=AS(w); k=bpnoun(AT(w));
143143
if(z==0)GA(z,AT(w),wn,wr,s); v=CAV(z); // allocate result area, unless we are inplacing into w
@@ -147,7 +147,8 @@ F2(jtrotate){A origw=w,z;C *u,*v;I acr,af,ar,*av,d,k,m,n,p,*s,wcr,wf,wn,wr;
147147
if(1<p){A y=z;
148148
// more than 1 axis: we ping-pong between buffers as we go down the axes.
149149
// Start here with input in z/v; put output in y/u so result will be in z at end of loop
150-
if(!jt->fill)GA(y,AT(w),wn,wr,s); C *u=CAV(y); // if fill, z is always inplaceable and we keep using it
150+
// obsolete if(1||!jt->fill) // if fill, z is always inplaceable and we keep using it
151+
GA(y,AT(w),wn,wr,s); C *u=CAV(y); // before ping-pong, y/u is the previous input, i. e. the new output
151152
// obsolete b=0;
152153
s+=wf; // skip over w frame to get to the cell. We will start 1 axis in
153154
// obsolete 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
@@ -265,7 +266,7 @@ static A jtreshapesp(J jt,A a,A w,I wf,I wcr){A a1,e,t,x,y,z;B az,*b,wz;I an,*av
265266
// Give rndfn a chance to adjust the number. nlens is #axes before inner cell: wcr for ($,) 1 for $ wcr is cell-rank of w, if "r given
266267
static A jtreshapeblank(J jt, A a, A w, A rndfn, I nlens, I wcr){
267268
RZ(a=vib(a)); RZ(a=mkwris(a)) // convert to int, converting _ to IMAX; make it writable since we will change _
268-
I upos=IMAX, xprod=1; DO(AN(a), I xval=IAV(a)[i]; I nupos=xval==IMAX?i:upos; xval=xval==IMAX?1:xval; ASSERT(nupos<=upos,EVDOMAIN) upos=nupos; DPMULD(xprod,xval,xprod,ASSERT(0,EVLIMIT));) // multiple non-_, error if overflow of >1 _
269+
I upos=IMAX, xprod=1; DO(AN(a), DPMULDDECLS I xval=IAV(a)[i]; I nupos=xval==IMAX?i:upos; xval=xval==IMAX?1:xval; ASSERT(nupos<=upos,EVDOMAIN) upos=nupos; DPMULD(xprod,xval,xprod,ASSERT(0,EVLIMIT));) // multiple non-_, error if overflow of >1 _
269270
if(upos==IMAX)R a; // if x didn't contain _, just use it as is
270271
ASSERT(xprod!=0,EVDOMAIN); // if result is empty, we cannot calculate a value
271272
I nw; PRODX(nw,nlens,AS(w)+AR(w)-wcr,1) // calculate # cells in a wcr-cell of w: use all axes or just the first

test/g231.ijs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,13 +401,14 @@ _2 3 (|."1 2 -: rot"1 2) j./?2 2 3 7$1000
401401
0 1 2 3 (|."0 1 -: {{ x |. y }}"0 1) i. 4 5 6
402402
(2 2 1$0 1 2 3) (|."0 1 -: {{ x |. y }}"0 1) i. 2 6
403403

404+
1: 0 : 0
404405
NB. Inplace if fill
405406
a =: i. 1e6
406407
5000 > 7!:2 'a =: 5 |.!.0 a'
407408
a =: i. 100 100 100
408409
5000 > 7!:2 'a =: 5 6 |.!.0 a'
409410
5000 > 7!:2 'a =: 5 6 7 |.!.0 a'
410-
411+
)
411412

412413
NB. x|.!.f"r y ----------------------------------------------------------
413414

0 commit comments

Comments
 (0)