From d09ae963e6cd05e16aa714d25ae268b65f46f1c1 Mon Sep 17 00:00:00 2001 From: Martin Rusek <martin.rusek@vsb.cz> Date: Sat, 22 Jul 2017 14:28:59 +0200 Subject: [PATCH] other: minor stuff --- SequenceComparison/dtw.cpp | 18 ++++++++++++++++++ SequenceComparison/dtw.h | 3 +++ 2 files changed, 21 insertions(+) diff --git a/SequenceComparison/dtw.cpp b/SequenceComparison/dtw.cpp index 4db4b0f..6567d43 100644 --- a/SequenceComparison/dtw.cpp +++ b/SequenceComparison/dtw.cpp @@ -377,6 +377,24 @@ void dtw::accumulate(vtr2<node<T>> &m, parameter const ¶ms) } } +template<class T> +void dtw::accumulate(vtr2<node<T>> &m, vtr parameter const ¶ms) +{ + int lenA = (int)m.size(); + int lenB = (int)m[0].size(); + + const int w = (int)(lenB * params.w); + for (int i = 1; i < lenA; i++) //row = y + { + const size_t start = max(1, (int)(ceil((i - 1) * (lenB / (double)lenA + 0.0000000001)) - w)); + const size_t end = min(lenB, (int)(ceil(i * lenB / (double)lenA)) + w); + for (size_t j = start; j < end; j++) //col = x + { + m[i][j].value += std::min({ m[i - 1][j - 1].value, m[i - 1][j].value, m[i][j - 1].value }); + } + } +} + template<class T> vtr<coords> dtw::get_minimums(vtr2<node<T>> const &m, parameter const ¶ms) { diff --git a/SequenceComparison/dtw.h b/SequenceComparison/dtw.h index fe41622..4ad07c2 100644 --- a/SequenceComparison/dtw.h +++ b/SequenceComparison/dtw.h @@ -30,6 +30,9 @@ public: template<class T> static void accumulate(vtr2<node<T>> &m, parameter const ¶ms); + template<class T> + static void accumulate_mod(vtr2<node<T>> &m, parameter const ¶ms); + template<class T> static result_path get_warping(vtr2<node<T>> const &m, coords coord, parameter const ¶ms); -- GitLab