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/shinohara_intensity_ratio.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/shinohara_intensity_ratio.c')
| -rw-r--r-- | test/shinohara_intensity_ratio.c | 34 |
1 files changed, 34 insertions, 0 deletions
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 <math.h> +#include <stddef.h> +#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); +} |