don't unroll arr_csz

This commit is contained in:
dzaima 2022-05-29 13:57:03 +03:00
parent bf618b9b64
commit 3dd1bffe2f
5 changed files with 7 additions and 7 deletions

View File

@ -225,7 +225,7 @@ B scan_c2(Md1D* d, B w, B x) { B f = d->f;
if (isArr(w)) {
ur wr = rnk(w); usz* wsh = a(w)->sh; SGet(w)
if (wr+1!=xr || !eqShPrefix(wsh, xsh+1, wr)) thrF("`: Shape of 𝕨 must match the cell of 𝕩 (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
if (wr+1!=xr || !eqShPart(wsh, xsh+1, wr)) thrF("`: Shape of 𝕨 must match the cell of 𝕩 (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
if (ia==0) return x;
usz csz = arr_csz(x);
for (; i < csz; i++) r.a[i] = fc2(f, Get(w,i), xget(xa,i));

View File

@ -1281,7 +1281,7 @@ static B takedrop_ucw(i64 wi, B o, u64 am, B x, size_t xr) {
B rep = c1(o, taga(arg));
if (isAtm(rep)) thrM("𝔽⌾(n⊸↑): 𝔽 returned an atom");
usz* repsh = a(rep)->sh;
if (rnk(rep)==0 || !eqShPrefix(repsh+1, a(x)->sh+1, xr-1) || repsh[0]!=am) thrM("𝔽⌾(n⊸↑)𝕩: 𝔽 returned an array with a different shape than n↑𝕩");
if (rnk(rep)==0 || !eqShPart(repsh+1, a(x)->sh+1, xr-1) || repsh[0]!=am) thrM("𝔽⌾(n⊸↑)𝕩: 𝔽 returned an array with a different shape than n↑𝕩");
MAKE_MUT(r, xia);
mut_init(r, el_or(TI(x,elType), TI(rep,elType))); MUTG_INIT(r);

View File

@ -762,7 +762,7 @@ B bqn_merge(B x) {
usz rp = 0;
for (usz i = 0; i < xia; i++) {
B c = GetU(x, i);
if (isArr(c)? (elR!=rnk(c) || !eqShPrefix(elSh, a(c)->sh, elR)) : elR!=0) { mut_pfree(r, rp); thrF(">: Elements didn't have equal shapes (contained shapes %H and %H)", x0, c); }
if (isArr(c)? (elR!=rnk(c) || !eqShPart(elSh, a(c)->sh, elR)) : elR!=0) { mut_pfree(r, rp); thrF(">: Elements didn't have equal shapes (contained shapes %H and %H)", x0, c); }
if (isArr(c)) mut_copy(r, rp, c, 0, elIA);
else mut_set(r, rp, inc(c));
if (!noFill(fill)) fill = fill_or(fill, getFillQ(c));

View File

@ -86,10 +86,10 @@ static usz arr_csz(B x) {
if (xr<=1) return 1;
usz* sh = a(x)->sh;
usz r = 1;
for (i32 i = 1; i < xr; i++) r*= sh[i];
NOUNROLL for (i32 i = 1; i < xr; i++) r*= sh[i];
return r;
}
static bool eqShPrefix(usz* w, usz* x, ur len) {
static bool eqShPart(usz* w, usz* x, usz len) {
return memcmp(w, x, len*sizeof(usz))==0;
}
static bool eqShape(B w, B x) { assert(isArr(w)); assert(isArr(x));
@ -97,7 +97,7 @@ static bool eqShape(B w, B x) { assert(isArr(w)); assert(isArr(x));
ur xr = rnk(x); usz* xsh = a(x)->sh;
if (wr!=xr) return false;
if (wsh==xsh) return true;
return eqShPrefix(wsh, xsh, wr);
return eqShPart(wsh, xsh, wr);
}
B bit_sel(B b, B e0, bool h0, B e1, bool h1); // consumes b; h0/h1 represent whether the corresponding element _might_ be in the result (can be true if unknown)

View File

@ -17,7 +17,7 @@ B eachd_fn(BBB2B f, B fo, B w, B x) {
decG(w); decG(x);
return m_hunit(r);
}
if (rm && !eqShPrefix(a(w)->sh, a(x)->sh, rm)) thrF("Mapping: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
if (rm && !eqShPart(a(w)->sh, a(x)->sh, rm)) thrF("Mapping: Expected equal shape prefix (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
bool rw = rM==wr && ((v(w)->type==t_harr) & reusable(w)); // v(…) is safe as rank>0
bool rx = rM==xr && ((v(x)->type==t_harr) & reusable(x));
if (rw|rx && (wr==xr | rm==0)) {