diff options
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); +} |