comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 478:1405f4a2caf3

* Add use-log-scale estimator. Not quite right yet; the model doesn't actually have any data in it yet at the point where we want to make this decision * Update changelog
author Chris Cannam
date Tue, 11 Nov 2008 13:54:47 +0000
parents beb2948baa77
children 55ad231c9db7
comparison
equal deleted inserted replaced
477:e0784311a103 478:1405f4a2caf3
13 COPYING included with this distribution for more information. 13 COPYING included with this distribution for more information.
14 */ 14 */
15 15
16 #include "EditableDenseThreeDimensionalModel.h" 16 #include "EditableDenseThreeDimensionalModel.h"
17 17
18 #include "base/LogRange.h"
19
18 #include <QTextStream> 20 #include <QTextStream>
19
20 #include <QStringList> 21 #include <QStringList>
21 22
22 #include <iostream> 23 #include <iostream>
23 24
24 #include <cmath> 25 #include <cmath>
245 { 246 {
246 m_binNames = names; 247 m_binNames = names;
247 emit modelChanged(); 248 emit modelChanged();
248 } 249 }
249 250
251 bool
252 EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
253 {
254 std::vector<float> sample;
255 std::vector<int> n;
256
257 for (int i = 0; i < 10; ++i) {
258 size_t index = i * 10;
259 if (index < m_data.size()) {
260 const Column &c = m_data[index];
261 while (c.size() > sample.size()) {
262 sample.push_back(0.f);
263 n.push_back(0);
264 }
265 for (int j = 0; j < c.size(); ++j) {
266 sample[j] += c[j];
267 ++n[j];
268 }
269 }
270 }
271
272 if (sample.empty()) return false;
273 for (int j = 0; j < sample.size(); ++j) {
274 if (n[j]) sample[j] /= n[j];
275 }
276
277 return LogRange::useLogScale(sample);
278 }
279
250 void 280 void
251 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update) 281 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update)
252 { 282 {
253 if (m_completion != completion) { 283 if (m_completion != completion) {
254 m_completion = completion; 284 m_completion = completion;