comparison base/LogRange.h @ 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 06f13a3b9e9e
children 667e369cfeab
comparison
equal deleted inserted replaced
1043:fe39581d249b 1044:31f01931b781
26 * Map a linear range onto a logarithmic range. min and max are 26 * Map a linear range onto a logarithmic range. min and max are
27 * passed as the extents of the linear range and returned as the 27 * passed as the extents of the linear range and returned as the
28 * extents of the logarithmic range. thresh is the minimum value 28 * extents of the logarithmic range. thresh is the minimum value
29 * for the log range, to be used if the linear range spans zero. 29 * for the log range, to be used if the linear range spans zero.
30 */ 30 */
31 static void mapRange(float &min, float &max, float thresh = -10); 31 static void mapRange(double &min, double &max, double thresh = -10);
32 32
33 /** 33 /**
34 * Map a value onto a logarithmic range. This just means taking 34 * Map a value onto a logarithmic range. This just means taking
35 * the base-10 log of the absolute value, or using the threshold 35 * the base-10 log of the absolute value, or using the threshold
36 * value if the absolute value is zero. 36 * value if the absolute value is zero.
37 */ 37 */
38 static float map(float value, float thresh = -10); 38 static double map(double value, double thresh = -10);
39 39
40 /** 40 /**
41 * Map a value from the logarithmic range back again. This just 41 * Map a value from the logarithmic range back again. This just
42 * means taking the value'th power of ten. 42 * means taking the value'th power of ten.
43 */ 43 */
44 static float unmap(float value); 44 static double unmap(double value);
45 45
46 /** 46 /**
47 * Estimate whether a set of values would be more properly shown 47 * Estimate whether a set of values would be more properly shown
48 * using a logarithmic than a linear scale. This is only ever 48 * using a logarithmic than a linear scale. This is only ever
49 * going to be a rough guess. 49 * going to be a rough guess.
50 */ 50 */
51 static bool useLogScale(std::vector<float> values); 51 static bool useLogScale(std::vector<double> values);
52 52
53 }; 53 };
54 54
55 #endif 55 #endif