# HG changeset patch # User Chris Cannam # Date 1399453039 -3600 # Node ID 91bb029a847a50144d5664d82b6dfff2fc6f58d0 # Parent a6e136aaa202e57bc2e675c2031886d5a65deac2 Reorder the calculations to match the series of vector operations in the most recent bqvec code, just in case it's the order of vector calculations that is saving the time rather than the avoidance of std::vector diff -r a6e136aaa202 -r 91bb029a847a src/EM.cpp --- a/src/EM.cpp Tue May 06 12:56:18 2014 +0100 +++ b/src/EM.cpp Wed May 07 09:57:19 2014 +0100 @@ -164,6 +164,8 @@ Grid newShifts(m_shiftCount, V(m_noteCount, epsilon)); Grid newSources(m_instrumentCount, V(m_noteCount, epsilon)); + V contributions(m_binCount); + for (int n = 0; n < m_noteCount; ++n) { const double pitch = m_pitches[n]; @@ -178,22 +180,31 @@ const double factor = pitch * source * shift; const double *w = templateFor(i, n, f); + for (int j = 0; j < m_binCount; ++j) { + contributions[j] = w[j]; + } + for (int j = 0; j < m_binCount; ++j) { + contributions[j] *= m_q.at(j); + } + for (int j = 0; j < m_binCount; ++j) { + contributions[j] *= factor; + } + + double total = 0.0; + for (int j = 0; j < m_binCount; ++j) { + total += contributions.at(j); + } + if (n >= m_lowestPitch && n <= m_highestPitch) { - for (int j = 0; j < m_binCount; ++j) { - newPitches[n] += w[j] * m_q[j] * factor; - } - + newPitches[n] += total; + if (inRange(i, n)) { - for (int j = 0; j < m_binCount; ++j) { - newSources[i][n] += w[j] * m_q[j] * factor; - } + newSources[i][n] += total; } } - for (int j = 0; j < m_binCount; ++j) { - newShifts[f][n] += w[j] * m_q[j] * factor; - } + newShifts[f][n] += total; } } }