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/dpo.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/dpo.c')
| -rw-r--r-- | test/dpo.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/dpo.c b/test/dpo.c new file mode 100644 index 0000000..e6e4560 --- /dev/null +++ b/test/dpo.c @@ -0,0 +1,24 @@ +#include <math.h> +#include <stddef.h> +#include "ts.h" + +bool ts_test_dpo( void ) +{ + fp_t const x[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; + + fp_t const * const inp[1] = { x }; + + /* k=4, offset=3 */ + /* SMA4: 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5 */ + /* DPO[3] = close[3] - SMA4[0] = 4 - 2.5 = 1.5 */ + /* DPO[4] = close[4] - SMA4[1] = 5 - 3.5 = 1.5 */ + /* ... all 1.5 */ + + fp_t const e[] = { 1.5, 1.5, 1.5, 1.5, 1.5, 1.5, 1.5 }; + + fp_t const * const exp[1] = { e }; + + uint_t c_val = 4; + + return ts_test(ts_dpo, ts_dpo_offset, inp, exp, sizeof( x ) / sizeof( *x ), (ts_constant_t *)&c_val, &ts_dpo_p); +} |