fast highrank⊸⊏˘ table

This commit is contained in:
dzaima 2024-12-02 21:53:45 +02:00
parent 7509d0c238
commit 81abc80863
3 changed files with 18 additions and 7 deletions

View File

@ -701,19 +701,24 @@ NOINLINE B for_cells_SA(B f, B w, B x, ur xcr, ur xr, u32 chr) { // w⊸F⎉xcr
case n_rtack: dec(w); return x;
case n_ltack: return const_cells(x, xk, xsh, w, chr);
case n_select:
if (isArr(w) && RNK(w)==1 && xcr==1) { // TODO handle RNK(w)!=1
if (isArr(w) && xcr==1) {
if (!TI(w,arrD1)) {
w = num_squeezeChk(w);
if (!TI(w,arrD1)) break;
}
assert(xr > 1);
ux wia = IA(w);
ShArr* rsh = m_shArr(xr);
ur wr = RNK(w);
if (wr == 0) {
usz ind = WRAP(o2i64(IGetU(w,0)), xsh[xk], break);
decG(w);
return select_cells(ind, x, cam, xk, false);
}
ur rr = xk+wr;
ShArr* rsh = m_shArr(rr);
shcpy(rsh->a, xsh, xk);
rsh->a[xk] = wia;
shcpy(rsh->a+xk, SH(w), wr);
Arr* r = customizeShape(select_rows_B(x, shProd(xsh,xk,xr), cam, w));
arr_shSetUG(r, xr, rsh);
return taga(r);
return taga(arr_shSetUG(r, rr, rsh));
}
if (isF64(w) && xcr>=1) {
usz l = xsh[xk];

View File

@ -903,7 +903,7 @@ B select_rows_direct(B x, ux csz, ux cam, void* inds, ux indn, u8 ie) { // ⥊ (
return r;
}
B select_rows_B(B x, ux csz, ux cam, B inds) { // consumes inds,x; ⥊ inds⊸⊏˘ cam‿csz⥊x
B select_rows_B(B x, ux csz, ux cam, B inds) { // consumes inds,x; ⥊ inds⊸⊏˘ cam‿csz⥊x; if inds isn't rank 1, result may or may not be high rank
assert(csz*cam == IA(x));
if (csz==0) goto generic;
if (cam<=1) {

View File

@ -97,11 +97,17 @@
!"⊏: Indexing out-of-bounds (1000∊𝕨, 3≡≠𝕩)" % %USE evar (31000) {𝕨˘𝕩}_evar 10031
!"⊏: Indexing out-of-bounds (1000∊𝕨, 4≡≠𝕩)" % %USE evar (41000) {𝕨˘𝕩}_evar 10041
!"⊏: Indexing out-of-bounds (1000∊𝕨, 8≡≠𝕩)" % %USE evar (81000) {𝕨˘𝕩}_evar 10081
!"⊏: Indexing out-of-bounds (100∊𝕨, 8≡≠𝕩)" % %USE evar (<100) {𝕨˘𝕩}_evar 10081
!"Integer out of range: 9e99" % %USE evar (<9e99) {𝕨˘𝕩}_evar 10081
12˘ 108100 %% (8×10) + 12
12˘ 1042100 %% (8×10) + [23,45]
12,1,0˘ 1042100 %% (8×10) + [32,54]
[21,45]˘ 108100 %% (8×10) + [21,45]
[11,01]˘ 1022100 %% (4×10) + 22223230123
%USE eqvar [213,457] {𝕨˘ 𝕩}_eqvar 108100 %% (8×10) + [213,457]
%USE eqvar [213,457] {𝕨1𝕩}_eqvar 348100 %% (348×12) + [213,457]
%USE eqvar [213,457] {𝕨˘ 𝕩}_eqvar 18100 %% [213,457]
%USE eqvar (<2) {𝕨˘𝕩}_eqvar 108100 %% 2 + 8×10
˘ 10110 %% 10
˘ 101330 %% 10330