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/shinohara_intensity_ratio.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 test/shinohara_intensity_ratio.c (limited to 'test/shinohara_intensity_ratio.c') diff --git a/test/shinohara_intensity_ratio.c b/test/shinohara_intensity_ratio.c new file mode 100644 index 0000000..1e3bd09 --- /dev/null +++ b/test/shinohara_intensity_ratio.c @@ -0,0 +1,34 @@ +#include +#include +#include "ts.h" + +bool ts_test_shinohara_intensity_ratio( void ) +{ + fp_t const x0[] = { 10, 10, 10, 20, 20, 20 }; + fp_t const x1[] = { 14, 13, 14, 24, 23, 24 }; + fp_t const x2[] = { 8, 9, 8, 18, 19, 18 }; + fp_t const x3[] = { 12, 11, 13, 22, 21, 23 }; + + fp_t const * const x[] = { x0, x1, x2, x3 }; + + uint_t k = 3; + + fp_t i0 = (x1[0] - x3[0]) / (x1[0] - x2[0]); + fp_t i1 = (x3[1] - x2[1]) / (x1[1] - x2[1]); + fp_t i2 = (x1[2] - x3[2]) / (x1[2] - x2[2]); + fp_t e[4]; + e[0] = (i0 + i1 + i2) / 3.0; + + fp_t i3 = (x3[3] > x0[3]) ? (x1[3] - x3[3]) / (x1[3] - x2[3]) : (x3[3] - x2[3]) / (x1[3] - x2[3]); + e[1] = e[0] + (i3 - i0) / 3.0; + + fp_t i4 = (x3[4] > x0[4]) ? (x1[4] - x3[4]) / (x1[4] - x2[4]) : (x3[4] - x2[4]) / (x1[4] - x2[4]); + e[2] = e[1] + (i4 - i1) / 3.0; + + fp_t i5 = (x3[5] > x0[5]) ? (x1[5] - x3[5]) / (x1[5] - x2[5]) : (x3[5] - x2[5]) / (x1[5] - x2[5]); + e[3] = e[2] + (i5 - i2) / 3.0; + + fp_t const * const exp[1] = { e }; + + return ts_test(ts_shinohara_intensity_ratio, ts_shinohara_intensity_ratio_offset, x, exp, sizeof( x0 ) / sizeof( *x0 ), (ts_constant_t *)&k, &ts_shinohara_intensity_ratio_p); +} -- cgit v1.3.1