comparison src/Matcher.cpp @ 206:fb799a1aabd8 memory

Don't create matrices in other matcher, now they aren't referred to
author Chris Cannam
date Fri, 27 Feb 2015 12:35:02 +0000
parents 010b91e44098
children 0159aff8c4c5
comparison
equal deleted inserted replaced
205:010b91e44098 206:fb799a1aabd8
140 pair<int, int> 140 pair<int, int>
141 Matcher::getColRangeForRow(int i) 141 Matcher::getColRangeForRow(int i)
142 { 142 {
143 if (m_firstPM) { 143 if (m_firstPM) {
144 if (i < 0 || i >= int(m_first.size())) { 144 if (i < 0 || i >= int(m_first.size())) {
145 cerr << "ERROR: Matcher::getColRange(" << i << "): Index out of range" 145 cerr << "ERROR: Matcher::getColRangeForRow(" << i << "): Index out of range"
146 << endl; 146 << endl;
147 throw "Index out of range"; 147 throw "Index out of range";
148 } else { 148 } else {
149 return pair<int, int>(m_first[i], m_last[i]); 149 return pair<int, int>(m_first[i], m_last[i]);
150 } 150 }
152 return m_otherMatcher->getRowRangeForCol(i); 152 return m_otherMatcher->getRowRangeForCol(i);
153 } 153 }
154 } 154 }
155 155
156 pair<int, int> 156 pair<int, int>
157 Matcher::getRowRangeForCol(int j) 157 Matcher::getRowRangeForCol(int i)
158 { 158 {
159 if (m_firstPM) { 159 if (m_firstPM) {
160 160
161 //!!! tedious, examine uses (& consider restoring use of 161 if (i < 0 || i >= int(m_otherMatcher->m_first.size())) {
162 //!!! first/last in "other" matcher) 162 cerr << "ERROR: Matcher::getRowRangeForCol(" << i << "): Index out of range"
163 int a = -1, b = -1;
164 for (int i = 0; i < int(m_first.size()); ++i) {
165 if (j >= m_first[i] && j < m_last[i]) {
166 if (a == -1) a = i;
167 b = i;
168 }
169 }
170 if (a == -1) {
171 cerr << "ERROR: Matcher::getRowRange(" << j << "): Index out of range"
172 << endl; 163 << endl;
173 throw "Index out of range"; 164 throw "Index out of range";
174 } else { 165 } else {
175 return pair<int, int>(a, b + 1); 166 return pair<int, int>(m_otherMatcher->m_first[i],
176 } 167 m_otherMatcher->m_last[i]);
177 168 }
178 } else { 169
179 return m_otherMatcher->getColRangeForRow(j); 170 } else {
171 return m_otherMatcher->getColRangeForRow(i);
180 } 172 }
181 } 173 }
182 174
183 distance_t 175 distance_t
184 Matcher::getDistance(int i, int j) 176 Matcher::getDistance(int i, int j)
273 } 265 }
274 266
275 void 267 void
276 Matcher::size() 268 Matcher::size()
277 { 269 {
278 int distSize = (m_params.maxRunCount + 1) * m_blockSize;
279 m_bestPathCost.resize(m_distXSize, pathcostvec_t(distSize, InvalidPathCost));
280 m_distance.resize(m_distXSize, distancevec_t(distSize, InvalidDistance));
281 m_advance.resize(m_distXSize, advancevec_t(distSize, AdvanceNone));
282 m_first.resize(m_distXSize, 0); 270 m_first.resize(m_distXSize, 0);
283 m_last.resize(m_distXSize, 0); 271 m_last.resize(m_distXSize, 0);
272
273 if (m_firstPM) {
274 int distSize = (m_params.maxRunCount + 1) * m_blockSize;
275 m_bestPathCost.resize(m_distXSize, pathcostvec_t(distSize, InvalidPathCost));
276 m_distance.resize(m_distXSize, distancevec_t(distSize, InvalidDistance));
277 m_advance.resize(m_distXSize, advancevec_t(distSize, AdvanceNone));
278 }
284 } 279 }
285 280
286 void 281 void
287 Matcher::consumeFeatureVector(const feature_t &feature) 282 Matcher::consumeFeatureVector(const feature_t &feature)
288 { 283 {