use C1 & C2 more
This commit is contained in:
parent
1af9155425
commit
deee2c7a18
@ -337,7 +337,7 @@ AR_I_SCALAR("⌊", floor, w.f>x.f?x.f:w.f, {})
|
|||||||
AR_I_SCALAR("⌈", ceil , w.f>x.f?w.f:x.f, {})
|
AR_I_SCALAR("⌈", ceil , w.f>x.f?w.f:x.f, {})
|
||||||
#undef AR_I_SCALAR
|
#undef AR_I_SCALAR
|
||||||
B not_c2(B t, B w, B x) {
|
B not_c2(B t, B w, B x) {
|
||||||
return add_c2(m_f64(1), m_f64(1), sub_c2(t, w, x));
|
return C2(add, m_f64(1), sub_c2(t, w, x));
|
||||||
}
|
}
|
||||||
|
|
||||||
#define AR_F_SCALAR(CHR, NAME, EXPR) B NAME##_c2(B t, B w, B x) { \
|
#define AR_F_SCALAR(CHR, NAME, EXPR) B NAME##_c2(B t, B w, B x) { \
|
||||||
|
|||||||
@ -84,7 +84,7 @@ B add_c1(B t, B x) {
|
|||||||
}
|
}
|
||||||
B sub_c2(B,B,B);
|
B sub_c2(B,B,B);
|
||||||
#define SUB_BODY(FEXPR) return sub_c2(t, m_f64(0), x);
|
#define SUB_BODY(FEXPR) return sub_c2(t, m_f64(0), x);
|
||||||
#define NOT_BODY(FEXPR) x = num_squeezeChk(x); return TI(x,elType)==el_bit? bit_negate(x) : sub_c2(m_f64(0), m_f64(1), x);
|
#define NOT_BODY(FEXPR) x = num_squeezeChk(x); return TI(x,elType)==el_bit? bit_negate(x) : C2(sub, m_f64(1), x);
|
||||||
|
|
||||||
GC1i("-", sub, -v, el_bit, bit_sel(x,m_f64(0),m_f64(-1)), SUB_BODY)
|
GC1i("-", sub, -v, el_bit, bit_sel(x,m_f64(0),m_f64(-1)), SUB_BODY)
|
||||||
GC1i("|", stile, fabs(v), el_bit, x, STILE_BODY)
|
GC1i("|", stile, fabs(v), el_bit, x, STILE_BODY)
|
||||||
|
|||||||
@ -74,7 +74,7 @@ B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
|||||||
if (isFun(f) && isPervasiveDy(f) && TI(w,arrD1)) {
|
if (isFun(f) && isPervasiveDy(f) && TI(w,arrD1)) {
|
||||||
if (TI(x,arrD1) && wia>130 && xia<2560>>arrTypeBitsLog(TY(x))) {
|
if (TI(x,arrD1) && wia>130 && xia<2560>>arrTypeBitsLog(TY(x))) {
|
||||||
Arr* wd = arr_shVec(TI(w,slice)(incG(w), 0, wia));
|
Arr* wd = arr_shVec(TI(w,slice)(incG(w), 0, wia));
|
||||||
r = fc2(f, slash_c2(f, m_i32(xia), taga(wd)), shape_c2(f, m_f64(ria), incG(x)));
|
r = fc2(f, C2(slash, m_i32(xia), taga(wd)), C2(shape, m_f64(ria), incG(x)));
|
||||||
} else if (xia>7) {
|
} else if (xia>7) {
|
||||||
SGet(w)
|
SGet(w)
|
||||||
M_HARR(r, wia)
|
M_HARR(r, wia)
|
||||||
|
|||||||
@ -148,7 +148,7 @@ B cond_c1(Md2D* d, B x) { B f=d->f; B g=d->g;
|
|||||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: 𝔽 out of bounds of 𝕘"));
|
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: 𝔽 out of bounds of 𝕘"));
|
||||||
return c1(IGetU(g, fri), x);
|
return c1(IGetU(g, fri), x);
|
||||||
} else {
|
} else {
|
||||||
B fn = pick_c2(m_f64(0), fr, inc(g));
|
B fn = C2(pick, fr, inc(g));
|
||||||
B r = c1(fn, x);
|
B r = c1(fn, x);
|
||||||
dec(fn);
|
dec(fn);
|
||||||
return r;
|
return r;
|
||||||
@ -161,7 +161,7 @@ B cond_c2(Md2D* d, B w, B x) { B g=d->g;
|
|||||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: 𝔽 out of bounds of 𝕘"));
|
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: 𝔽 out of bounds of 𝕘"));
|
||||||
return c2(IGetU(g, fri), w, x);
|
return c2(IGetU(g, fri), w, x);
|
||||||
} else {
|
} else {
|
||||||
B fn = pick_c2(m_f64(0), fr, inc(g));
|
B fn = C2(pick, fr, inc(g));
|
||||||
B r = c2(fn, w, x);
|
B r = c2(fn, w, x);
|
||||||
dec(fn);
|
dec(fn);
|
||||||
return r;
|
return r;
|
||||||
|
|||||||
@ -297,7 +297,7 @@ B count_c2(B t, B w, B x) {
|
|||||||
x = t.n;
|
x = t.n;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isArr(x) || IA(x)<=1) return indexOf_c2(m_f64(0), w, x);
|
if (!isArr(x) || IA(x)<=1) return C2(indexOf, w, x);
|
||||||
u8 we = TI(w,elType); usz wia = IA(w);
|
u8 we = TI(w,elType); usz wia = IA(w);
|
||||||
u8 xe = TI(x,elType); usz xia = IA(x);
|
u8 xe = TI(x,elType); usz xia = IA(x);
|
||||||
i32* rp; B r = m_i32arrc(&rp, x);
|
i32* rp; B r = m_i32arrc(&rp, x);
|
||||||
|
|||||||
@ -198,7 +198,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
if (max>=(i64)xn) thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", max, xn); \
|
if (max>=(i64)xn) thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", max, xn); \
|
||||||
W* ip=wp; usz off=xn; \
|
W* ip=wp; usz off=xn; \
|
||||||
if (max>=0) { off=0; if (RARE(min<0)) { \
|
if (max>=0) { off=0; if (RARE(min<0)) { \
|
||||||
if (RARE(xn > (1ULL<<(sizeof(W)*8-1)))) { w=taga(NEXT(w)); mm_free((Value*)r); return select_c2(m_f64(0), w, x); } \
|
if (RARE(xn > (1ULL<<(sizeof(W)*8-1)))) { w=taga(NEXT(w)); mm_free((Value*)r); return C2(select, w, x); } \
|
||||||
if (!wt) {wt=TALLOCP(W,i1-i0);} ip=wt-i0;\
|
if (!wt) {wt=TALLOCP(W,i1-i0);} ip=wt-i0;\
|
||||||
for (usz i=i0; i<i1; i++) { W e=wp[i]; ip[i]=e+((W)xn & (W)-(e<0)); } \
|
for (usz i=i0; i<i1; i++) { W e=wp[i]; ip[i]=e+((W)xn & (W)-(e<0)); } \
|
||||||
} } \
|
} } \
|
||||||
@ -213,15 +213,15 @@ B select_c2(B t, B w, B x) {
|
|||||||
if (!bool_use_simd && xe==el_bit && (csz&7)!=0 && (xl==0? wia>=256 : wia>=4) && csz<128) {
|
if (!bool_use_simd && xe==el_bit && (csz&7)!=0 && (xl==0? wia>=256 : wia>=4) && csz<128) {
|
||||||
// test widen/narrow on bitarr input
|
// test widen/narrow on bitarr input
|
||||||
// ShArr* sh = RNK(x)==1? NULL : ptr_inc(shObj(x));
|
// ShArr* sh = RNK(x)==1? NULL : ptr_inc(shObj(x));
|
||||||
// B t = select_c2(m_f64(0), w, widenBitArr(x, 1));
|
// B t = C2(select, w, widenBitArr(x, 1));
|
||||||
// B r = narrowWidenedBitArr(t, wr, xr-1, sh==NULL? &xn : sh->a+1);
|
// B r = narrowWidenedBitArr(t, wr, xr-1, sh==NULL? &xn : sh->a+1);
|
||||||
// if (sh!=NULL) ptr_dec(sh);
|
// if (sh!=NULL) ptr_dec(sh);
|
||||||
// return r;
|
// return r;
|
||||||
if (csz==1) {
|
if (csz==1) {
|
||||||
if (wia/4>=xia) return taga(cpyBitArr(select_c2(m_f64(0), w, taga(cpyI8Arr(x)))));
|
if (wia/4>=xia) return taga(cpyBitArr(C2(select, w, taga(cpyI8Arr(x)))));
|
||||||
} else if (csz>64? wia/2>=xn : wia>=xn/2) {
|
} else if (csz>64? wia/2>=xn : wia>=xn/2) {
|
||||||
ShArr* sh = ptr_inc(shObj(x));
|
ShArr* sh = ptr_inc(shObj(x));
|
||||||
B t = select_c2(m_f64(0), w, widenBitArr(x, 1));
|
B t = C2(select, w, widenBitArr(x, 1));
|
||||||
B r = narrowWidenedBitArr(t, wr, xr-1, sh->a+1);
|
B r = narrowWidenedBitArr(t, wr, xr-1, sh->a+1);
|
||||||
ptr_dec(sh);
|
ptr_dec(sh);
|
||||||
return r;
|
return r;
|
||||||
@ -263,7 +263,7 @@ B select_c2(B t, B w, B x) {
|
|||||||
if (xr!=1) {
|
if (xr!=1) {
|
||||||
if (xe!=el_B && (csz<<elWidthLogBits(xe)) < 128) {
|
if (xe!=el_B && (csz<<elWidthLogBits(xe)) < 128) {
|
||||||
dec(xf);
|
dec(xf);
|
||||||
return select_c2(m_f64(0), taga(cpyI8Arr(w)), x);
|
return C2(select, taga(cpyI8Arr(w)), x);
|
||||||
} else {
|
} else {
|
||||||
goto generic_l;
|
goto generic_l;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1474,7 +1474,7 @@ static B shape_uc1_t(B r, usz ia) {
|
|||||||
B shape_uc1(B t, B o, B x) {
|
B shape_uc1(B t, B o, B x) {
|
||||||
if (!isArr(x) || RNK(x)==0) {
|
if (!isArr(x) || RNK(x)==0) {
|
||||||
usz xia = isArr(x)? IA(x) : 1;
|
usz xia = isArr(x)? IA(x) : 1;
|
||||||
return shape_c2(t, emptyIVec(), shape_uc1_t(c1(o, shape_c1(t, x)), xia));
|
return C2(shape, emptyIVec(), shape_uc1_t(c1(o, shape_c1(t, x)), xia));
|
||||||
}
|
}
|
||||||
usz xia = IA(x);
|
usz xia = IA(x);
|
||||||
if (RNK(x)==1) return shape_uc1_t(c1(o, x), xia);
|
if (RNK(x)==1) return shape_uc1_t(c1(o, x), xia);
|
||||||
@ -1485,17 +1485,17 @@ B shape_uc1(B t, B o, B x) {
|
|||||||
|
|
||||||
B select_ucw(B t, B o, B w, B x);
|
B select_ucw(B t, B o, B w, B x);
|
||||||
|
|
||||||
B transp_uc1(B t, B o, B x) { return transp_im(t, c1(o, transp_c1(t, x))); }
|
B transp_uc1(B t, B o, B x) { return transp_im(m_f64(0), c1(o, transp_c1(t, x))); }
|
||||||
B reverse_uc1(B t, B o, B x) { return reverse_c1(t, c1(o, reverse_c1(t, x))); }
|
B reverse_uc1(B t, B o, B x) { return reverse_c1(m_f64(0), c1(o, reverse_c1(t, x))); }
|
||||||
|
|
||||||
B reverse_ix(B t, B w, B x) {
|
B reverse_ix(B t, B w, B x) {
|
||||||
if (isAtm(x) || RNK(x)==0) thrM("⌽⁼: 𝕩 must have rank at least 1");
|
if (isAtm(x) || RNK(x)==0) thrM("⌽⁼: 𝕩 must have rank at least 1");
|
||||||
if (isF64(w)) return reverse_c2(t, m_f64(-o2fG(w)), x);
|
if (isF64(w)) return C2(reverse, m_f64(-o2fG(w)), x);
|
||||||
if (isAtm(w)) thrM("⌽⁼: 𝕨 must consist of integers");
|
if (isAtm(w)) thrM("⌽⁼: 𝕨 must consist of integers");
|
||||||
return rotate_highrank(1, w, x);
|
return rotate_highrank(1, w, x);
|
||||||
}
|
}
|
||||||
|
|
||||||
B reverse_ucw(B t, B o, B w, B x) { return reverse_ix(t, w, c1(o, reverse_c2(t, inc(w), x))); }
|
B reverse_ucw(B t, B o, B w, B x) { return reverse_ix(m_f64(0), w, c1(o, reverse_c2(t, inc(w), x))); }
|
||||||
|
|
||||||
NOINLINE B enclose_im(B t, B x) {
|
NOINLINE B enclose_im(B t, B x) {
|
||||||
if (isAtm(x) || RNK(x)!=0) thrM("<⁼: Argument wasn't a rank 0 array");
|
if (isAtm(x) || RNK(x)!=0) thrM("<⁼: Argument wasn't a rank 0 array");
|
||||||
|
|||||||
@ -966,7 +966,7 @@ B slash_ucw(B t, B o, B w, B x) {
|
|||||||
w = num_squeezeChk(w);
|
w = num_squeezeChk(w);
|
||||||
if (!elInt(TI(w,elType))) goto base;
|
if (!elInt(TI(w,elType))) goto base;
|
||||||
}
|
}
|
||||||
B arg = slash_c2(t, inc(w), inc(x));
|
B arg = C2(slash, incG(w), incG(x));
|
||||||
usz argIA = IA(arg);
|
usz argIA = IA(arg);
|
||||||
B rep = c1(o, arg);
|
B rep = c1(o, arg);
|
||||||
if (isAtm(rep) || RNK(rep)!=1 || IA(rep) != argIA) thrF("𝔽⌾(a⊸/)𝕩: Result of 𝔽 must have the same shape as a/𝕩 (expected ⟨%s⟩, got %H)", argIA, rep);
|
if (isAtm(rep) || RNK(rep)!=1 || IA(rep) != argIA) thrF("𝔽⌾(a⊸/)𝕩: Result of 𝔽 must have the same shape as a/𝕩 (expected ⟨%s⟩, got %H)", argIA, rep);
|
||||||
|
|||||||
@ -521,7 +521,7 @@ B rand_subset_c2(B t, B w, B x) {
|
|||||||
}
|
}
|
||||||
s = taga(cpyBitArr(s));
|
s = taga(cpyBitArr(s));
|
||||||
if (invert) s = bit_negate(s);
|
if (invert) s = bit_negate(s);
|
||||||
return slash_c1(t, s);
|
return C1(slash, s);
|
||||||
} else {
|
} else {
|
||||||
// Sorted "hash" set
|
// Sorted "hash" set
|
||||||
u64 sh = 0;
|
u64 sh = 0;
|
||||||
@ -1560,7 +1560,7 @@ B sys_c1(B t, B x) {
|
|||||||
B tmp[2]; getSysvals(tmp);
|
B tmp[2]; getSysvals(tmp);
|
||||||
B curr_ns = tmp[0];
|
B curr_ns = tmp[0];
|
||||||
B curr_vs = tmp[1]; SGetU(curr_vs)
|
B curr_vs = tmp[1]; SGetU(curr_vs)
|
||||||
B idxs = indexOf_c2(m_f64(0), incG(curr_ns), incG(x)); SGetU(idxs)
|
B idxs = C2(indexOf, incG(curr_ns), incG(x)); SGetU(idxs)
|
||||||
|
|
||||||
B fileNS = m_f64(0);
|
B fileNS = m_f64(0);
|
||||||
B path = m_f64(0);
|
B path = m_f64(0);
|
||||||
|
|||||||
@ -723,7 +723,7 @@ bool ignore_bad_tag;
|
|||||||
void g_p(B x) { printI(x); putchar(10); fflush(stdout); }
|
void g_p(B x) { printI(x); putchar(10); fflush(stdout); }
|
||||||
void g_i(B x) { B r = info_c2(x, m_f64(1), inc(x)); printI(r); dec(r); putchar(10); fflush(stdout); }
|
void g_i(B x) { B r = info_c2(x, m_f64(1), inc(x)); printI(r); dec(r); putchar(10); fflush(stdout); }
|
||||||
void g_pv(void* x) { ignore_bad_tag=true; printI(tag(x,OBJ_TAG)); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
void g_pv(void* x) { ignore_bad_tag=true; printI(tag(x,OBJ_TAG)); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
||||||
void g_iv(void* x) { ignore_bad_tag=true; B xo = tag(x, OBJ_TAG); B r = info_c2(xo, m_f64(1), inc(xo)); printI(r); dec(r); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
void g_iv(void* x) { ignore_bad_tag=true; B xo = tag(x, OBJ_TAG); B r = C2(info, m_f64(1), inc(xo)); printI(r); dec(r); putchar(10); fflush(stdout); ignore_bad_tag=false; }
|
||||||
void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|||||||
@ -391,7 +391,7 @@ static bool isCmd(char* s, char** e, const char* cmd) {
|
|||||||
if (IA(b_pv)+1 != IA(s) || b_pp+1 != pos) goto stop;
|
if (IA(b_pv)+1 != IA(s) || b_pp+1 != pos) goto stop;
|
||||||
if (!slice_equal(b_pv, 0, s, 0, pos-1)) goto stop;
|
if (!slice_equal(b_pv, 0, s, 0, pos-1)) goto stop;
|
||||||
if (!slice_equal(b_pv, b_pp, s, pos, IA(s)-pos)) goto stop;
|
if (!slice_equal(b_pv, b_pp, s, pos, IA(s)-pos)) goto stop;
|
||||||
usz mapPos = o2i(pick_c1(m_f64(0), indexOf_c2(m_f64(0), incG(b_key), IGet(s,pos-1))));
|
usz mapPos = o2i(C1(pick, C2(indexOf, incG(b_key), IGet(s,pos-1))));
|
||||||
if (mapPos==IA(b_key)) goto stop;
|
if (mapPos==IA(b_key)) goto stop;
|
||||||
|
|
||||||
TmpState t2 = insertChar(o2c(IGetU(b_val, mapPos)), true);
|
TmpState t2 = insertChar(o2c(IGetU(b_val, mapPos)), true);
|
||||||
|
|||||||
@ -119,7 +119,7 @@ NOINLINE B nc_tokenize(B prims, B sysvs, u32* chars, usz len, bool* hasBlock) {
|
|||||||
u32* np; B name = m_c32arrv(&np, ia);
|
u32* np; B name = m_c32arrv(&np, ia);
|
||||||
PLAINLOOP for (usz j = 0; j < ia; j++) np[j] = chars[i0+j] + (nc_up(chars[i0+j])? 32 : 0);
|
PLAINLOOP for (usz j = 0; j < ia; j++) np[j] = chars[i0+j] + (nc_up(chars[i0+j])? 32 : 0);
|
||||||
if (sys) {
|
if (sys) {
|
||||||
B sysRes = sys_c1(m_f64(0), m_hVec1(name));
|
B sysRes = C1(sys, m_hVec1(name));
|
||||||
val = nc_literal(IGet(sysRes, 0)); // won't have the class the user entered but ¯\_(ツ)_/¯
|
val = nc_literal(IGet(sysRes, 0)); // won't have the class the user entered but ¯\_(ツ)_/¯
|
||||||
decG(sysRes);
|
decG(sysRes);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
#endif
|
#endif
|
||||||
#include "utils/time.h"
|
#include "utils/time.h"
|
||||||
|
#include "utils/calls.h"
|
||||||
|
|
||||||
#if defined(RT_WRAP) || defined(WRAP_NNBI)
|
#if defined(RT_WRAP) || defined(WRAP_NNBI)
|
||||||
|
|
||||||
@ -60,10 +61,10 @@ B wfn_identity(B x) {
|
|||||||
#define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \
|
#define CHK(EXP,GOT,W,X) { if (!eequal(EXP,GOT)) { \
|
||||||
printI(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \
|
printI(f); printf(": failed RT_VERIFY\n"); fflush(stdout); \
|
||||||
if (RT_VERIFY_ARGS) { \
|
if (RT_VERIFY_ARGS) { \
|
||||||
if(!q_N(W)){printf("𝕨:"); printI(W); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(W))); putchar('\n'); fflush(stdout); } \
|
if(!q_N(W)){printf("𝕨:"); printI(W); printf(" / "); printsB(C2(info, m_i32(1), inc(W))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("𝕩:"); printI(X); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(X))); putchar('\n'); fflush(stdout); } \
|
{ printf("𝕩:"); printI(X); printf(" / "); printsB(C2(info, m_i32(1), inc(X))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("got:"); printI(GOT); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(GOT))); putchar('\n'); fflush(stdout); } \
|
{ printf("got:"); printI(GOT); printf(" / "); printsB(C2(info, m_i32(1), inc(GOT))); putchar('\n'); fflush(stdout); } \
|
||||||
{ printf("exp:"); printI(EXP); printf(" / "); printsB(info_c2(bi_N, m_i32(1), inc(EXP))); putchar('\n'); fflush(stdout); } \
|
{ printf("exp:"); printI(EXP); printf(" / "); printsB(C2(info, m_i32(1), inc(EXP))); putchar('\n'); fflush(stdout); } \
|
||||||
} \
|
} \
|
||||||
vm_pstLive(); exit(1); \
|
vm_pstLive(); exit(1); \
|
||||||
}}
|
}}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user