03-25-2023 02:43 AM
Does anyone know how can we obtain FFT Twiddle Factors in LabVIEW?
03-25-2023 07:58 AM
03-25-2023 10:27 AM
A Web search for FFT Twiddle Factors will show you that your question makes little sense. The FFT, particularly the Radix-2 FFT known to some as the Cooley-Tukey Algorithm (Jim Cooley, whom I met in my student years, gave me a copy of the IBM Research paper I used to code this algorithm in Fortran using punch cards), exploits interesting symmetries when the number of points being transformed is composed of relatively few prime factors (so the Radix-2 FFT, where the number of points is a power of 2, is the simplest and probably the most common implementation).
Fortunately for LabVIEW users, we no longer need to write LabVIEW code to do FFTs (NI has done it for us). You can ask "Are the Twiddle Factors that LabVIEW is using in its implementation correctly computed?", and you can do a test by generating a Waveform whose harmonic composition you know, taking its FFT, and seeing if LabVIEW gives you back your starting harmonic composition (for fastest and most accurate results, use an N that is a power of 2).
Bob Schor
03-25-2023 11:38 AM - edited 03-25-2023 11:54 AM
Twiddle factors are a concept of some FFT algorithms, nothing specific to LabVIEW. They depend on the specific algorithm and the data size, so your question is very fuzzy to begin with.
LabVIEW uses highly optimized libraries that work well for all sizes. You need to treat it as a black box and trust it! (see also my comments here). There is a good chance that they use the Intel MKL, but have not investigated that in detail.
You are welcome to write your own FFT from basic primitives, including twiddle factors, and see how close you get with the stock algorithms. It's all just math, right? I doubt you'll get even close. 😄
A very poor "literal" implementation of FFT can be found here, so start with that. 😄 To speed it up once you know the size and it does not change, you can pre-calculate the lower part of the code and cache it, for example.
03-25-2023 12:19 PM
03-25-2023 06:14 PM - edited 03-25-2023 06:17 PM
@altenbach wrote:
LabVIEW uses highly optimized libraries that work well for all sizes. You need to treat it as a black box and trust it! (see also my comments here). There is a good chance that they use the Intel MKL, but have not investigated that in detail.
This is a very good assumption. Almost all LabVIEW Advanced Analysis library functions are since about LabVIEW 7.1 using the Intel MKL under the hood. Before that, NI used to have its own AAL library written in C code, but they decided that there was no way they could compete with the expertise of Intel engineers in the long run to optimize the library for all possible CPU families.
03-25-2023 09:40 PM
@altenbach wrote:
Google Bard AI has a good explanation:
Sigh. Google's "Bard", of course, is wrong! For an order N FFT, the Twiddle factors are basically mulltiples of the N-th roots of 1, so the extra "division by N" in the exponent above should be erased. I went looking for my (more-than-two-decade-old?) Fortran routine, but couldn't find it. Oh, well, this algorithm is too well-known (and easily checked) that I, for one, take NI on faith that they "did it right" (and certainly optimized it far better than I would be able to do by trying to write LabVIEW code to do it).
Bob Schor
03-26-2023 12:14 PM
@linu95k wrote:
Does anyone know how can we obtain FFT Twiddle Factors in LabVIEW?
So re-reading the question, ...