From 0945e8b031b7804feae301b1faf5014e7f6227f8 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Fri, 16 Jan 2015 18:06:03 +0100 Subject: [PATCH] replaced if's with a simpler switch in radix2 --- app/src/main/rs/radix2.rsh | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/app/src/main/rs/radix2.rsh b/app/src/main/rs/radix2.rsh index f926002..87fe896 100644 --- a/app/src/main/rs/radix2.rsh +++ b/app/src/main/rs/radix2.rsh @@ -22,20 +22,20 @@ limitations under the License. static void radix2(complex_t *out, float *in, int N, int S, int L) { - if (1 == N) { - out[0] = complex(in[0], 0.0f); - return; - } else if (2 == N) { - out[0] = complex(in[0] + in[S], 0.0f); - out[1] = complex(in[0] - in[S], 0.0f); - return; - } else if (4 == N) { - complex_t w = radix2_z[1 << L]; - out[0] = complex(in[0] + in[S] + in[2 * S] + in[3 * S], 0.0f); - out[1] = complex(in[0] - in[2 * S], 0.0f) + w * (in[S] - in[3 * S]); - out[2] = complex(in[0] - in[S] + in[2 * S] - in[3 * S], 0.0f); - out[3] = complex(in[0] - in[2 * S], 0.0f) + w * (in[3 * S] - in[S]); - return; + switch (N) { + case 1: + out[0] = complex(in[0], 0.0f); + return; + case 2: + out[0] = complex(in[0] + in[S], 0.0f); + out[1] = complex(in[0] - in[S], 0.0f); + return; + case 4: + out[0] = complex(in[0] + in[S] + in[2 * S] + in[3 * S], 0.0f); + out[1] = complex(in[0] - in[2 * S], 0.0f) + radix2_z[1 << L] * (in[S] - in[3 * S]); + out[2] = complex(in[0] - in[S] + in[2 * S] - in[3 * S], 0.0f); + out[3] = complex(in[0] - in[2 * S], 0.0f) + radix2_z[1 << L] * (in[3 * S] - in[S]); + return; } radix2(out, in, N / 2, 2 * S, L + 1); radix2(out + N / 2, in + S, N / 2, 2 * S, L + 1);