Direct ⍷bool implementation
This commit is contained in:
parent
f1142b4184
commit
93ef4bb2a9
@ -3,16 +3,14 @@
|
|||||||
// Except for trivial cases, ⍷ is implemented as ∊⊸/
|
// Except for trivial cases, ⍷ is implemented as ∊⊸/
|
||||||
// Other functions use adaptations of the same set of methods
|
// Other functions use adaptations of the same set of methods
|
||||||
|
|
||||||
// Boolean ∊: 1 at first element and first ¬⊑𝕩
|
// Boolean cases all use special code, including ⍷
|
||||||
// Boolean ⊒: Branchless sum thing
|
|
||||||
// COULD vectorize boolean ⊒ with +`
|
// COULD vectorize boolean ⊒ with +`
|
||||||
// Boolean ⊐: ⥊¬⍟⊑𝕩
|
// Sorted flags: start with r0⌾⊑»⊸≠𝕩 (r0←0 for ⊐, 1 otherwise)
|
||||||
// SHOULD implement boolean ⍷ directly
|
|
||||||
// Sorted flags: start with r0⌾⊑»⊸≠𝕩 (r0 is 0 for ⊐ and 1 otherwise)
|
|
||||||
// ∊: ⊢; ⊐: +`; ⊒: ↕∘≠⊸(⊣-⌈`∘×)
|
// ∊: ⊢; ⊐: +`; ⊒: ↕∘≠⊸(⊣-⌈`∘×)
|
||||||
// COULD determine ⊒ result type by direct comparisons on 𝕩
|
// COULD determine ⊒ result type by direct comparisons on 𝕩
|
||||||
// Brute force or all-pairs comparison for small lengths
|
// Brute force or all-pairs comparison for small lengths
|
||||||
// Branchless, not vectorized (+´∧` structure for ⊐)
|
// Branchless, not vectorized (+´∧` structure for ⊐)
|
||||||
|
// COULD use direct all-pairs filter, not ∊⊸/, for short ⍷
|
||||||
// Full-size table lookups for 1- and 2-byte 𝕩
|
// Full-size table lookups for 1- and 2-byte 𝕩
|
||||||
// 2-byte table can be "sparse" initialized with an extra pass over 𝕩
|
// 2-byte table can be "sparse" initialized with an extra pass over 𝕩
|
||||||
// 4-byte ⊐ can use a small-range lookup table
|
// 4-byte ⊐ can use a small-range lookup table
|
||||||
@ -29,6 +27,8 @@
|
|||||||
// Generic hash table for other cases
|
// Generic hash table for other cases
|
||||||
// Resizing is pretty expensive here
|
// Resizing is pretty expensive here
|
||||||
|
|
||||||
|
// SHOULD widen small odd sizes
|
||||||
|
|
||||||
#include "../core.h"
|
#include "../core.h"
|
||||||
#include "../utils/hash.h"
|
#include "../utils/hash.h"
|
||||||
#include "../utils/talloc.h"
|
#include "../utils/talloc.h"
|
||||||
@ -510,5 +510,13 @@ B find_c1(B t, B x) {
|
|||||||
if (isAtm(x) || RNK(x)==0) thrM("⍷: Argument cannot have rank 0");
|
if (isAtm(x) || RNK(x)==0) thrM("⍷: Argument cannot have rank 0");
|
||||||
usz n = *SH(x);
|
usz n = *SH(x);
|
||||||
if (n<=1) return x;
|
if (n<=1) return x;
|
||||||
|
if (TI(x,elType)==el_bit && RNK(x)==1) {
|
||||||
|
u64* xp = bitarr_ptr(x);
|
||||||
|
u64 x0 = 1 & *xp;
|
||||||
|
usz i = bit_find(xp, n, !x0); decG(x);
|
||||||
|
u64* rp; B r = m_bitarrv(&rp, 1 + (i<n));
|
||||||
|
rp[0] = 2 ^ -x0;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
return C2(slash, C1(memberOf, inc(x)), x);
|
return C2(slash, C1(memberOf, inc(x)), x);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user