diff options
| author | Ethan Werner <mail@ethanwerner.com> | 2026-07-01 09:42:39 +0400 |
|---|---|---|
| committer | Ethan Werner <mail@ethanwerner.com> | 2026-07-01 09:42:39 +0400 |
| commit | 07e18043145f3d91c8ea7ec3ad41b3c905585277 (patch) | |
| tree | 2bdeae46973f4bdfce263679a4008ac768011f28 /test/rank.c | |
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
Diffstat (limited to 'test/rank.c')
| -rw-r--r-- | test/rank.c | 20 |
1 files changed, 20 insertions, 0 deletions
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 <math.h> +#include <stddef.h> +#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); +} |