Mercurial > hg > svcore
comparison base/LogRange.cpp @ 1073:d4212687520e
minor debug thing
author | Chris Cannam |
---|---|
date | Thu, 21 May 2015 16:38:07 +0100 |
parents | 31f01931b781 |
children | b061b9f8fca5 |
comparison
equal
deleted
inserted
replaced
1071:f4ad0bfceeb7 | 1073:d4212687520e |
---|---|
24 LogRange::mapRange(double &min, double &max, double logthresh) | 24 LogRange::mapRange(double &min, double &max, double logthresh) |
25 { | 25 { |
26 if (min > max) std::swap(min, max); | 26 if (min > max) std::swap(min, max); |
27 if (max == min) max = min + 1; | 27 if (max == min) max = min + 1; |
28 | 28 |
29 // SVDEBUG << "LogRange::mapRange: min = " << min << ", max = " << max << endl; | 29 // cerr << "LogRange::mapRange: min = " << min << ", max = " << max << endl; |
30 | 30 |
31 if (min >= 0.f) { | 31 if (min >= 0.f) { |
32 | 32 |
33 max = log10(max); // we know max != 0 | 33 max = log10(max); // we know max != 0 |
34 | 34 |
35 if (min == 0.f) min = std::min(logthresh, max); | 35 if (min == 0.f) min = std::min(logthresh, max); |
36 else min = log10(min); | 36 else min = log10(min); |
37 | 37 |
38 // SVDEBUG << "LogRange::mapRange: positive: min = " << min << ", max = " << max << endl; | 38 // cerr << "LogRange::mapRange: positive: min = " << min << ", max = " << max << endl; |
39 | 39 |
40 } else if (max <= 0.f) { | 40 } else if (max <= 0.f) { |
41 | 41 |
42 min = log10(-min); // we know min != 0 | 42 min = log10(-min); // we know min != 0 |
43 | 43 |
44 if (max == 0.f) max = std::min(logthresh, min); | 44 if (max == 0.f) max = std::min(logthresh, min); |
45 else max = log10(-max); | 45 else max = log10(-max); |
46 | 46 |
47 std::swap(min, max); | 47 std::swap(min, max); |
48 | 48 |
49 // SVDEBUG << "LogRange::mapRange: negative: min = " << min << ", max = " << max << endl; | 49 // cerr << "LogRange::mapRange: negative: min = " << min << ", max = " << max << endl; |
50 | 50 |
51 } else { | 51 } else { |
52 | 52 |
53 // min < 0 and max > 0 | 53 // min < 0 and max > 0 |
54 | 54 |
55 max = log10(std::max(max, -min)); | 55 max = log10(std::max(max, -min)); |
56 min = std::min(logthresh, max); | 56 min = std::min(logthresh, max); |
57 | 57 |
58 // SVDEBUG << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << endl; | 58 // cerr << "LogRange::mapRange: spanning: min = " << min << ", max = " << max << endl; |
59 } | 59 } |
60 | 60 |
61 if (min == max) min = max - 1; | 61 if (min == max) min = max - 1; |
62 } | 62 } |
63 | 63 |