Converting Complex to ArrayList<Float> in Java
<p>I have an input signal that I want to store in an ArrayList then convert it into Complex, which goes something like this</p>

<pre><code>-0.03480425839330703
0.07910192950176387
0.7233322451735928
0.1659819820667019
</code></pre>

<p>and this outputs its FFT like this</p>

<pre><code>0.9336118983487516
-0.7581365035668999 + 0.08688005256493803i
0.44344407521182005
-0.7581365035668999 - 0.08688005256493803i
</code></pre>

<p>This is in a complex structure, I want to convert this into an ArrayList type. while dropping the <code>+ 0.08688005256493803i</code> value.</p>

<p>So All I need are these values</p>

<pre><code>0.9336118983487516
-0.7581365035668999
0.44344407521182005
-0.7581365035668999
</code></pre>

<p>What is the best way of going about this?</p>

<p>And this is the code that I am using</p>

<pre><code>public static Complex[] fft(Complex[] x) {
        int N = x.length;

        // base case
        if (N == 1) return new Complex[] { x[0] };

        // radix 2 Cooley-Tukey FFT
        if (N % 2 != 0) { throw new RuntimeException("N is not a power of 2"); }

        // fft of even terms
        Complex[] even = new Complex[N/2];
        for (int k = 0; k &lt; N/2; k++) {
            even[k] = x[2*k];
        }
        Complex[] q = fft(even);

        // fft of odd terms
        Complex[] odd  = even;  // reuse the array
        for (int k = 0; k &lt; N/2; k++) {
            odd[k] = x[2*k + 1];
        }
        Complex[] r = fft(odd);

        // combine
        Complex[] y = new Complex[N];
        for (int k = 0; k &lt; N/2; k++) {
            double kth = -2 * k * Math.PI / N;
            Complex wk = new Complex(Math.cos(kth), Math.sin(kth));
            y[k]       = q[k].plus(wk.times(r[k]));
            y[k + N/2] = q[k].minus(wk.times(r[k]));
        }
        return y;
    }
</code></pre>
