0b12d71e9961 — Chris Cannam a month ago
Some tidying, + make simple dispatch functions inline
3 files changed, 83 insertions(+), 100 deletions(-)

M bqvec/Allocators.h
M bqvec/VectorOpsComplex.h
M src/VectorOpsComplex.cpp
M bqvec/Allocators.h +1 -1
@@ 145,7 145,7 @@ T *allocate(size_t count)
     // Alignment must be a power of two, bigger than the pointer
     // size. Stuff the actual malloc'd pointer in just before the
     // returned value.  This is the least desirable way to do this --
-    // the other options below are all better
+    // the other options are all better
     size_t allocd = count * sizeof(T) + alignment;
     void *buf = malloc(allocd);
     if (buf) {

          
M bqvec/VectorOpsComplex.h +82 -45
@@ 477,51 477,6 @@ inline void c_magphase(float *mag, float
 }
 #endif
 
-#ifndef NO_COMPLEX_TYPES
-
-inline bq_complex_t c_phasor(bq_complex_element_t phase)
-{
-    bq_complex_t c;
-    c_phasor<bq_complex_element_t>(&c.re, &c.im, phase);
-    return c;
-}
-
-inline void c_magphase(bq_complex_element_t *mag, bq_complex_element_t *phase,
-                       bq_complex_t c)
-{
-    c_magphase<bq_complex_element_t>(mag, phase, c.re, c.im);
-}
-
-void v_polar_to_cartesian(bq_complex_t *const BQ_R__ dst,
-                          const bq_complex_element_t *const BQ_R__ mag,
-                          const bq_complex_element_t *const BQ_R__ phase,
-                          const int count);
-
-void v_polar_interleaved_to_cartesian(bq_complex_t *const BQ_R__ dst,
-                                      const bq_complex_element_t *const BQ_R__ src,
-                                      const int count);
-
-void v_cartesian_to_polar(bq_complex_element_t *const BQ_R__ mag,
-                          bq_complex_element_t *const BQ_R__ phase,
-                          const bq_complex_t *const BQ_R__ src,
-                          const int count);
-
-inline void v_cartesian_to_polar_interleaved(bq_complex_element_t *const BQ_R__ dst,
-                                             const bq_complex_t *const BQ_R__ src,
-                                             const int count)
-{
-    for (int i = 0; i < count; ++i) {
-        c_magphase<bq_complex_element_t>(&dst[i*2], &dst[i*2+1],
-                                         src[i].re, src[i].im);
-    }
-}
-
-void v_cartesian_to_magnitudes(bq_complex_element_t *const BQ_R__ mag,
-                               const bq_complex_t *const BQ_R__ src,
-                               const int count);
-
-#endif // !NO_COMPLEX_TYPES
-
 template<typename S, typename T> // S source, T target
 void v_polar_to_cartesian(T *const BQ_R__ real,
                           T *const BQ_R__ imag,

          
@@ 812,6 767,88 @@ inline void v_cartesian_interleaved_to_m
 }
 #endif
 
+#ifndef NO_COMPLEX_TYPES
+
+inline bq_complex_t c_phasor(bq_complex_element_t phase)
+{
+    bq_complex_t c;
+    c_phasor<bq_complex_element_t>(&c.re, &c.im, phase);
+    return c;
+}
+
+inline void c_magphase(bq_complex_element_t *mag, bq_complex_element_t *phase,
+                       bq_complex_t c)
+{
+    c_magphase<bq_complex_element_t>(mag, phase, c.re, c.im);
+}
+
+inline void v_polar_to_cartesian(bq_complex_t *const BQ_R__ dst,
+                                 const bq_complex_element_t *const BQ_R__ mag,
+                                 const bq_complex_element_t *const BQ_R__ phase,
+                                 const int count)
+{
+    if (sizeof(bq_complex_element_t) == sizeof(float)) {
+        v_polar_to_cartesian_interleaved((float *)dst,
+                                         (const float *)mag,
+                                         (const float *)phase,
+                                         count);
+    } else {
+        v_polar_to_cartesian_interleaved((double *)dst,
+                                         (const double *)mag,
+                                         (const double *)phase,
+                                         count);
+    }
+}
+
+void v_polar_interleaved_to_cartesian(bq_complex_t *const BQ_R__ dst,
+                                      const bq_complex_element_t *const BQ_R__ src,
+                                      const int count);
+
+inline void v_cartesian_to_polar(bq_complex_element_t *const BQ_R__ mag,
+                                 bq_complex_element_t *const BQ_R__ phase,
+                                 const bq_complex_t *const BQ_R__ src,
+                                 const int count)
+{
+    if (sizeof(bq_complex_element_t) == sizeof(float)) {
+        v_cartesian_interleaved_to_polar((float *)mag,
+                                         (float *)phase,
+                                         (const float *)src,
+                                         count);
+    } else {
+        v_cartesian_interleaved_to_polar((double *)mag,
+                                         (double *)phase,
+                                         (const double *)src,
+                                         count);
+    }
+}
+
+inline void v_cartesian_to_polar_interleaved(bq_complex_element_t *const BQ_R__ dst,
+                                             const bq_complex_t *const BQ_R__ src,
+                                             const int count)
+{
+    for (int i = 0; i < count; ++i) {
+        c_magphase<bq_complex_element_t>(&dst[i*2], &dst[i*2+1],
+                                         src[i].re, src[i].im);
+    }
+}
+
+inline void v_cartesian_to_magnitudes(bq_complex_element_t *const BQ_R__ mag,
+                                      const bq_complex_t *const BQ_R__ src,
+                                      const int count)
+{
+    if (sizeof(bq_complex_element_t) == sizeof(float)) {
+        v_cartesian_interleaved_to_magnitudes((float *)mag,
+                                              (const float *)src,
+                                              count);
+    } else {
+        v_cartesian_interleaved_to_magnitudes((double *)mag,
+                                              (const double *)src,
+                                              count);
+    }
+}
+
+#endif // !NO_COMPLEX_TYPES
+
 }
 
 #endif

          
