summaryrefslogtreecommitdiffstats
path: root/test/williams_r.c
blob: 5d9f32f821237619a90301ce189e26b71b41d6ef (plain)
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_williams_r( void )
{
	/* k=3, monotonic increase. C is always at the high end. */
	/* i=2: HH=14, LL=9, C=13 => -100*(14-13)/(14-9) = -20 */
	/* i=3: HH=15, LL=10, C=14 => -100*(15-14)/(15-10) = -20 */
	/* i=4: HH=16, LL=11, C=15 => -20 */
	fp_t const o[] = { 10, 11, 12, 13, 14, 15, 16, 17 };
	fp_t const h[] = { 12, 13, 14, 15, 16, 17, 18, 19 };
	fp_t const l[] = { 9, 10, 11, 12, 13, 14, 15, 16 };
	fp_t const c[] = { 11, 12, 13, 14, 15, 16, 17, 18 };

	fp_t const * const x[] = { o, h, l, c };
	fp_t const e[] = { -20, -20, -20, -20, -20, -20 };
	fp_t const * const exp[1] = { e };

	uint_t k = 3;
	return ts_test(ts_williams_r, ts_williams_r_offset, x, exp, sizeof( o ) / sizeof( *o ), (ts_constant_t *)&k, &ts_williams_r_p);
}