MCPcopy Create free account
hub / github.com/algorithm-archivists/algorithm-archive / bit_reverse

Function bit_reverse

contents/cooley_tukey/code/c/fft.c:58–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

56}
57
58void bit_reverse(double complex *X, size_t N) {
59 for (size_t i = 0; i < N; ++i) {
60 size_t n = i;
61 size_t a = i;
62 int count = (int)log2((double)N) - 1;
63
64 n >>= 1;
65 while (n > 0) {
66 a = (a << 1) | (n & 1);
67 count--;
68 n >>= 1;
69 }
70 n = (a << count) & (size_t)((1 << (size_t)log2((double)N)) - 1);
71
72 if (n > i) {
73 double complex tmp = X[i];
74 X[i] = X[n];
75 X[n] = tmp;
76 }
77 }
78}
79
80void iterative_cooley_tukey(double complex *X, size_t N) {
81 bit_reverse(X, N);

Callers 1

iterative_cooley_tukeyFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected