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/mesa_sine_wave.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/mesa_sine_wave.c')
| -rw-r--r-- | test/mesa_sine_wave.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/mesa_sine_wave.c b/test/mesa_sine_wave.c new file mode 100644 index 0000000..598de80 --- /dev/null +++ b/test/mesa_sine_wave.c @@ -0,0 +1,22 @@ +#include <math.h> +#include <stddef.h> +#include "ts.h" + +bool ts_test_mesa_sine_wave( void ) +{ + /* k=3 */ + fp_t const x[] = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; + + fp_t const * const inp[1] = { x }; + + /* SMA(3): 11, 12, 13, 14, 15, 16, 17, 18 */ + /* ROC: 13-11=2, 14-12=2, 15-13=2, 16-14=2, 17-15=2, 18-16=2, 19-18=2 */ + /* EMA(5) of constant 2 converges to 2, clamped to 1 */ + /* All sines = 1, all leads = 0 */ + fp_t const es[] = { 1, 1, 1, 1, 1, 1, 1 }; + fp_t const el[] = { 0, 0, 0, 0, 0, 0, 0 }; + fp_t const * const exp[2] = { es, el }; + + uint_t k = 3; + return ts_test(ts_mesa_sine_wave, ts_mesa_sine_wave_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&k, &ts_mesa_sine_wave_p); +} |