comparison data/fft/FFTMemoryCache.h @ 509:6066bde1c126

* Cut back on the locking and general workload in FFTDataServer::getMagnitudes(). This stuff is far too complicated!
author Chris Cannam
date Mon, 08 Dec 2008 11:15:13 +0000
parents 115f60df1e4d
children 3cc4b7cd2aa5
comparison
equal deleted inserted replaced
508:1b8c748fd7ea 509:6066bde1c126
53 virtual void reset(); // zero-fill or 1-fill as appropriate without changing size 53 virtual void reset(); // zero-fill or 1-fill as appropriate without changing size
54 54
55 virtual float getMagnitudeAt(size_t x, size_t y) const { 55 virtual float getMagnitudeAt(size_t x, size_t y) const {
56 if (m_storageType == Rectangular) { 56 if (m_storageType == Rectangular) {
57 Profiler profiler("FFTMemoryCache::getMagnitudeAt: cart to polar"); 57 Profiler profiler("FFTMemoryCache::getMagnitudeAt: cart to polar");
58 return sqrt(m_freal[x][y] * m_freal[x][y] + 58 return sqrtf(m_freal[x][y] * m_freal[x][y] +
59 m_fimag[x][y] * m_fimag[x][y]); 59 m_fimag[x][y] * m_fimag[x][y]);
60 } else { 60 } else {
61 return getNormalizedMagnitudeAt(x, y) * m_factor[x]; 61 return getNormalizedMagnitudeAt(x, y) * m_factor[x];
62 } 62 }
63 } 63 }
64 64
92 Profiler profiler("FFTMemoryCache::getValuesAt: polar to cart"); 92 Profiler profiler("FFTMemoryCache::getValuesAt: polar to cart");
93 float mag = getMagnitudeAt(x, y); 93 float mag = getMagnitudeAt(x, y);
94 float phase = getPhaseAt(x, y); 94 float phase = getPhaseAt(x, y);
95 real = mag * cosf(phase); 95 real = mag * cosf(phase);
96 imag = mag * sinf(phase); 96 imag = mag * sinf(phase);
97 }
98 }
99
100 virtual void getMagnitudesAt(size_t x, float *values, size_t minbin, size_t count, size_t step) const
101 {
102 if (m_storageType == Rectangular) {
103 for (size_t i = 0; i < count; ++i) {
104 size_t y = i * step + minbin;
105 values[i] = sqrtf(m_freal[x][y] * m_freal[x][y] +
106 m_fimag[x][y] * m_fimag[x][y]);
107 }
108 } else if (m_storageType == Polar) {
109 for (size_t i = 0; i < count; ++i) {
110 size_t y = i * step + minbin;
111 values[i] = m_fmagnitude[x][y] * m_factor[x];
112 }
113 } else {
114 for (size_t i = 0; i < count; ++i) {
115 size_t y = i * step + minbin;
116 values[i] = (float(m_magnitude[x][y]) * m_factor[x]) / 65535.0;
117 }
97 } 118 }
98 } 119 }
99 120
100 virtual bool haveSetColumnAt(size_t x) const { 121 virtual bool haveSetColumnAt(size_t x) const {
101 return m_colset.get(x); 122 return m_colset.get(x);