various fill improvements

This commit is contained in:
dzaima 2023-04-28 20:23:52 +03:00
parent 7a501ffbdf
commit 7dd677a4e2
4 changed files with 12 additions and 19 deletions

View File

@ -298,11 +298,12 @@ B group_c2(B t, B w, B x) {
Arr* r = m_fillarr0p(ria);
B xf = getFillQ(x);
incBy(xf, ria);
B* rp = fillarr_ptr(r);
for (usz i = 0; i < ria; i++) {
Arr* c = m_fillarrp(len[i]);
c->ia = 0;
fillarr_setFill(c, inc(xf));
fillarr_setFill(c, xf);
NOGC_E; // see comments in group_simple
arr_shVec(c);
rp[i] = taga(c);

View File

@ -757,7 +757,7 @@ B join_c1(B t, B x) {
cam += cr < rm ? 1 : *csh++;
if (!eqShPart(csh, esh, cr-1)) thrF("∾: Item trailing shapes must be equal (contained arrays with shapes %H and %H)", x0, c);
}
if (SFNS_FILLS && !noFill(rf)) rf = fill_or(rf, getFillQ(c));
if (SFNS_FILLS && !noFill(rf) && !fillEqualsGetFill(rf, c)) rf = bi_noFill;
}
if (rm==0) thrM("∾: Some item rank must be equal or greater than rank of argument");
@ -843,7 +843,7 @@ B join_c1(B t, B x) {
ur cr=0; usz* sh=NULL; if (!isAtm(c)) { cr=RNK(c); sh=SH(c); }
if (cr != r1-rd) thrF("∾: Incompatible item ranks", base, c);
if (!eqShPart(rd?tsh0:tsh, sh, cr)) thrF("∾: Incompatible item shapes (contained arrays with shapes %H and %H along axis %i)", base, c, a);
if (SFNS_FILLS && !noFill(rf)) rf = fill_or(rf, getFillQ(c));
if (SFNS_FILLS && !noFill(rf) && !fillEqualsGetFill(rf, c)) rf = bi_noFill;
}
}
tr -= a0;

View File

@ -99,11 +99,9 @@ NOINLINE bool fillEqualF(B w, B x) { // doesn't consume; both args must be array
u8 we = TI(w,elType);
u8 xe = TI(x,elType);
if (we!=el_B && xe!=el_B) {
return elChr(we) == elChr(xe);
}
SGetU(x)
SGetU(w)
if (we!=el_B && xe!=el_B) return elNum(we) == elNum(xe);
SGetU(x) SGetU(w)
for (usz i = 0; i < ia; i++) if(!fillEqual(GetU(w,i),GetU(x,i))) return false;
return true;
}

View File

@ -101,21 +101,15 @@ static Arr* m_fillarr0p(usz ia) { // zero-initialized fillarr, with both fill &
B m_unit(B x); // consumes
B m_atomUnit(B x); // consumes
static B fill_or(B wf, B xf) { // consumes
if (fillEqual(wf, xf)) {
dec(wf);
return xf;
}
dec(wf); dec(xf);
return bi_noFill;
}
static bool fillEqualsGetFill(B fill, B obj) { // equal to fill_or(fill, getFillQ(obj))
static bool fillEqualsGetFill(B fill, B obj) { // returns whether `fill` equals the fill of `obj`
return fillEqual(fill, getFillN(obj));
}
static B fill_both(B w, B x) { // doesn't consume
B wf = getFillQ(w);
B wf = getFillN(w);
if (noFill(wf)) return bi_noFill;
B xf = getFillQ(x);
return fill_or(wf, xf);
if (fillEqual(wf, xf)) return xf;
dec(xf);
return bi_noFill;
}