M src/VectorOpsComplex.cpp +0 -54
@@ 221,60 221,6 @@ v_polar_to_cartesian_interleaved_pommier
 
 #ifndef NO_COMPLEX_TYPES
 
-void
-v_polar_to_cartesian(bq_complex_t *const BQ_R__ dst,
-		     const bq_complex_element_t *const BQ_R__ mag,
-		     const bq_complex_element_t *const BQ_R__ phase,
-		     const int count)
-{
-    if (sizeof(bq_complex_element_t) == sizeof(float)) {
-        v_polar_to_cartesian_interleaved((float *)dst,
-                                         (const float *)mag,
-                                         (const float *)phase,
-                                         count);
-    } else {
-        v_polar_to_cartesian_interleaved((double *)dst,
-                                         (const double *)mag,
-                                         (const double *)phase,
-                                         count);
-    }
-}
-
-void
-v_cartesian_to_polar(bq_complex_element_t *const BQ_R__ mag,
-                     bq_complex_element_t *const BQ_R__ phase,
-                     const bq_complex_t *const BQ_R__ src,
-                     const int count)
-{
-    if (sizeof(bq_complex_element_t) == sizeof(float)) {
-        v_cartesian_interleaved_to_polar((float *)mag,
-                                         (float *)phase,
-                                         (const float *)src,
-                                         count);
-    } else {
-        v_cartesian_interleaved_to_polar((double *)mag,
-                                         (double *)phase,
-                                         (const double *)src,
-                                         count);
-    }
-}
-
-void
-v_cartesian_to_magnitudes(bq_complex_element_t *const BQ_R__ mag,
-                          const bq_complex_t *const BQ_R__ src,
-                          const int count)
-{
-    if (sizeof(bq_complex_element_t) == sizeof(float)) {
-        v_cartesian_interleaved_to_magnitudes((float *)mag,
-                                              (const float *)src,
-                                              count);
-    } else {
-        v_cartesian_interleaved_to_magnitudes((double *)mag,
-                                              (const double *)src,
-                                              count);
-    }
-}
-
 #if defined USE_POMMIER_MATHFUN
 
 //!!! further tests reqd.  This is only single precision but it seems