half_real_fft
template<class G1,class G2> inline void half_real_fft(const Vector<G1> &X, Vector<G2> &Y)
template<class G1,class G2> inline void half_real_fft(const Matrix<G1> &X, Matrix<G2> &Y)
FFT of a real signal
Parameters
X | A real signal |
Y | The half complex FFT |
Remarks
The FFT of a signal with N real values is complex and has the following symmetry property:
Y[N-i] = conj(Y[i])
For some speed consideration, only the first half part of Y is filled with correct values. Y should have at least N/2+1 complex elements. Nevertheless Y should best have N elements, Y is then used as internal memory buffer resulting in overwritten values in the second half part and a somewhat quicker execution speed.
In case of a 2D signal with MxN real values, only the left part of the Y matrix is filled with correct values. Y should usualy have Mx(N/2+1) complex elements. Nevertheless for an optimal execution on single precision signals with SSE instructions, every line of Y has to be aligned in memory, that is Y should have Mx2*((N/2)/2+1) complex elements
If needed, the second half part of Y can be reconstructed by the use of its symmetry property, but the optimized fft function that entirely fills Y should be preferred.
Example
DenseVector<float>::self X(4, 1); DenseVector<complex<float> >::self Y(X.size()); half_real_fft(X,Y); DenseMatrix<float>::self X(4,4, 1); DenseMatrix<complex<float> >::self Y(X.nrows(),2*((X.ncols()/2)/2+1); half_real_fft(X,Y);