faster 2↕

This commit is contained in:
dzaima 2023-02-18 19:47:22 +02:00
parent 7b57b4ae39
commit 96316f0fe1

View File

@ -84,6 +84,8 @@ B ud_c1(B t, B x) {
return taga(r); return taga(r);
} }
B slash_c2(B t, B w, B x);
B ud_c2(B t, B w, B x) { B ud_c2(B t, B w, B x) {
usz wia=1; usz wia=1;
if (isArr(w)) { if (isArr(w)) {
@ -124,12 +126,16 @@ B ud_c2(B t, B w, B x) {
decG(x); decG(x);
return taga(ra); return taga(ra);
} }
if (wr==1 && wsh[0]==2 && xr==1) {
B t = C2(slash, w, x);
return taga(arr_shSetU(TI(t,slice)(t, 1, IA(t)-2), 2, sh));
}
ur fr=2*wr; // Frame rank in result ur fr=2*wr; // Frame rank in result
usz cia=1; // Cell length usz cia=1; // Cell length
for (usz i=fr; i<rr; i++) if (mulOn(cia, rsh[i])) thrM("↕: result shape too large"); for (usz i=fr; i<rr; i++) if (mulOn(cia, rsh[i])) thrM("↕: result shape too large");
usz ria=cia; usz ria=cia;
for (usz i=0; i<fr; i++) if (mulOn(ria, rsh[i])) thrM("↕: result shape too large"); for (usz i=0; i<fr; i++) if (mulOn(ria, rsh[i])) thrM("↕: result shape too large");
B xf = getFillQ(x);
TALLOC(usz, ri, fr-1); TALLOC(usz, ri, fr-1);
MAKE_MUT(r, ria); mut_init(r, TI(x,elType)); MAKE_MUT(r, ria); mut_init(r, TI(x,elType));
MUTG_INIT(r); MUTG_INIT(r);
@ -153,7 +159,9 @@ B ud_c2(B t, B w, B x) {
} }
} }
} }
decG(x); TFREE(ri); TFREE(ri);
B xf = getFillQ(x);
decG(x);
return withFill(taga(arr_shSetU(mut_fp(r), rr, sh)), xf); return withFill(taga(arr_shSetU(mut_fp(r), rr, sh)), xf);
} }