summaryrefslogtreecommitdiffstats
path: root/test/dpo.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/dpo.c')
-rw-r--r--test/dpo.c24
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);
+}