import config
import wavelets/cdf_9x7

int def test_cdf97():
    int n = 512
    V signal[n]
    #V a = RAND_MAX
    for int i = 0; i < n; i++:
        #signal[i] = (rand() - a / 2) / (a / 2)
        #signal[i] = cos(2 * pi * i * 4 / (n - 1.0)) + cos(2 * pi * i * 16 / (n - 1.0))
        signal[i] = i == 128 ? 1 : 0
        #signal[i] = sin(2 * pi * i / 511.0)

    V low1[n]
    V high1[n]
    cdf_9x7_filter_nosubsample(signal, n, 1, low1, 1, high1, 1, 0)

    V low2[n]
    V high2[n]
    cdf_9x7_filter_nosubsample_param(signal, n, 1, low2, 1, high2, 1, 0, 0.5)

    int ok = 0
    for int i = 0; i < n / 2; i++:
        if fabs(low1[i * 2] - low2[i]) > 0.01:
            printf("low %d: %f %f\n", i, low1[i * 2], low2[i])
            ok = 1
        if fabs(high1[i * 2] - high2[i]) > 0.01:
            printf("high %d: %f %f\n", i, high1[i * 2], high2[i])
            ok = 1

    return ok