fixes for /
This commit is contained in:
parent
1fcd5295eb
commit
bd823839fe
@ -339,6 +339,24 @@ static bool groups_lt(u64* wp, usz len, usz max) {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static NOINLINE B zeroCells(B x) { // doesn't consume
|
||||||
|
u8 xe = TI(x,elType);
|
||||||
|
B r; ur xr = RNK(x);
|
||||||
|
if (xr==1) {
|
||||||
|
if (xe==el_B) { B xf = getFillR(x); r = noFill(xf)? emptyHVec() : m_emptyFVec(xf); }
|
||||||
|
else r = elNum(xe)? emptyIVec() : emptyCVec();
|
||||||
|
} else {
|
||||||
|
Arr* ra;
|
||||||
|
if (xe==el_B) { B xf = getFillR(x); if (noFill(xf)) ra = (Arr*)m_harrUp(0).c; else { ra = m_fillarrp(0); fillarr_setFill(ra, xf); } }
|
||||||
|
else m_tyarrp(&ra, 1, 0, elNum(xe)? t_bitarr : t_c8arr);
|
||||||
|
usz* rsh = arr_shAlloc(ra, xr);
|
||||||
|
shcpy(rsh+1, SH(x)+1, xr-1);
|
||||||
|
rsh[0] = 0;
|
||||||
|
r = taga(ra);
|
||||||
|
}
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
extern B take_c2(B, B, B);
|
extern B take_c2(B, B, B);
|
||||||
static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
|
static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
|
||||||
u64* wp = bitarr_ptr(w);
|
u64* wp = bitarr_ptr(w);
|
||||||
@ -346,12 +364,7 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
|
|||||||
usz ie = wia/64;
|
usz ie = wia/64;
|
||||||
usz q=wia%64; if (q) we = wp[ie] &= ((u64)1<<q) - 1;
|
usz q=wia%64; if (q) we = wp[ie] &= ((u64)1<<q) - 1;
|
||||||
while (!we) {
|
while (!we) {
|
||||||
if (RARE(ie==0)) {
|
if (RARE(ie==0)) return zeroCells(x);
|
||||||
if (RNK(x)>1) return take_c2(m_f64(0), m_f64(0), inc(x));
|
|
||||||
u8 xe = TI(x,elType);
|
|
||||||
if (xe != el_B) return elNum(xe)? emptyIVec() : emptyCVec();
|
|
||||||
B xf = getFillQ(x); return q_N(xf)? emptyHVec() : m_emptyFVec(xf);
|
|
||||||
}
|
|
||||||
we = wp[--ie];
|
we = wp[--ie];
|
||||||
}
|
}
|
||||||
usz wia0 = wia;
|
usz wia0 = wia;
|
||||||
@ -453,7 +466,8 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
|
|||||||
usz b = 1<<10; \
|
usz b = 1<<10; \
|
||||||
for (usz k=0, j=0, ij=WV; ; ) { \
|
for (usz k=0, j=0, ij=WV; ; ) { \
|
||||||
usz e = b<s-k? k+b : s; \
|
usz e = b<s-k? k+b : s; \
|
||||||
SET; for (usz i=k; i<e; i++) rp[i]=0; \
|
for (usz i=k; i<e; i++) rp[i]=0; \
|
||||||
|
SET; \
|
||||||
while (ij<e) { j++; UPD; ij+=WV; } \
|
while (ij<e) { j++; UPD; ij+=WV; } \
|
||||||
SCAN; \
|
SCAN; \
|
||||||
if (e==s) {break;} k=e; \
|
if (e==s) {break;} k=e; \
|
||||||
@ -572,7 +586,8 @@ B slash_c2(B t, B w, B x) {
|
|||||||
} else {
|
} else {
|
||||||
atom:
|
atom:
|
||||||
if (!q_i32(w)) goto base;
|
if (!q_i32(w)) goto base;
|
||||||
wv = o2i(w);
|
wv = o2iG(w);
|
||||||
|
if (wv < 0) thrM("/: 𝕨 cannot be negative");
|
||||||
}
|
}
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("/: 𝕩 must have rank at least 1 for simple 𝕨");
|
if (isAtm(x) || RNK(x)==0) thrM("/: 𝕩 must have rank at least 1 for simple 𝕨");
|
||||||
ur xr = RNK(x);
|
ur xr = RNK(x);
|
||||||
@ -676,8 +691,9 @@ B slash_c2(B t, B w, B x) {
|
|||||||
goto decWX_ret;
|
goto decWX_ret;
|
||||||
} else {
|
} else {
|
||||||
if (wv <= 1) {
|
if (wv <= 1) {
|
||||||
if (wv < 0) thrM("/: 𝕨 cannot be negative");
|
if (wv || xlen==0) return x;
|
||||||
return wv ? x : taga(arr_shVec(TI(x,slice)(x, 0, 0)));
|
r = zeroCells(x);
|
||||||
|
goto decX_ret;
|
||||||
}
|
}
|
||||||
if (xlen == 0) return x;
|
if (xlen == 0) return x;
|
||||||
usz s = xlen * wv;
|
usz s = xlen * wv;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user