native high-rank ∊ & ⊐
This commit is contained in:
parent
3f40955d83
commit
95b1beb9db
@ -40,11 +40,34 @@ static u64 elRange(u8 eltype) { return 1ull<<(1<<elWidthLogBits(eltype)); }
|
|||||||
} \
|
} \
|
||||||
TFREE(tab0);
|
TFREE(tab0);
|
||||||
|
|
||||||
|
typedef struct { B n, p; } B2;
|
||||||
|
static NOINLINE B2 splitCells(B n, B p, bool indexOf) {
|
||||||
|
#define SYMB (indexOf? "⊐" : "∊")
|
||||||
|
#define ARG_N (indexOf? "𝕩" : "𝕨")
|
||||||
|
#define ARG_P (indexOf? "𝕨" : "𝕩")
|
||||||
|
if (isAtm(p) || RNK(p)==0) thrF("%U: %U cannot have rank 0", SYMB, ARG_P);
|
||||||
|
ur pr = RNK(p);
|
||||||
|
if (isAtm(n)) n = m_hunit(n);
|
||||||
|
ur nr = RNK(n);
|
||||||
|
if (nr < pr-1) thrF("%U: Rank of %U must be at least the cell rank of %U (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", SYMB, ARG_N, ARG_P, indexOf? p : n, indexOf? n : p);
|
||||||
|
ur cr = (pr>nr? nr : pr-1);
|
||||||
|
n = toKCells(n, nr-cr);
|
||||||
|
p = toKCells(p, pr-cr);
|
||||||
|
assert(RNK(p)<=1);
|
||||||
|
return (B2){.n=n, .p=p};
|
||||||
|
|
||||||
|
#undef ARG_N
|
||||||
|
#undef ARG_P
|
||||||
|
#undef SYMB
|
||||||
|
}
|
||||||
|
|
||||||
extern B rt_indexOf;
|
extern B rt_indexOf;
|
||||||
B indexOf_c2(B t, B w, B x) {
|
B indexOf_c2(B t, B w, B x) {
|
||||||
if (!isArr(w) || RNK(w)==0) thrM("⊐: 𝕨 must have rank at least 1");
|
if (RARE(!isArr(w) || RNK(w)!=1)) {
|
||||||
if (RNK(w)!=1) return c2(rt_indexOf, w, x);
|
B2 t = splitCells(x, w, true);
|
||||||
|
w = t.p;
|
||||||
|
x = t.n;
|
||||||
|
}
|
||||||
if (!isArr(x) || RNK(x)==0) {
|
if (!isArr(x) || RNK(x)==0) {
|
||||||
usz wia = IA(w);
|
usz wia = IA(w);
|
||||||
B el = isArr(x)? IGetU(x,0) : x;
|
B el = isArr(x)? IGetU(x,0) : x;
|
||||||
@ -123,7 +146,11 @@ B enclosed_0;
|
|||||||
B enclosed_1;
|
B enclosed_1;
|
||||||
extern B rt_memberOf;
|
extern B rt_memberOf;
|
||||||
B memberOf_c2(B t, B w, B x) {
|
B memberOf_c2(B t, B w, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=1) return c2(rt_memberOf, w, x);
|
if (isAtm(x) || RNK(x)!=1) {
|
||||||
|
B2 t = splitCells(w, x, false);
|
||||||
|
w = t.n;
|
||||||
|
x = t.p;
|
||||||
|
}
|
||||||
if (isAtm(w)) goto single;
|
if (isAtm(w)) goto single;
|
||||||
|
|
||||||
ur wr = RNK(w);
|
ur wr = RNK(w);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user