indutny / fft.js

The fastest JS Radix-4/Radix-2 FFT implementation
278 stars 31 forks source link

Real Number FFT #10

Closed harrisosserman closed 5 years ago

harrisosserman commented 5 years ago

My input data has all real numbers and I am trying to do a realTransform on the input. The docs have an inconsistency, and I'm not sure which part of the output array to look at to get the real value output.

  1. In the Usage section, the docs say "realTransform fills just the left half of the out"
  2. In the realTransform section, the docs say "perform FFT transformation on it, filling the left half of the output with complex values "

If I only want to look at the real (non-imaginary) output values, do I look at the left half or the right half of the output array?

Thank you!

indutny commented 5 years ago

Hello!

This is a great question, and I'm sorry for confusion. The output is always an array of complex numbers. For the realTransform, only left half of it will be filled and each complex number in that half would have zero imaginary part.

Does this explanation make more sense?

Thanks again!

harrisosserman commented 5 years ago

@indutny that makes a lot of sense! I'll look at only the left half of the output array and treat those as the real part of the Fourier Transform output.

Really appreciate your quick response :)

indutny commented 5 years ago

You're very welcome!

If you feel like the description of this method in the README could be improved, please do not hesitate to open a PR :wink:

harrisosserman commented 5 years ago

@indutny my pleasure: https://github.com/indutny/fft.js/pull/11