a round of more incG/incByG

This commit is contained in:
dzaima 2023-04-29 16:50:51 +03:00
parent a855d03b93
commit bb7c37960e
15 changed files with 29 additions and 29 deletions

View File

@ -26,7 +26,7 @@ B add_c1(B t, B x) {
if (isF64(x)) return x;
if (!isArr(x)) thrM("+: Argument must consist of numbers");
if (elNum(TI(x,elType))) return x;
dec(eachm_fn(m_f64(0), inc(x), add_c1));
decG(eachm_fn(m_f64(0), incG(x), add_c1));
return x;
}
#if SINGELI_SIMD
@ -167,13 +167,13 @@ B ne_c1(B t, B x) { if (isAtm(x)) { decA(x); return m_i32(1); } B r = m_f64(*SH(
static B mathNS;
B getMathNS(void) {
if (mathNS.u == 0) {
#define F(X) inc(bi_##X),
#define F(X) incG(bi_##X),
Body* d = m_nnsDesc("sin","cos","tan","asin","acos","atan","atan2","sinh","cosh","tanh","asinh","acosh","atanh","cbrt","log2","log10","log1p","expm1","hypot","fact","logfact","erf","erfc","comb","gcd","lcm","sum");
mathNS = m_nns(d, F(sin)F(cos)F(tan)F(asin)F(acos)F(atan)F(atan2)F(sinh)F(cosh)F(tanh)F(asinh)F(acosh)F(atanh)F(cbrt)F(log2)F(log10)F(log1p)F(expm1)F(hypot)F(fact)F(logfact)F(erf)F(erfc)F(comb)F(gcd)F(lcm)F(sum));
#undef F
gc_add(mathNS);
}
return inc(mathNS);
return incG(mathNS);
}
void arith_init(void) {

View File

@ -303,7 +303,7 @@ i32 str2gid(B s) {
if(had) return globalNames->a[p].val;
i32 r = IA(globalNameList);
globalNameList = vec_addN(globalNameList, inc(s));
globalNameList = vec_addN(globalNameList, incG(s));
globalNames->a[p].val = r;
return r;
}

View File

@ -221,7 +221,7 @@ B SORT_C1(B t, B x) {
}
} else {
B xf = getFillQ(x);
HArr* r0 = (HArr*)cpyHArr(inc(x));
HArr* r0 = (HArr*)cpyHArr(incG(x));
CAT(GRADE_UD(bA,bD),tim_sort)(r0->a, n);
r = withFill(taga(r0), xf);
}

View File

@ -93,13 +93,13 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xn, usz* xsh, u8 we) {
if (ria <= 1) {
if (ria == 0) goto dec_ret; // Needed so wia>0
if (neg == 0) { rp[0]=inc(x); goto dec_ret; }
if (neg == 0) { rp[0]=incG(x); goto dec_ret; }
// else, 𝕨 is a mix of 0 and ¯1 (and maybe trailing 1)
}
if (we==el_bit) {
assert(ria == 2);
if (wia>xn) w = C2(take, m_f64(xn), w);
rp[1] = C2(slash, inc(w), inc(x));
rp[1] = C2(slash, incG(w), incG(x));
rp[0] = C2(slash, bit_negate(w), x);
return taga(r);
}
@ -173,8 +173,8 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xn, usz* xsh, u8 we) {
// Many ¯1s: filter out, then continue
if (xn>32 && neg>(bits?0:xn/4)+xn/8) {
if (wia>xn) w = C2(take, m_f64(xn), w);
B m = C2(ne, m_f64(-1), inc(w));
w = C2(slash, inc(m), w);
B m = C2(ne, m_f64(-1), incG(w));
w = C2(slash, incG(m), w);
x = C2(slash, m, x); xn = *SH(x);
neg = 0;
}
@ -263,7 +263,7 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xn, usz* xsh, u8 we) {
extern B rt_group;
B group_c2(B t, B w, B x) {
if (!isArr(x)) thrM("⊔: 𝕩 must be an array");
if (isAtm(x)) thrM("⊔: 𝕩 must be an array");
ur xr = RNK(x);
if (isArr(w) && RNK(w)==1 && xr>=1 && depth(w)==1) {
usz wia = IA(w);

View File

@ -195,7 +195,7 @@ B variation_c2(B t, B w, B x) {
} else thrF("•internal.Variation: Bad type \"%R\"", taga(wc));
if (slice) {
Arr* slice = TI(res,slice)(inc(res), 0, IA(res));
Arr* slice = TI(res,slice)(incG(res), 0, IA(res));
arr_shCopy(slice, res);
dec(res);
res = taga(slice);

View File

@ -134,8 +134,8 @@ B swap_c2(Md1D* d, B w, B x) { return c2(d->f, x , w); }
B timed_c2(Md1D* d, B w, B x) { B f = d->f;
i64 am = o2i64(w);
if (am<=0) thrM("•_timed: 𝕨 must be an integer greater than 1");
incBy(x, am);
dec(x);
u64 sns = nsTime();
for (i64 i = 0; i < am; i++) dec(c1(f, x));
u64 ens = nsTime();

View File

@ -50,8 +50,8 @@ void pushRe(void) {
lastErrMsg = inc(thrownMsg);
freeThrown();
}
B catch_c1(Md2D* d, B x) { if(CATCH) { pushRe(); B r = c1(d->g, x); dec(gsPop()); return r; } inc(x); B r = c1(d->f, x); popCatch(); dec(x); return r; }
B catch_c2(Md2D* d, B w, B x) { if(CATCH) { pushRe(); B r = c2(d->g, w,x); dec(gsPop()); return r; } inc(w); inc(x); B r = c2(d->f, w,x); popCatch(); dec(w); dec(x); return r; }
B catch_c1(Md2D* d, B x) { if(CATCH) { pushRe(); B r = c1(d->g, x); dec(gsPop()); return r; } B r = c1(d->f, inc(x)); popCatch(); dec(x); return r; }
B catch_c2(Md2D* d, B w, B x) { if(CATCH) { pushRe(); B r = c2(d->g, w,x); dec(gsPop()); return r; } B r = c2(d->f, inc(w),inc(x)); popCatch(); dec(w); dec(x); return r; }
#else
B fillBy_c1(Md2D* d, B x) { return c1(d->f, x); }
B fillBy_c2(Md2D* d, B w, B x) { return c2(d->f, w,x); }

View File

@ -370,7 +370,7 @@ B select_ucw(B t, B o, B w, B x) {
usz wia = IA(w);
SGetU(w)
if (TI(w,elType)!=el_i32) for (usz i = 0; i < wia; i++) if (!q_i64(GetU(w,i))) return def_fn_ucw(t, o, w, x);
B arg = select_c2(t, inc(w), inc(x));
B arg = select_c2(t, incG(w), incG(x));
B rep = c1(o, arg);
if (isAtm(rep) || !eqShape(w, rep)) thrF("𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected %H, got %H)", w, rep);
#if CHECK_VALID

View File

@ -338,7 +338,7 @@ B count_c1(B t, B x) {
if (use_sorted(x, lw) && n>16 && (lw>4 || n<1<<16)) { // ↕∘≠(⊣-⌈`∘×)∊
B c = shift_ne(x, n, lw, 1);
B i = C1(ud, m_f64(n));
B m = C2(mul, c, inc(i));
B m = C2(mul, c, incG(i));
return C2(sub, i, scan_max_num(m, TI(m,elType), n));
}
void* xv = tyany_ptr(x);
@ -542,5 +542,5 @@ B find_c1(B t, B x) {
rp[0] = 2 ^ -x0;
return r;
}
return C2(slash, C1(memberOf, inc(x)), x);
return C2(slash, C1(memberOf, incG(x)), x);
}

View File

@ -428,7 +428,7 @@ static B compress(B w, B x, usz wia, u8 xl, u8 xt) {
usz wia0 = wia;
wia = 64*(ie+1) - CLZ(we);
usz wsum = bit_sum(wp, wia);
if (wsum == wia0) return inc(x);
if (wsum == wia0) return incG(x);
B r;
switch(xl) {

View File

@ -1343,7 +1343,7 @@ B bitop1(B f, B x, enum BitOp1 op, char* name) {
arr_shCopyUnchecked(ra, x);
r = taga(ra); rp = tyany_ptr(r);
} else {
r = inc(x); rp = xp;
r = incG(x); rp = xp;
}
switch (op) { default: UD;
case op_not: {

View File

@ -451,7 +451,7 @@ BQNFFIEnt ffi_parseType(B arg, bool forRes) { // doesn't consume; parse argument
if (!forRes) thrM("FFI: Argument type empty");
return (BQNFFIEnt){.t = ffi_type_void, .o=m_c32(sty_void), .resSingle=false};
}
arg = chr_squeezeChk(inc(arg));
arg = chr_squeezeChk(incG(arg));
MAKE_MUT_INIT(tmp, ia+1, el_c32); MUTG_INIT(tmp);
mut_copyG(tmp, 0, arg, 0, ia);
@ -551,7 +551,7 @@ void genObj(B o, B c, bool anyMut, void* ptr) {
usz ia = IA(c);
if (t->ty==cty_tlarr && t->arrCount!=ia) thrF("FFI: Incorrect item count of %s corresponding to \"[%s]...\"", ia, (usz)t->arrCount);
if (isC32(e)) { // *num / &num
inc(c);
incG(c);
B cG;
bool mut = t->a[0].mutPtr;
switch(o2cG(e)) { default: thrF("FFI: \"*%S\" argument type NYI", sty_names[o2cG(e)]);
@ -590,7 +590,7 @@ void genObj(B o, B c, bool anyMut, void* ptr) {
u8 etw = sty_w[et]*8;
if (!isArr(c)) thrF("FFI: Expected array corresponding to \"%S:%c%i\"", sty_names[et], (u32)reT, 1<<reW);
if (IA(c) != etw>>reW) thrM("FFI: Bad input array length");
B cG = toW(reT, reW, inc(c));
B cG = toW(reT, reW, incG(c));
memcpy(ptr, tyany_ptr(cG), 8); // may over-read, ¯\_(ツ)_/¯
dec(cG);
} else { // *scalar:any / &scalar:any
@ -598,7 +598,7 @@ void genObj(B o, B c, bool anyMut, void* ptr) {
BQNFFIType* t2 = c(BQNFFIType, o2);
B ore = t2->a[0].o;
assert(t2->ty==cty_ptr && isC32(ore)); // we shouldn't be generating anything else
inc(c);
incG(c);
B cG;
bool mut = t->a[0].mutPtr;
if (mut) {
@ -689,7 +689,7 @@ B buildObj(BQNFFIEnt ent, bool anyMut, B* objs, usz* objPos) {
usz ia = IA(f);
if (isC32(e)) {
switch(o2cG(e)) { default: UD;
case sty_i8: case sty_i16: case sty_i32: case sty_f64: return inc(f);
case sty_i8: case sty_i16: case sty_i32: case sty_f64: return incG(f);
case sty_u8: { u8* tp=tyarr_ptr(f); i16* rp; B r=m_i16arrv(&rp, ia); for (usz i=0; i<ia; i++) rp[i]=tp[i]; return num_squeeze(r); }
case sty_u16: { u16* tp=tyarr_ptr(f); i32* rp; B r=m_i32arrv(&rp, ia); for (usz i=0; i<ia; i++) rp[i]=tp[i]; return num_squeeze(r); }
case sty_u32: { u32* tp=tyarr_ptr(f); f64* rp; B r=m_f64arrv(&rp, ia); for (usz i=0; i<ia; i++) rp[i]=tp[i]; return num_squeeze(r); }

View File

@ -643,9 +643,9 @@ static void funBI_visit(Value* x) {
static B funBI_imRt(B t, B x) { return c1(c(BFn, t)->rtInvReg, x); }
static B funBI_iwRt(B t, B w, B x) { return c2(c(BFn, t)->rtInvSwap, w, x); }
static B funBI_ixRt(B t, B w, B x) { return c2(c(BFn, t)->rtInvReg, w, x); }
static B funBI_imInit(B t, B x) { B f=c(BFn,t)->rtInvReg; if(f.u==0) f=c(BFn,t)->rtInvReg=c1rt(invFnReg, inc(t)); c(BFn,t)->im=funBI_imRt; return c1(f, x); }
static B funBI_ixInit(B t, B w, B x) { B f=c(BFn,t)->rtInvReg; if(f.u==0) f=c(BFn,t)->rtInvReg=c1rt(invFnReg, inc(t)); c(BFn,t)->ix=funBI_ixRt; return c2(f, w, x); }
static B funBI_iwInit(B t, B w, B x) { B f=c(BFn,t)->rtInvSwap =c1rt(invFnSwap, inc(t)); c(BFn,t)->iw=funBI_iwRt; return c2(f, w, x); }
static B funBI_imInit(B t, B x) { B f=c(BFn,t)->rtInvReg; if(f.u==0) f=c(BFn,t)->rtInvReg=c1rt(invFnReg, incG(t)); c(BFn,t)->im=funBI_imRt; return c1(f, x); }
static B funBI_ixInit(B t, B w, B x) { B f=c(BFn,t)->rtInvReg; if(f.u==0) f=c(BFn,t)->rtInvReg=c1rt(invFnReg, incG(t)); c(BFn,t)->ix=funBI_ixRt; return c2(f, w, x); }
static B funBI_iwInit(B t, B w, B x) { B f=c(BFn,t)->rtInvSwap =c1rt(invFnSwap, incG(t)); c(BFn,t)->iw=funBI_iwRt; return c2(f, w, x); }
void* m_customObj(u64 size, V2v visit, V2v freeO) {

View File

@ -98,7 +98,7 @@ static i32* emptyi32ptr;
static B emptyi32obj;
Body* m_nnsDescF(i32 n, char** names) {
if (emptyi32ptr==NULL) gc_add(emptyi32obj = m_i32arrv(&emptyi32ptr, 0));
incBy(emptyi32obj, 3);
incByG(emptyi32obj, 3);
M_HARR(nl, n)
for (usz i = 0; i < n; i++) HARR_ADD(nl, i, m_c8vec_0(names[i]));

View File

@ -168,7 +168,7 @@ DEF_S(void, fill, f64, isF64(x), x, (void* a, usz ms, B x, usz l), ms, x, l) { f
DEF_G(void, fill, B , (void* a, usz ms, B x, usz l), ms, x, l) {
B* p = ms + (B*)a;
for (usz i = 0; i < l; i++) p[i] = x;
if (isVal(x)) incBy(x, l);
incBy(x, l);
return;
}