From 82ebd37b3f2e8095b750cd86e97f6f6d928bb86f Mon Sep 17 00:00:00 2001 From: dzaima Date: Thu, 13 Mar 2025 20:41:46 +0200 Subject: [PATCH] group statistics test --- src/builtins/internal.c | 18 ++++++++++++++++++ test/cases/build-specific/test_group_stat.bqn | 19 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 test/cases/build-specific/test_group_stat.bqn diff --git a/src/builtins/internal.c b/src/builtins/internal.c index ef5cefd5..05839990 100644 --- a/src/builtins/internal.c +++ b/src/builtins/internal.c @@ -283,7 +283,25 @@ B eequal_c2(B t, B w, B x) { #if TEST_RANGE #include "../utils/calls.h" #endif +#if TEST_GROUP_STAT + extern void (*const si_group_statistics_i8)(void*,usz,uint8_t*,usz*,uint8_t*,usz*,int8_t*); + extern void (*const si_group_statistics_i16)(void*,usz,uint8_t*,usz*,uint8_t*,usz*,int16_t*); + extern void (*const si_group_statistics_i32)(void*,usz,uint8_t*,usz*,uint8_t*,usz*,int32_t*); +#endif B internalTemp_c1(B t, B x) { + #if TEST_GROUP_STAT + u8 bad; usz neg; u8 sort; usz change; i32 max; + #define CASE(T) \ + if (TI(x,elType)==el_##T) { T max_t; si_group_statistics_##T(tyany_ptr(x), IA(x), &bad, &neg, &sort, &change, &max_t); max = max_t; } \ + else + CASE(i8) CASE(i16) CASE(i32) + thrM("bad eltype"); + #undef CASE + decG(x); + f64* rp; B r = m_f64arrv(&rp, 5); + rp[0] = bad; rp[1] = neg; rp[2] = sort; rp[3] = change; rp[4] = max; + return r; + #endif #if TEST_RANGE i64 buf[2]; bool b = getRange_fns[TI(x,elType)](tyany_ptr(x), buf, IA(x)); diff --git a/test/cases/build-specific/test_group_stat.bqn b/test/cases/build-specific/test_group_stat.bqn new file mode 100644 index 00000000..d4f6e69d --- /dev/null +++ b/test/cases/build-specific/test_group_stat.bqn @@ -0,0 +1,19 @@ +# needs: Singeli & -DTEST_GROUP_STAT +"basic test doesn't work; are you on a -DTEST_GROUP_STAT build?" ! 0‿0‿1‿10‿9 ≡ •internal.Temp ↕10 + +%DEF tvar AllEq←{v←⊑𝕩 ⋄ {𝕩≡v?1;!𝕩‿v}¨ ⥊𝕩 ⋄ v} ⋄ _tvar ← {Sel _𝕣 a: AllEq {Sel •internal.Temp 𝕩•internal.Variation a}¨ ∊⟜"Ai8"‿"Ai16"‿"Ai32"⊸/ •internal.ListVariations •internal.Squeeze a} +%USE tvar ⋄ ⊢_tvar ↕10 %% 0‿0‿1‿10‿9 + +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq {⊑_tvar ¯2⌾(𝕩⊸⊑) a}¨ ↕𝕩}¨ 1+↕40 %% 1 +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq {⊑_tvar ¯128⌾(𝕩⊸⊑) a}¨ ↕𝕩}¨ 1+↕40 %% 1 + +%USE tvar ⋄ AllEq {⊢_tvar 𝕩⥊0}¨ 1+↕1000 %% 0‿0‿1‿1‿0 +%USE tvar ⋄ AllEq {⊢_tvar 𝕩⥊10}¨ 1+↕1000 %% 0‿0‿1‿1‿10 +%USE tvar ⋄ {! ⟨0,0,0,𝕩,3⟩ ≡ ⊢_tvar 𝕩⥊3‿2}¨ 2+↕1000 +%USE tvar ⋄ {! ⟨0,0,1,𝕩,𝕩-1⟩ ≡ ⊢_tvar ↕𝕩}¨ 1+↕1000 + +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq {0‿1‿2‿4⊸⊏_tvar 3⌾(𝕩⊸⊑) a}¨ ↕𝕩-1}¨ 2+↕40 %% 0‿0‿0‿3 +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq { ⊢_tvar 9⌾(𝕩⊸⊑) a}¨ 1+↕𝕩-2}¨ 3+↕40 %% 0‿0‿0‿3‿9 + +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq {0‿1‿4⊸⊏_tvar ¯1⌾(𝕩⊸⊑) a}¨ ↕𝕩}¨ 2+↕40 %% 0‿1‿0 +%USE tvar ⋄ AllEq {a←𝕩⥊0 ⋄ AllEq {0‿1‿4⊸⊏_tvar 12⌾(𝕩⊸⊑) a}¨ ↕𝕩}¨ 1+↕40 %% 0‿0‿12