fast 𝔽⌾(num⊸⊏)arr
This commit is contained in:
parent
07f9b640e9
commit
d2c27fd880
@ -967,16 +967,24 @@ B select_rows_B(B x, ux csz, ux cam, B inds) { // consumes inds,x; ⥊ inds⊸
|
|||||||
}
|
}
|
||||||
|
|
||||||
B select_ucw(B t, B o, B w, B x) {
|
B select_ucw(B t, B o, B w, B x) {
|
||||||
if (isAtm(x) || isAtm(w)) { def: return def_fn_ucw(t, o, w, x); }
|
if (RARE(isAtm(x))) { def: return def_fn_ucw(t, o, w, x); }
|
||||||
usz xia = IA(x);
|
u8 we;
|
||||||
usz wia = IA(w);
|
if (isAtm(w)) {
|
||||||
u8 we = TI(w,elType);
|
if (RARE(!isNum(w))) goto def;
|
||||||
if (!elInt(we) && IA(w)!=0) {
|
w = m_unit(w);
|
||||||
w = num_squeezeChk(w); we = TI(w,elType);
|
we = TI(w,elType);
|
||||||
if (!elNum(we)) goto def;
|
assert(elNum(we));
|
||||||
|
} else {
|
||||||
|
we = TI(w,elType);
|
||||||
|
if (!elInt(we) && IA(w)!=0) {
|
||||||
|
w = num_squeezeChk(w); we = TI(w,elType);
|
||||||
|
if (!elNum(we)) goto def;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
usz wia = IA(w);
|
||||||
B rep;
|
B rep;
|
||||||
if (isArr(o) && RNK(x)>0) {
|
if (isArr(o) && RNK(x)>0) {
|
||||||
|
usz xia = IA(x);
|
||||||
i64 buf[2];
|
i64 buf[2];
|
||||||
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xia || buf[1]>=xia)) {
|
if (wia!=0 && (!getRange_fns[we](tyany_ptr(w), buf, wia) || buf[0]<-(i64)xia || buf[1]>=xia)) {
|
||||||
C2(select, w, x);
|
C2(select, w, x);
|
||||||
|
|||||||
@ -30,6 +30,10 @@
|
|||||||
|
|
||||||
# ⊑
|
# ⊑
|
||||||
!"𝔽⌾(a⊸⊑): Incompatible result elements" % 10‿20⌾(⟨1‿2,1‿2⟩⊸⊑) 4‿5⥊↕9
|
!"𝔽⌾(a⊸⊑): Incompatible result elements" % 10‿20⌾(⟨1‿2,1‿2⟩⊸⊑) 4‿5⥊↕9
|
||||||
|
!"Expected integer, got character" % 1⊸+⌾('a'⊸⊑) "hello"
|
||||||
|
!"Expected integer, got 1.5" % 1⊸+⌾(1.5⊸⊑) "hello"
|
||||||
|
!"𝔽⌾(n⊸⊑)𝕩: reading out-of-bounds (n≡100, 5≡≠𝕩)" % 1⊸+⌾(100⊸⊑) "hello"
|
||||||
|
!"𝕨⊑𝕩: 𝕩 must be a list when 𝕨 is a number (4‿4 ≡ ≢𝕩)" % 1⊸+⌾(100⊸⊑) 4‿4⥊↕16
|
||||||
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 10‿20‿30⌾(⟨1‿2,2‿1⟩⊸⊑) 4‿4⥊↕16
|
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 10‿20‿30⌾(⟨1‿2,2‿1⟩⊸⊑) 4‿4⥊↕16
|
||||||
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 1⌾((<⋈2)⊸⊑) ↕10
|
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 1⌾((<⋈2)⊸⊑) ↕10
|
||||||
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 1⌾((<1‿2)⊸⊑) 3‿3⥊↕9
|
!"𝔽⌾(nested⊸⊑)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 1⌾((<1‿2)⊸⊑) 3‿3⥊↕9
|
||||||
@ -58,6 +62,10 @@ a←10‿10‿10⥊↕1000 ⋄ ! a ≡ a⌾((↕≢a)⊸⊑) a
|
|||||||
# ⊏
|
# ⊏
|
||||||
n←500 ⋄ a←↕n ⋄ i←(-n)+↕2×n ⋄ r←⌽(2×n)⥊a ⋄ ! (⌽a) ≡ r⌾(i⊸⊏) a
|
n←500 ⋄ a←↕n ⋄ i←(-n)+↕2×n ⋄ r←⌽(2×n)⥊a ⋄ ! (⌽a) ≡ r⌾(i⊸⊏) a
|
||||||
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % 0‿0⌾(0‿0⊸⊏) <0
|
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % 0‿0⌾(0‿0⊸⊏) <0
|
||||||
|
!"Expected integer, got character" % 1⊸+⌾('a'⊸⊏) "hello"
|
||||||
|
!"Expected integer, got 1.5" % 1⊸+⌾(1.5⊸⊏) "hello"
|
||||||
|
!"𝕨⊏𝕩: Indexing out-of-bounds (100∊𝕨, 5≡≠𝕩)" % 1⊸+⌾(100⊸⊏) "hello"
|
||||||
|
!"𝕨⊏𝕩: Indexing out-of-bounds (100∊𝕨, 4≡≠𝕩)" % 1⊸+⌾(100⊸⊏) 4‿4⥊↕16
|
||||||
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % %USE evar ⋄ (↕0) {⊢⌾(𝕨⊸⊏)𝕩}_evar <0
|
!"𝕨⊏𝕩: 𝕩 cannot be a unit" % %USE evar ⋄ (↕0) {⊢⌾(𝕨⊸⊏)𝕩}_evar <0
|
||||||
!"𝕨⊏𝕩: Indexing out-of-bounds (¯11∊𝕨, 10≡≠𝕩)" % %USE evar ⋄ 5‿¯11 {0‿1⌾(𝕨⊸⊏)𝕩}_evar 10⥊1‿0‿1
|
!"𝕨⊏𝕩: Indexing out-of-bounds (¯11∊𝕨, 10≡≠𝕩)" % %USE evar ⋄ 5‿¯11 {0‿1⌾(𝕨⊸⊏)𝕩}_evar 10⥊1‿0‿1
|
||||||
!"𝕨⊏𝕩: Indexing out-of-bounds (10∊𝕨, 10≡≠𝕩)" % %USE evar ⋄ 9‿10 {0‿1⌾(𝕨⊸⊏)𝕩}_evar 10⥊1‿0‿1
|
!"𝕨⊏𝕩: Indexing out-of-bounds (10∊𝕨, 10≡≠𝕩)" % %USE evar ⋄ 9‿10 {0‿1⌾(𝕨⊸⊏)𝕩}_evar 10⥊1‿0‿1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user