idft
Builtin index · Signal processing
result = idft(X)
Input: X · Output: result
What it is
X is a length-N complex vector (CVec).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = idft(X) | X vector or CVecnot documented yet | result CVec | Returns a length-N CVec. Inverse of dft, same O(n²) direct implementation. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
fs = 1000
n = 0:1:63
t = n / fs
x = sin(2*pi*100*t)
X = fft(x)
xr = idft(X)
print("idft roundtrip max err: {max(abs(xr - x))}")
k100 = 100 * length(x) / fs # bin index equivalent to 100 Hz
bin100 = goertzel(x, k100)
print("goertzel magnitude at bin {k100}: {abs(bin100)}")
same = goertzel_freq(x, fs, 100) # the Hz-parameterized convenience form
print("goertzel_freq agrees: {abs(same - bin100) < 1e-9}")
half = rfft(x)
back = irfft(half, 64)
print("rfft/irfft roundtrip max err: {max(abs(back - x))}")
output
idft roundtrip max err: 1.604386e-14 goertzel magnitude at bin 6.4: 32.158025 goertzel_freq agrees: true rfft/irfft roundtrip max err: 3.330669e-16
from signal-processing