1 #include "Correlation.h"
3 #include "MainWindow.h"
6 #include <QtTest/QtTest>
7 #include "Test/TestCorrelation.h"
16 void TestCorrelation::cleanupTestCase ()
20 void TestCorrelation::initTestCase ()
22 const QString NO_ERROR_REPORT_LOG_FILE;
23 const QString NO_REGRESSION_OPEN_FILE;
24 const bool NO_GNUPLOT_LOG_FILES =
false;
25 const bool NO_REGRESSION_IMPORT =
false;
26 const bool NO_RESET =
false;
27 const bool NO_EXPORT_ONLY =
false;
28 const bool NO_EXTRACT_IMAGE_ONLY =
false;
29 const QString NO_EXTRACT_IMAGE_EXTENSION;
30 const bool DEBUG_FLAG =
false;
31 const QStringList NO_LOAD_STARTUP_FILES;
32 const QStringList NO_COMMAND_LINE;
34 initializeLogging (
"engauge_test",
39 NO_REGRESSION_OPEN_FILE,
44 NO_EXTRACT_IMAGE_ONLY,
45 NO_EXTRACT_IMAGE_EXTENSION,
46 NO_LOAD_STARTUP_FILES,
51 void TestCorrelation::loadSinusoid (
double function [],
55 for (
int i = 0; i < n; i++) {
60 function [i] = qSin (x) / x;
65 void TestCorrelation::loadThreeTriangles (
double function [],
69 const int PEAK_SEPARATION = 50, PEAK_HALF_WIDTH = 5;
72 for (
int i = 0; i < n; i++) {
76 if (x > PEAK_HALF_WIDTH) {
79 x = i - (center - PEAK_SEPARATION);
80 if (x > PEAK_HALF_WIDTH) {
83 x = i - (center + PEAK_SEPARATION);
87 if (x < PEAK_HALF_WIDTH) {
90 function [i] = (double) (PEAK_HALF_WIDTH - x) / (double) PEAK_HALF_WIDTH;
99 void TestCorrelation::testShiftSinusoidNonPowerOf2 ()
102 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
105 double function1 [N], function2 [N], correlations [N];
112 loadSinusoid (function1, N, INDEX_MAX);
113 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
115 correlation.correlateWithShift (N,
122 QVERIFY ((binStartMax = INDEX_SHIFT));
125 void TestCorrelation::testShiftSinusoidPowerOf2 ()
128 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
131 double function1 [N], function2 [N], correlations [N];
138 loadSinusoid (function1, N, INDEX_MAX);
139 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
141 correlation.correlateWithShift (N,
148 QVERIFY ((binStartMax = INDEX_SHIFT));
151 void TestCorrelation::testShiftThreeTrianglesNonPowerOf2 ()
154 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
157 double function1 [N], function2 [N], correlations [N];
164 loadThreeTriangles (function1, N, INDEX_MAX);
165 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
167 correlation.correlateWithShift (N,
174 QVERIFY ((binStartMax = INDEX_SHIFT));
177 void TestCorrelation::testShiftThreeTrianglesPowerOf2 ()
180 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
183 double function1 [N], function2 [N], correlations [N];
190 loadThreeTriangles (function1, N, INDEX_MAX);
191 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
193 correlation.correlateWithShift (N,
200 QVERIFY ((binStartMax = INDEX_SHIFT));
Fast cross correlation between two functions.
Unit tests of fast correlation algorithm.
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...