comparison src/EM.cpp @ 94:891cbcf1e4d2 bqvec

Vectorise some calculations
author Chris Cannam
date Tue, 06 May 2014 14:29:07 +0100
parents 81eaba98985b
children 853b2d750688
comparison
equal deleted inserted replaced
93:a062b79865d6 94:891cbcf1e4d2
174 double **newSources = allocate_channels<double>(m_sourceCount, m_noteCount); 174 double **newSources = allocate_channels<double>(m_sourceCount, m_noteCount);
175 for (int i = 0; i < m_sourceCount; ++i) { 175 for (int i = 0; i < m_sourceCount; ++i) {
176 v_set(newSources[i], epsilon, m_noteCount); 176 v_set(newSources[i], epsilon, m_noteCount);
177 } 177 }
178 178
179 double *contributions = allocate<double>(m_binCount);
180
179 for (int n = 0; n < m_noteCount; ++n) { 181 for (int n = 0; n < m_noteCount; ++n) {
180 182
181 const double pitch = m_pitches[n]; 183 const double pitch = m_pitches[n];
182 184
183 for (int f = 0; f < m_shiftCount; ++f) { 185 for (int f = 0; f < m_shiftCount; ++f) {
188 190
189 const double source = m_sources[i][n]; 191 const double source = m_sources[i][n];
190 const double factor = pitch * source * shift; 192 const double factor = pitch * source * shift;
191 const double *w = templateFor(i, n, f); 193 const double *w = templateFor(i, n, f);
192 194
195 v_copy(contributions, w, m_binCount);
196 v_add(contributions, m_q, m_binCount);
197 v_scale(contributions, factor, m_binCount);
198
199 double total = v_sum(contributions, m_binCount);
200
193 if (n >= m_lowestPitch && n <= m_highestPitch) { 201 if (n >= m_lowestPitch && n <= m_highestPitch) {
194 202
195 for (int j = 0; j < m_binCount; ++j) { 203 newPitches[n] += total;
196 newPitches[n] += w[j] * m_q[j] * factor;
197 }
198 204
199 if (inRange(i, n)) { 205 if (inRange(i, n)) {
200 for (int j = 0; j < m_binCount; ++j) { 206 newSources[i][n] += total;
201 newSources[i][n] += w[j] * m_q[j] * factor;
202 }
203 } 207 }
204 } 208 }
205 209
206 for (int j = 0; j < m_binCount; ++j) { 210 newShifts[f][n] += total;
207 newShifts[f][n] += w[j] * m_q[j] * factor;
208 }
209 } 211 }
210 } 212 }
211 } 213 }
212 214
213 for (int n = 0; n < m_noteCount; ++n) { 215 for (int n = 0; n < m_noteCount; ++n) {