goertzel.c
// Similar to goertzel() but with phase correction factor
Similar to goertzel() but with phase correction factor
Similar to goertzel () but with phase correction factor
double_complex goertzelGen(double *x, int N, double k) {
    double w;
    double sinW, cosW, twoCosW;
    double s0, s1, s2;
    double_complex phaseFactor;
    w = (2.0 * M_PI * k) / N;
    sinW = sin(w);
    cosW = cos(w);
    twoCosW = 2.0 * cosW;
    phaseFactor = exp(double_complex(0, -w * N)); 
    s0 = 0.0;
    s1 = 0.0;
    s2 = 0.0;
    for (int n = 0; n < N; n++) {
        s0 = x[n] + (twoCosW * s1) - s2;
        s2 = s1;
        s1 = s0;
    }
    return double_complex(cosW * s1 - s2, sinW * s1) * phaseFactor;
}
double_complex goertzelGen ( double * x , int N , double k ) { double w ; double sinW , cosW , twoCosW ; double s0 , s1 , s2 ; double_complex phaseFactor ; w = ( 2.0 * M_PI * k ) / N ; sinW = sin ( w ) ; cosW = cos ( w ) ; twoCosW = 2.0 * cosW ; phaseFactor = exp ( double_complex ( 0 , - w * N ) ) ; s0 = 0.0 ; s1 = 0.0 ; s2 = 0.0 ; for ( int n = 0 ; n < N ; n ++ ) { s0 = x [ n ] + ( twoCosW * s1 ) - s2 ; s2 = s1 ; s1 = s0 ; } return double_complex ( cosW * s1 - s2 , sinW * s1 ) * phaseFactor ; }
Similar to goertzel() but with phase correction factor
Similar to goertzel () but with phase correction factor
// e^(-j*2*pi*k)