6#include <QtTest/QtTest>
16void TestCorrelation::cleanupTestCase ()
20void TestCorrelation::initTestCase ()
27 const bool NO_RESET =
false;
53void TestCorrelation::loadSinusoid (
double function [],
57 for (
int i = 0; i < n; i++) {
62 function [i] = qSin (x) / x;
67void TestCorrelation::loadThreeTriangles (
double function [],
71 const int PEAK_SEPARATION = 50, PEAK_HALF_WIDTH = 5;
74 for (
int i = 0; i < n; i++) {
78 if (x > PEAK_HALF_WIDTH) {
81 x = i - (center - PEAK_SEPARATION);
82 if (x > PEAK_HALF_WIDTH) {
85 x = i - (center + PEAK_SEPARATION);
89 if (x < PEAK_HALF_WIDTH) {
92 function [i] = (double) (PEAK_HALF_WIDTH - x) / (double) PEAK_HALF_WIDTH;
101void TestCorrelation::testShiftSinusoidNonPowerOf2 ()
104 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
107 double function1 [N], function2 [N], correlations [N];
110 Correlation correlation (N);
114 loadSinusoid (function1, N, INDEX_MAX);
115 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
117 correlation.correlateWithShift (N,
124 QVERIFY ((binStartMax = INDEX_SHIFT));
127void TestCorrelation::testShiftSinusoidPowerOf2 ()
130 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
133 double function1 [N], function2 [N], correlations [N];
136 Correlation correlation (N);
140 loadSinusoid (function1, N, INDEX_MAX);
141 loadSinusoid (function2, N, INDEX_MAX + INDEX_SHIFT);
143 correlation.correlateWithShift (N,
150 QVERIFY ((binStartMax = INDEX_SHIFT));
153void TestCorrelation::testShiftThreeTrianglesNonPowerOf2 ()
156 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
159 double function1 [N], function2 [N], correlations [N];
162 Correlation correlation (N);
166 loadThreeTriangles (function1, N, INDEX_MAX);
167 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
169 correlation.correlateWithShift (N,
176 QVERIFY ((binStartMax = INDEX_SHIFT));
179void TestCorrelation::testShiftThreeTrianglesPowerOf2 ()
182 const int INDEX_MAX = 200, INDEX_SHIFT = 50;
185 double function1 [N], function2 [N], correlations [N];
188 Correlation correlation (N);
192 loadThreeTriangles (function1, N, INDEX_MAX);
193 loadThreeTriangles (function2, N, INDEX_MAX + INDEX_SHIFT);
195 correlation.correlateWithShift (N,
202 QVERIFY ((binStartMax = INDEX_SHIFT));
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
const bool NO_EXPORT_ONLY
const QStringList NO_COMMAND_LINE
const QString NO_EXTRACT_IMAGE_EXTENSION
const QString NO_ERROR_REPORT_LOG_FILE
const bool NO_GNUPLOT_LOG_FILES
const QString NO_REGRESSION_OPEN_FILE
const QStringList NO_LOAD_STARTUP_FILES
const bool NO_REGRESSION_IMPORT
const bool NO_EXTRACT_IMAGE_ONLY
const bool NO_DROP_REGRESSION
Unit tests of fast correlation algorithm.
TestCorrelation(QObject *parent=0)
Single constructor.