6#include <QtTest/QtTest>
16const QString WEBPAGE (
"https://tools.timodenk.com/cubic-spline-interpolation");
29void TestSpline::cleanupTestCase ()
46#ifdef SHOWCOEFFICIENTS
48 <<
"(t,x) inputs to be copied to " <<
WEBPAGE.toLatin1().data()
50 for (
i = 0;
i < t.size();
i++) {
54 <<
"x=d*(t-ti)^3+c*(t-ti)^2+b*(t-ti)+a natural cubic spline results to be used in this code"
56 for (
i = 0;
i < t.size() - 1;
i++) {
61 s.m_elements[
i].a().x(),
62 s.m_elements[
i].b().x(),
63 s.m_elements[
i].c().x(),
64 s.m_elements[
i].d().x());
67 <<
"x=d*t^3+c*t^2+b*t+a outputs to be compared to results from " <<
WEBPAGE.toLatin1().data()
70 for (
i = 0;
i < t.size() - 1;
i++) {
71 s.computeUntranslatedCoefficients (
s.m_elements[
i].a().x(),
72 s.m_elements[
i].b().x(),
73 s.m_elements[
i].c().x(),
74 s.m_elements[
i].d().x(),
80#ifdef SHOWCOEFFICIENTS
114#ifdef SHOWCOEFFICIENTS
116 <<
"(t,y) inputs to be copied to " <<
WEBPAGE.toLatin1().data()
118 for (
i = 0;
i <
xy.size();
i++) {
122 <<
"y=d*(t-ti)^3+c*(t-ti)^2+b*(t-ti)+a natural cubic spline results to be used in this code"
124 for (
i = 0;
i <
xy.size() - 1;
i++) {
129 s.m_elements[
i].a().y(),
130 s.m_elements[
i].b().y(),
131 s.m_elements[
i].c().y(),
132 s.m_elements[
i].d().y());
135 <<
"y=d*t^3+c*t^2+b*t+a outputs to be compared to results from " <<
WEBPAGE.toLatin1().data()
138 for (
i = 0;
i < t.size() - 1;
i++) {
139 s.computeUntranslatedCoefficients (
s.m_elements[
i].a().y(),
140 s.m_elements[
i].b().y(),
141 s.m_elements[
i].c().y(),
142 s.m_elements[
i].d().y(),
148#ifdef SHOWCOEFFICIENTS
187void TestSpline::initTestCase ()
220void TestSpline::testCoefficientsFromOrdinals ()
236 vector<SplinePair>::const_iterator
itr;
244 success &= coefCheckX (t,
247 success &= coefCheckY (t,
254void TestSpline::testSharpTransition ()
256 const int NUM_T = 60;
276 vector<SplinePair>::const_iterator
itrB;
279 t.push_back (
pair.x());
285 double tStop = t[t.size() - 1];
299 map<double, bool>::const_iterator
itrX;
301 double x =
itrX->first;
307 cout <<
"set datafile missing \"?\"" <<
endl;
308 cout <<
"plot \"gnuplot.in\" using 1:2 with linespoints, \"gnuplot.in\" using 1:3 with lines" <<
endl;
312 map<double, bool>::const_iterator
itrM;
314 double x =
itrM->first;
316 string yB =
"?",
yA =
"?";
318 vector<SplinePair>::iterator
itrB;
320 if (
itrB->x() == x) {
328 vector<SplinePair>::iterator
itrA;
330 if (
itrA->x() == x) {
357void TestSpline::testSplinesAsControlPoints ()
361 const int NUM_T = 60;
const int INNER_RADIUS_MIN
void initializeLogging(const QString &name, const QString &filename, bool isDebug)
const bool NO_EXPORT_ONLY
const QStringList NO_COMMAND_LINE
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_DROP_REGRESSION
const QString WEBPAGE("https://tools.timodenk.com/cubic-spline-interpolation")
Main window consisting of menu, graphics scene, status bar and optional toolbars as a Single Document...
Single X/Y pair for cubic spline interpolation initialization and calculations.
double y() const
Get method for y.
double x() const
Get method for x.
Cubic interpolation given independent and dependent value vectors.
Unit test of spline library.
TestSpline(QObject *parent=0)
Single constructor.