import algo3/fft

int def test_fft():
    int n = 32
    complex x[n], y[n], z[n]
    for int i = 0; i < n; i++:
        x[i] = sin(4.5 * 2 * pi * i / n) * i
    fft(n, x, y)
    for int i = 0; i < n; i++:
        printf("% 7.5f % 7.5f\n", creal(y[i]), cimag(y[i]))
    ifft(n, y, z)
    double e = 0.000001
    for int i = 0; i < n; i++:
        double d = x[i] - z[i]
        if d < -e or d >e:
            printf(" differ: % 7.5f % 7.5f and % 7.5f % 7.5f\n",
                creal(x[i]), cimag(x[i]), creal(z[i]), cimag(z[i]))
    return 0