summaryrefslogtreecommitdiffstats
path: root/test/disparity_index.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/disparity_index.c')
-rw-r--r--test/disparity_index.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/disparity_index.c b/test/disparity_index.c
new file mode 100644
index 0000000..1860f8f
--- /dev/null
+++ b/test/disparity_index.c
@@ -0,0 +1,27 @@
+#include <math.h>
+#include <stddef.h>
+#include "ts.h"
+
+bool ts_test_disparity_index( void )
+{
+ fp_t const x0[] = { 10, 10, 10, 10, 15, 15, 15 };
+ fp_t const * const x[] = { x0 };
+
+ uint_t k = 3;
+
+ fp_t sma = (10 + 10 + 10) / 3.0;
+ fp_t e[5] = { 0 };
+ e[0] = (10 - sma) / sma * 100;
+ sma = sma + (10 - 10) / 3.0;
+ e[1] = (10 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[2] = (15 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[3] = (15 - sma) / sma * 100;
+ sma = sma + (15 - 10) / 3.0;
+ e[4] = (15 - sma) / sma * 100;
+
+ fp_t const * const exp[1] = { e };
+
+ return ts_test(ts_disparity_index, ts_disparity_index_offset, x, exp, sizeof( x0 ) / sizeof( *x0 ), (ts_constant_t *)&k, &ts_disparity_index_p);
+}