summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2010-09-25 00:13:01 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2010-09-25 00:13:01 -0400
commitc0a705de6f28b878ea5ab47f1c17aa51c88840e6 (patch)
tree8d1d3d06ced1946ac692540b2aadefbaddbc1282
parent897f5fbac08776364dc93cd350e0cd6d915960f7 (diff)
Add a shift function
-rw-r--r--fft.c13
-rw-r--r--fft.h4
2 files changed, 17 insertions, 0 deletions
diff --git a/fft.c b/fft.c
index f903dd4..1897d7e 100644
--- a/fft.c
+++ b/fft.c
@@ -76,3 +76,16 @@ ifft (complex_t *buffer, int n)
do_fft (buffer, n, p, TRUE);
}
+
+void
+shift (complex_t *buffer, int n)
+{
+ int i;
+
+ for (i = 0; i < n / 2; ++i)
+ {
+ complex_t tmp = buffer[i];
+ buffer[i] = buffer[i + n/2];
+ buffer[i + n/2] = tmp;
+ }
+}
diff --git a/fft.h b/fft.h
index 8a4e20e..35a756d 100644
--- a/fft.h
+++ b/fft.h
@@ -67,3 +67,7 @@ fft (complex_t *buffer, int n);
void
ifft (complex_t *buffer, int n);
+
+/* Shifts the zero component to the center of the array */
+void
+shift (complex_t *buffer, int n);