fix ∾2‿2⥊<0‿0⥊⟨⟩

This commit is contained in:
dzaima 2024-09-22 01:42:26 +03:00
parent f65906721d
commit 989970f7fd
2 changed files with 52 additions and 38 deletions

View File

@ -882,52 +882,60 @@ B join_c1(B t, B x) {
} }
st[a] = len; st[a] = len;
} }
// Move the data // Shapes known correct; move the data
usz* csh = tr ? SH(x0) + r0-tr : NULL; // Trailing shape usz* csh = tr ? SH(x0) + r0-tr : NULL; // Trailing shape
usz csz = shProd(csh, 0, tr); usz csz = shProd(csh, 0, tr);
MAKE_MUT(r, shProd(st, 0, xr)*csz); usz ria = shProd(st, 0, xr);
// Element index and effective shape, updated progressively if (mulOn(ria, csz)) thrOOM();
usz *ei =tsh; for (usz i=0; i<xr; i++) ei [i]=0; Arr* ra;
usz ri = 0; if (ria>0) {
usz *ll = lp+lp[xr-1]; MAKE_MUT(r, ria);
for (usz i = 0;;) { // Element index and effective shape, updated progressively
B e = GetU(x, i); usz *ei =tsh; for (usz i=0; i<xr; i++) ei [i]=0;
usz l = ll[ei[xr-1]] * csz; usz ri = 0;
if (RARE(isAtm(e))) { usz *ll = lp+lp[xr-1];
assert(l==1); for (usz i = 0;;) {
mut_set(r, ri, inc(e)); B e = GetU(x, i);
} else { usz l = ll[ei[xr-1]] * csz;
usz eia = IA(e); if (RARE(isAtm(e))) {
if (eia) { assert(l==1);
usz rj = ri; mut_set(r, ri, inc(e));
usz *ii=tsh0; for (usz k=0; k<xr-1; k++) ii[k]=0; } else {
usz str0 = st[xr-1]*csz; usz eia = IA(e);
for (usz j=0;;) { if (eia) {
mut_copy(r, rj, e, j, l); usz rj = ri;
j+=l; if (j==eia) break; usz *ii=tsh0; for (usz k=0; k<xr-1; k++) ii[k]=0;
usz str = str0; usz str0 = st[xr-1]*csz;
rj += str; for (usz j=0;;) {
for (usz a = xr-2; RARE(++ii[a] == lp[lp[a]+ei[a]]); a--) { mut_copy(r, rj, e, j, l);
rj -= ii[a]*str; j+=l; if (j==eia) break;
ii[a] = 0; usz str = str0;
str *= st[a];
rj += str; rj += str;
for (usz a = xr-2; RARE(++ii[a] == lp[lp[a]+ei[a]]); a--) {
rj -= ii[a]*str;
ii[a] = 0;
str *= st[a];
rj += str;
}
} }
} }
} }
if (++i == xia) break;
ri += l;
usz str = csz;
for (usz a = xr-1; RARE(++ei[a] == xsh[a]); ) {
ei[a] = 0;
str *= st[a];
a--;
ri += (lp[lp[a]+ei[a]]-1) * str;
}
} }
if (++i == xia) break; ra = mut_fp(r);
ri += l; } else {
usz str = csz; ra = (Arr*) m_harrUp(0).c;
for (usz a = xr-1; RARE(++ei[a] == xsh[a]); ) {
ei[a] = 0;
str *= st[a];
a--;
ri += (lp[lp[a]+ei[a]]-1) * str;
}
} }
Arr* ra = mut_fp(r);
usz* sh = arr_shAlloc(ra, xr+tr); usz* sh = arr_shAlloc(ra, xr+tr);
shcpy(sh , st , xr); shcpy(sh , st , xr);
shcpy(sh+xr, csh, tr); shcpy(sh+xr, csh, tr);

View File

@ -193,6 +193,12 @@ w←1‿1⥊1 ⋄ x←2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨•Repr𝕩,": Expe
"ab", 12, "de" %% 'a','b',12,'d','e' "ab", 12, "de" %% 'a','b',12,'d','e'
!"∾: Item trailing shapes must be equal (contained arrays with shapes 3‿3 and 3‿4)" % 33,34 !"∾: Item trailing shapes must be equal (contained arrays with shapes 3‿3 and 3‿4)" % 33,34
!"∾: Item trailing shapes must be equal (contained arrays with shapes ⟨2⟩ and 3‿3)" % 12,33 !"∾: Item trailing shapes must be equal (contained arrays with shapes ⟨2⟩ and 3‿3)" % 12,33
!"∾: Item ranks along an axis can differ by at most one (contained ranks 1 and 3 along axis 0)" % 21 0¨ 023, 0
!"∾: Incompatible item shapes (contained arrays with shapes 1‿0 and 1‿0 along axis 1)" % {1𝕩0}¨ [01, 00]
!"∾: Incompatible item ranks" % 0¨ [0101, 011]
33<1030 %% 3030
33<00 %% 00
133<103<"hi" %% " "
# 𝕨∾𝕩 # 𝕨∾𝕩
!"∾: Lengths not matchable (⟨6⟩ ≡ ≢𝕨, 1‿1 ≡ ≢𝕩)" % ("abc""def")"a" !"∾: Lengths not matchable (⟨6⟩ ≡ ≢𝕨, 1‿1 ≡ ≢𝕩)" % ("abc""def")"a"