/i32arr
This commit is contained in:
parent
7df1b5d4a7
commit
81cdfa9cab
32
src/sfns.c
32
src/sfns.c
@ -307,28 +307,38 @@ B select_c2(B t, B w, B x) {
|
|||||||
return c2(rt_select, w, x);
|
return c2(rt_select, w, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
B rt_slash;
|
static NOINLINE B slash_c1R(B x, u64 s) {
|
||||||
B slash_c1(B t, B x) {
|
|
||||||
if (isAtm(x) || rnk(x)!=1) thrF("/: Argument must have rank 1 (%H ≡ ≢𝕩)", x);
|
|
||||||
i64 s = isum(x);
|
|
||||||
if(s<0) thrM("/: Argument must consist of natural numbers");
|
|
||||||
usz xia = a(x)->ia;
|
usz xia = a(x)->ia;
|
||||||
BS2B xgetU = TI(x).getU;
|
BS2B xgetU = TI(x).getU;
|
||||||
usz ri = 0;
|
f64* rp; B r = m_f64arrv(&rp, s); usz ri = 0;
|
||||||
if (xia<I32_MAX) {
|
for (usz i = 0; i < xia; i++) {
|
||||||
i32* rp; B r = m_i32arrv(&rp, s);
|
|
||||||
for (i32 i = 0; i < xia; i++) {
|
|
||||||
usz c = o2s(xgetU(x, i));
|
usz c = o2s(xgetU(x, i));
|
||||||
for (usz j = 0; j < c; j++) rp[ri++] = i;
|
for (usz j = 0; j < c; j++) rp[ri++] = i;
|
||||||
}
|
}
|
||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
f64* rp; B r = m_f64arrv(&rp, s);
|
B rt_slash;
|
||||||
for (usz i = 0; i < xia; i++) {
|
B slash_c1(B t, B x) {
|
||||||
|
if (RARE(isAtm(x)) || RARE(rnk(x)!=1)) thrF("/: Argument must have rank 1 (%H ≡ ≢𝕩)", x);
|
||||||
|
i64 s = isum(x);
|
||||||
|
if(s<0) thrM("/: Argument must consist of natural numbers");
|
||||||
|
usz xia = a(x)->ia;
|
||||||
|
if (RARE(xia>=I32_MAX)) return slash_c1R(x, s);
|
||||||
|
i32* rp; B r = m_i32arrv(&rp, s); usz ri = 0;
|
||||||
|
if (TI(x).elType==el_i32) {
|
||||||
|
i32* xp = i32any_ptr(x);
|
||||||
|
for (i32 i = 0; i < xia; i++) {
|
||||||
|
if (RARE(xp[i])<0) thrF("/: Argument must consist of natural numbers (contained %i)", xp[i]);
|
||||||
|
for (usz j = 0; j < xp[i]; j++) rp[ri++] = i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BS2B xgetU = TI(x).getU;
|
||||||
|
for (i32 i = 0; i < xia; i++) {
|
||||||
usz c = o2s(xgetU(x, i));
|
usz c = o2s(xgetU(x, i));
|
||||||
for (usz j = 0; j < c; j++) rp[ri++] = i;
|
for (usz j = 0; j < c; j++) rp[ri++] = i;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
dec(x);
|
dec(x);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -261,6 +261,7 @@ void printRaw(B x) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
B def_decompose(B x) { return m_v2(m_i32(isCallable(x)? 0 : -1),x); }
|
B def_decompose(B x) { return m_v2(m_i32(isCallable(x)? 0 : -1),x); }
|
||||||
|
static NOINLINE bool equalR(B w, B x) { return equal(w, x); }
|
||||||
bool atomEqual(B w, B x) { // doesn't consume (not that that matters really currently)
|
bool atomEqual(B w, B x) { // doesn't consume (not that that matters really currently)
|
||||||
if(isF64(w)&isF64(x)) return w.f==x.f;
|
if(isF64(w)&isF64(x)) return w.f==x.f;
|
||||||
if (w.u==x.u) return true;
|
if (w.u==x.u) return true;
|
||||||
@ -273,7 +274,7 @@ bool atomEqual(B w, B x) { // doesn't consume (not that that matters really curr
|
|||||||
if (o2i(wdp[0])<=1) { dec(wd);dec(xd); return false; }
|
if (o2i(wdp[0])<=1) { dec(wd);dec(xd); return false; }
|
||||||
usz wia = a(wd)->ia;
|
usz wia = a(wd)->ia;
|
||||||
if (wia!=a(xd)->ia) { dec(wd);dec(xd); return false; }
|
if (wia!=a(xd)->ia) { dec(wd);dec(xd); return false; }
|
||||||
for (i32 i = 0; i<wia; i++) if(!equal(wdp[i], xdp[i]))
|
for (i32 i = 0; i<wia; i++) if(!equalR(wdp[i], xdp[i]))
|
||||||
{ dec(wd);dec(xd); return false; }
|
{ dec(wd);dec(xd); return false; }
|
||||||
dec(wd);dec(xd); return true;
|
dec(wd);dec(xd); return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user