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 DEBUG_FLAG =
false;
29 const QStringList NO_LOAD_STARTUP_FILES;
31 initializeLogging (
"engauge_test",
36 NO_REGRESSION_OPEN_FILE,
41 NO_LOAD_STARTUP_FILES);
45 void TestCorrelation::loadSinusoid (
double function [],
49 for (
int i = 0; i < n; i++) {
54 function [i] = qSin (x) / x;
59 void TestCorrelation::loadThreeTriangles (
double function [],
63 const int PEAK_SEPARATION = 50, PEAK_HALF_WIDTH = 5;
66 for (
int i = 0; i < n; i++) {
70 if (x > PEAK_HALF_WIDTH) {
73 x = i - (center - PEAK_SEPARATION);
74 if (x > PEAK_HALF_WIDTH) {
77 x = i - (center + PEAK_SEPARATION);
81 if (x < PEAK_HALF_WIDTH) {
84 function [i] = (double) (PEAK_HALF_WIDTH - x) / (double) PEAK_HALF_WIDTH;
93 void TestCorrelation::testShiftSinusoidNonPowerOf2 ()
96 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
99 double function1 [N], function2 [N], correlations [N];
106 loadSinusoid (function1, N, INDEX_MAX);
107 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
109 correlation.correlateWithShift (N,
116 QVERIFY ((binStartMax = INDEX_SHIFT));
119 void TestCorrelation::testShiftSinusoidPowerOf2 ()
122 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
125 double function1 [N], function2 [N], correlations [N];
132 loadSinusoid (function1, N, INDEX_MAX);
133 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
135 correlation.correlateWithShift (N,
142 QVERIFY ((binStartMax = INDEX_SHIFT));
145 void TestCorrelation::testShiftThreeTrianglesNonPowerOf2 ()
148 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
151 double function1 [N], function2 [N], correlations [N];
158 loadThreeTriangles (function1, N, INDEX_MAX);
159 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
161 correlation.correlateWithShift (N,
168 QVERIFY ((binStartMax = INDEX_SHIFT));
171 void TestCorrelation::testShiftThreeTrianglesPowerOf2 ()
174 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
177 double function1 [N], function2 [N], correlations [N];
184 loadThreeTriangles (function1, N, INDEX_MAX);
185 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
187 correlation.correlateWithShift (N,
194 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...