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/t3.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/t3.c (limited to 'test/t3.c') diff --git a/test/t3.c b/test/t3.c new file mode 100644 index 0000000..7ef7e8e --- /dev/null +++ b/test/t3.c @@ -0,0 +1,29 @@ +#include +#include "ts.h" + +bool ts_test_t3( void ) +{ + fp_t const x0[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + uint_t n = sizeof( x0 ) / sizeof( *x0 ); + + // T3 uses hardcoded k=5, b=0.7 + fp_t alpha = 2.0 / 6.0; + fp_t c3 = 0.7, c3m1 = -0.3, c3m2 = -1.3, c3m3 = -2.3; + fp_t w3 = c3, w2 = -3.0 * c3m1, w1 = 3.0 * c3m1 * c3m2, w0 = -c3m1 * c3m2 * c3m3; + + fp_t e0[10]; + fp_t ema1 = x0[0], ema2 = x0[0], ema3 = x0[0]; + e0[0] = x0[0]; + for ( uint_t i = 1; i < n; ++i ) + { + ema1 = ema1 + alpha * ( x0[i] - ema1 ); + ema2 = ema2 + alpha * ( ema1 - ema2 ); + ema3 = ema3 + alpha * ( ema2 - ema3 ); + e0[i] = w3 * ema3 + w2 * ema2 + w1 * ema1 + w0 * x0[i]; + } + + fp_t const * const x[] = { x0 }; + fp_t const * const e[] = { e0 }; + + return ts_test(ts_t3, ts_t3_offset, x, e, n, (ts_constant_t *)NULL, &ts_t3_p); +} -- cgit v1.3.1