Function dft

  • Calculates the Discrete Fourier Transform (DFT) of a sequence.

    Parameters

    • sequence: number[]

      The input sequence for which to calculate the DFT.

    Returns ComplexNumber[]

    An array of complex numbers representing the DFT coefficients.

    Remark

    This is only defined for sequences of numbers at the moment

    Example

    const sequence = [1, 2, 3, 2, 1];
    const result = dft(sequence);
    console.log(result);
    // Output:
    [
    { real: 9, imaginary: 0 },
    { real: -2.118033988749895, imaginary: -1.538841768587627 },
    { real: 0.11803398874989479, imaginary: 0.36327126400268017 },
    { real: 0.11803398874989524, imaginary: -0.3632712640026805 },
    { real: -2.118033988749895, imaginary: 1.5388417685876252 }
    ]

Generated using TypeDoc