diff --git a/src/builtins/grade.h b/src/builtins/grade.h index 8cfbd0ba..b75d31ab 100644 --- a/src/builtins/grade.h +++ b/src/builtins/grade.h @@ -412,9 +412,13 @@ static u64 CAT(bit_boundary,GRADE_UD(up,dn))(u64* x, u64 n) { } #define LE_C2 CAT(GRADE_UD(le,ge),c2) -extern B LE_C2(B,B,B); -extern B select_c2(B t, B w, B x); -extern B mul_c2(B, B, B); +extern B lt_c2(B,B,B); +extern B le_c2(B,B,B); +extern B gt_c2(B,B,B); +extern B ge_c2(B,B,B); +extern B ne_c2(B,B,B); +extern B select_c2(B,B,B); +extern B mul_c2(B,B,B); B GRADE_CAT(c2)(B t, B w, B x) { if (isAtm(w) || RNK(w)==0) thrM(GRADE_CHR": 𝕨 must have rank≥1"); @@ -442,6 +446,11 @@ B GRADE_CAT(c2)(B t, B w, B x) { B c = IGet(w, 0); if (LIKELY(we we) { @@ -554,9 +565,7 @@ B GRADE_CAT(c2)(B t, B w, B x) { } #endif } else { - #if !SINGELI gen:; - #endif i32* rp; r = m_i32arrc(&rp, x); SLOW2("𝕨"GRADE_CHR"𝕩", w, x); SGetU(w) SGetU(x) diff --git a/src/builtins/sort.c b/src/builtins/sort.c index 8492aac7..7c0ff199 100644 --- a/src/builtins/sort.c +++ b/src/builtins/sort.c @@ -24,6 +24,11 @@ static NOINLINE void generic_grade(B x, usz ia, B r, i32* rp, void (*fn)(BI32p*, vfor (usz i = 0; i < ia; i++) rp[i] = tmp[i].v; TFREE(tmp); } +static bool q_nan(B x) { + assert(isNum(x)); + double f = o2fG(x); + return f!=f; +} #define GRADE_UD(U,D) U #include "grade.h" diff --git a/src/singeli/src/bins.singeli b/src/singeli/src/bins.singeli index 9fc1482d..110548a1 100644 --- a/src/singeli/src/bins.singeli +++ b/src/singeli/src/bins.singeli @@ -376,13 +376,13 @@ include './f64' require{'math.h'} fn saturate{F,T,...up}(dst:*void, src:*void, n:u64) : void = { # Auto-vectorizes, although not that well for f64 - def a = minvalue{T}; af := cast_i{F,a} - def b = maxvalue{T}; bf := cast_i{F,b} + def a = minvalue{T} + def b = maxvalue{T} @for (d in *T~~dst, xf in *F~~src over n) { x := if (F==f64) (if (select{up,0}) floor else ceil){xf} else xf d = cast_i{T, x} - if (xbf) d = b + if (not x