import config

class Filter:
    int hn, gn
    V *h, *g

def filter(V const *indata, int n, instep, V *fdata, int fn,
    V *outdata, int outstep, stride):
    """
    Convolve the given data of length n with the given filter of length fn.
    This is a slow brute force implementation.
    """

    V *ylow = outdata

    # Apply filter with brute force (no FFT)
    V const *y = indata
    for int i = 0; i < n; i++:
        V const *y2 = y
        V x = 0
        for int j = 0; j < fn; j++:
            x += *y2 * fdata[j]
            y2 -= instep * stride
            if y2 < indata: y2 += n * instep
        *ylow = x
        y += instep
        ylow += outstep  