Mercurial > hg > silvet
comparison src/EM.cpp @ 116:91bb029a847a timing
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
author | Chris Cannam |
---|---|
date | Wed, 07 May 2014 09:57:19 +0100 |
parents | a6e136aaa202 |
children |
comparison
equal
deleted
inserted
replaced
89:a6e136aaa202 | 116:91bb029a847a |
---|---|
162 { | 162 { |
163 V newPitches(m_noteCount, epsilon); | 163 V newPitches(m_noteCount, epsilon); |
164 Grid newShifts(m_shiftCount, V(m_noteCount, epsilon)); | 164 Grid newShifts(m_shiftCount, V(m_noteCount, epsilon)); |
165 Grid newSources(m_instrumentCount, V(m_noteCount, epsilon)); | 165 Grid newSources(m_instrumentCount, V(m_noteCount, epsilon)); |
166 | 166 |
167 V contributions(m_binCount); | |
168 | |
167 for (int n = 0; n < m_noteCount; ++n) { | 169 for (int n = 0; n < m_noteCount; ++n) { |
168 | 170 |
169 const double pitch = m_pitches[n]; | 171 const double pitch = m_pitches[n]; |
170 | 172 |
171 for (int f = 0; f < m_shiftCount; ++f) { | 173 for (int f = 0; f < m_shiftCount; ++f) { |
176 | 178 |
177 const double source = m_sources[i][n]; | 179 const double source = m_sources[i][n]; |
178 const double factor = pitch * source * shift; | 180 const double factor = pitch * source * shift; |
179 const double *w = templateFor(i, n, f); | 181 const double *w = templateFor(i, n, f); |
180 | 182 |
183 for (int j = 0; j < m_binCount; ++j) { | |
184 contributions[j] = w[j]; | |
185 } | |
186 for (int j = 0; j < m_binCount; ++j) { | |
187 contributions[j] *= m_q.at(j); | |
188 } | |
189 for (int j = 0; j < m_binCount; ++j) { | |
190 contributions[j] *= factor; | |
191 } | |
192 | |
193 double total = 0.0; | |
194 for (int j = 0; j < m_binCount; ++j) { | |
195 total += contributions.at(j); | |
196 } | |
197 | |
181 if (n >= m_lowestPitch && n <= m_highestPitch) { | 198 if (n >= m_lowestPitch && n <= m_highestPitch) { |
182 | 199 |
183 for (int j = 0; j < m_binCount; ++j) { | 200 newPitches[n] += total; |
184 newPitches[n] += w[j] * m_q[j] * factor; | 201 |
202 if (inRange(i, n)) { | |
203 newSources[i][n] += total; | |
185 } | 204 } |
186 | 205 } |
187 if (inRange(i, n)) { | 206 |
188 for (int j = 0; j < m_binCount; ++j) { | 207 newShifts[f][n] += total; |
189 newSources[i][n] += w[j] * m_q[j] * factor; | |
190 } | |
191 } | |
192 } | |
193 | |
194 for (int j = 0; j < m_binCount; ++j) { | |
195 newShifts[f][n] += w[j] * m_q[j] * factor; | |
196 } | |
197 } | 208 } |
198 } | 209 } |
199 } | 210 } |
200 | 211 |
201 for (int n = 0; n < m_noteCount; ++n) { | 212 for (int n = 0; n < m_noteCount; ++n) { |