replaced if's with a simpler switch in radix2

pull/6/head
Ahmet Inan 2015-01-16 18:06:03 +01:00
rodzic e812fd9c54
commit 0945e8b031
1 zmienionych plików z 14 dodań i 14 usunięć

Wyświetl plik

@ -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);