# HG changeset patch # User Chris Cannam # Date 1591027932 -3600 # Node ID 8280f7a363d1c5bdedd1f97f3f0b844d1ffb5836 # Parent 1d6cca5a5621f65f087ef9ae239ea28109503135 Prefer diagonal if the cost is the same - this makes the results the same as our earlier test aligner diff -r 1d6cca5a5621 -r 8280f7a363d1 align/DTW.h --- a/align/DTW.h Fri May 29 17:39:02 2020 +0100 +++ b/align/DTW.h Mon Jun 01 17:12:12 2020 +0100 @@ -18,6 +18,8 @@ #include #include +//#define DEBUG_DTW 1 + template class DTW { @@ -38,6 +40,16 @@ auto costs = costSeries(s1, s2); +#ifdef DEBUG_DTW + SVCERR << "Cost matrix:" << endl; + for (auto v: costs) { + for (auto x: v) { + SVCERR << x << " "; + } + SVCERR << "\n"; + } +#endif + size_t j = s1.size() - 1; size_t i = s2.size() - 1; @@ -51,12 +63,12 @@ if (a < b) { --j; - if (both < a) { + if (both <= a) { --i; } } else { --i; - if (both < b) { + if (both <= b) { --j; } }