1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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);
}
|