From 07e18043145f3d91c8ea7ec3ad41b3c905585277 Mon Sep 17 00:00:00 2001 From: Ethan Werner Date: Wed, 1 Jul 2026 09:42:39 +0400 Subject: initial commit: ts time series analysis library v0.1.0 - 354 financial and mathematical time-series indicators - Uniform C11 API with consistent function signatures - 349 passing tests with -Werror - Static and shared library builds - pkg-config integration - Python bindings - Fuzzing and sanitizer support - Security hardening flags --- test/rank.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/rank.c (limited to 'test/rank.c') diff --git a/test/rank.c b/test/rank.c new file mode 100644 index 0000000..2c96247 --- /dev/null +++ b/test/rank.c @@ -0,0 +1,20 @@ +#include +#include +#include "ts.h" + +bool ts_test_rank( void ) +{ + /* k=3, data: 10, 20, 15, 25, 5, 30 */ + /* i=2 (window [10,20,15]): current=15, <=: 10,15 => 2/3*100 = 66.667 */ + /* i=3 (window [20,15,25]): current=25, <=: 20,15,25 => 3/3*100 = 100.0 */ + /* i=4 (window [15,25,5]): current=5, <=: 5 => 1/3*100 = 33.333 */ + /* i=5 (window [25,5,30]): current=30, <=: 25,5,30 => 3/3*100 = 100.0 */ + fp_t const x[] = { 10, 20, 15, 25, 5, 30 }; + + fp_t const * const inp[1] = { x }; + fp_t const e[] = { 66.66667, 100.0, 33.33333, 100.0 }; + fp_t const * const exp[1] = { e }; + + uint_t k = 3; + return ts_test(ts_rank, ts_rank_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_rank_p); +} -- cgit v1.3.1