comparison data/model/EditableDenseThreeDimensionalModel.cpp @ 1044:31f01931b781 cxx11

Move to using double rather than float for floating-point calculations (float only for storage); more build fixes
author Chris Cannam
date Mon, 09 Mar 2015 12:02:10 +0000
parents a1cd5abcb38b
children 0fd3661bcfff
comparison
equal deleted inserted replaced
1043:fe39581d249b 1044:31f01931b781
24 24
25 #include <iostream> 25 #include <iostream>
26 26
27 #include <cmath> 27 #include <cmath>
28 #include <cassert> 28 #include <cassert>
29
30 using std::vector;
29 31
30 #include "system/System.h" 32 #include "system/System.h"
31 33
32 EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate, 34 EditableDenseThreeDimensionalModel::EditableDenseThreeDimensionalModel(sv_samplerate_t sampleRate,
33 int resolution, 35 int resolution,
443 bool 445 bool
444 EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const 446 EditableDenseThreeDimensionalModel::shouldUseLogValueScale() const
445 { 447 {
446 QReadLocker locker(&m_lock); 448 QReadLocker locker(&m_lock);
447 449
448 QVector<float> sample; 450 vector<double> sample;
449 QVector<int> n; 451 vector<int> n;
450 452
451 for (int i = 0; i < 10; ++i) { 453 for (int i = 0; i < 10; ++i) {
452 int index = i * 10; 454 int index = i * 10;
453 if (index < m_data.size()) { 455 if (index < m_data.size()) {
454 const Column &c = m_data.at(index); 456 const Column &c = m_data.at(index);
455 while (c.size() > sample.size()) { 457 while (c.size() > int(sample.size())) {
456 sample.push_back(0.f); 458 sample.push_back(0.0);
457 n.push_back(0); 459 n.push_back(0);
458 } 460 }
459 for (int j = 0; j < c.size(); ++j) { 461 for (int j = 0; j < c.size(); ++j) {
460 sample[j] += c.at(j); 462 sample[j] += c.at(j);
461 ++n[j]; 463 ++n[j];
462 } 464 }
463 } 465 }
464 } 466 }
465 467
466 if (sample.empty()) return false; 468 if (sample.empty()) return false;
467 for (int j = 0; j < sample.size(); ++j) { 469 for (decltype(sample)::size_type j = 0; j < sample.size(); ++j) {
468 if (n[j]) sample[j] /= float(n[j]); 470 if (n[j]) sample[j] /= n[j];
469 } 471 }
470 472
471 return LogRange::useLogScale(sample.toStdVector()); 473 return LogRange::useLogScale(sample);
472 } 474 }
473 475
474 void 476 void
475 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update) 477 EditableDenseThreeDimensionalModel::setCompletion(int completion, bool update)
476 { 478 {