As I know if the impulse response is symmetric around sample zero phase response should be entirely zero.
The code below just set a rectangular window for vector "in"
const int N = 10;
// in = 0 , 0 , 0 , 0 , 1 , 1 , 1 , 0 , 0 , 0 , 0
std::vector< std::complex<double> > in (N);
std::vector< std::complex<double> > out (N);
std::vector< std::complex<double> > polarOut (N);
auto middleElem = in.begin() + in.size()/2;
std::fill( middleElem - 1, middleElem + 2, 1);
fftw_plan my_plan = fftw_plan_dft_1d(N, reinterpret_cast<fftw_complex*>(&in[0]),
reinterpret_cast<fftw_complex*>(&out[0]), FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(my_plan);
std::transform( out.begin(), out.end(), polarOut.begin(),
[]( auto& in ){
return std::complex<double>( std::abs(in), std::arg(in) );
} );
I getting back a sinc like result in magnitude, But I am so curious why I have values different than zero in phase :
polarOut <11 items> std::vector<std::complex<double>>
[0] (3.000000, 0.000000) std::complex<double>
[1] (2.682507, -2.855993) std::complex<double>
[2] (1.830830, 0.571199) std::complex<double>
[3] (0.715370, -2.284795) std::complex<double>
[4] (0.309721, -1.999195) std::complex<double>
[5] (0.918986, 1.427997) std::complex<double>
[6] (0.918986, -1.427997) std::complex<double>
[7] (0.309721, 1.999195) std::complex<double>
[8] (0.715370, 2.284795) std::complex<double>
[9] (1.830830, -0.571199) std::complex<double>
[10] (2.682507, 2.855993) std::complex<double>
Any explanation about the phase response of behaviour of this fft will be great.