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

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