The input values to this routine are ar(.), the real part of the DFT, and ai(.), the imaginary part of the DFT. For N even, the values are stored as follows.
ar(0) <-> X[0]
ar(1) <-> X[1]
... ...
ar(N/2-1) <-> X[N/2-1]
ar(N/2) <-> X[N/2]
ai(1) <-> X[N/2+1]
ai(2) <-> X[N/2+2]
... ...
ai(N/2-1) <-> X[N-1]
The values ai(0) and ai(N/2) are known, a priori, to be zero. The output of
this routine is a vector of N/2+1 values calculated as follows.
X2[k] = ar(k)^2 + ai(k)^2 0 <= k <= N/2.
This routine also works for N odd, in which case there are (N+1)/2 output values.