Пример #1
0
	/**
	 * C++ version of gsl_fft_real_float_radix2_transform().
	 * @param data An array of float values.
	 * @param n The size of the array.
	 * @return Error code on failure.
	 */
	inline int transform( float data[], size_t const n ){
	  return gsl_fft_real_float_radix2_transform( data, 1, n ); }
Пример #2
0
            /* Produce a vector of chisquared values as a function of frequency */
void    fastChi(const double *sampletimes, const float *vals, const float *stderrs, 
                long ndata, long nharmonics, double deltat, 
                long nrealpoints, long nchivalues, double tstart,
                float *dovstorage, float *oovstorage,
                float *chireductionlist)
{
    int d;
    int i;
    int h;
    float invdeltat = 1/deltat;

    gsl_matrix *alpha = gsl_matrix_alloc(2 * nharmonics + 1,2 * nharmonics + 1);
    gsl_vector *beta =  gsl_vector_alloc(2 * nharmonics + 1);
    gsl_vector *x    =  gsl_vector_alloc(2 * nharmonics + 1);

    float *cosdata = malloc((nharmonics + 1) * sizeof(float));
    float *sindata = malloc((nharmonics + 1) * sizeof(float));
    float *cosvar = malloc((2*nharmonics + 1) * sizeof(float));
    float *sinvar = malloc((2*nharmonics + 1) * sizeof(float));

        /* if the pointers point somewhere, assume that they point to the right place */
    assert(sampletimes && vals && stderrs && dovstorage && oovstorage && chireductionlist);
    assert(nchivalues * 2 * nharmonics <= nrealpoints); /* FIXME: change 2 to 1 when */
                                                        /* using aliasing */
    assert(cosdata && sindata && cosvar && sinvar);
    
    memset(dovstorage, 0, nrealpoints * sizeof(float));
    memset(oovstorage, 0, nrealpoints * sizeof(float));
    
    for (d = 0 ; d < ndata ; d++)
    {
        long tindex = (sampletimes[d] - tstart) * invdeltat;
        float inv_variance = 1/(stderrs[d] * stderrs[d]); 
        assert(tindex >= 0 && tindex < nrealpoints);
                /* adding rather than setting averages measurments that */
                /* fall in same timebin.  It does, however, reduce the d.o.f. */
                /* and subsequently improperly reduces the chisquared.  */
                /* This is a minor point. */
            /* dov: _d_ata _o_ver _v_ariance  oov: _o_ne  _o_ver _v_ariance */
        dovstorage[tindex] += vals[d] * inv_variance;
        oovstorage[tindex] += inv_variance;
    }
    gsl_fft_real_float_radix2_transform(dovstorage, 1, nrealpoints);
    gsl_fft_real_float_radix2_transform(oovstorage, 1, nrealpoints);

    cosdata[0] = dovstorage[0];     /* The constant (0f) terms are the same for all f */
    cosvar[0] = oovstorage[0];

    for (i = 1 ; i < nchivalues ; i++)
    {
        for (h = 1 ; h <= nharmonics ; h++)
        {
            cosdata[h] = dovstorage[i*h];
            sindata[h] = dovstorage[nrealpoints - (i * h)] * FFTSIGNCONVENTION;
        }
        for (h = 1 ; h <= 2*nharmonics ; h++)
        {                               /* put alias wrapping in here */
            cosvar[h] = oovstorage[i*h];
            sinvar[h] = oovstorage[nrealpoints - (i * h)] * FFTSIGNCONVENTION;
        }
        chireductionlist[i] 
                = calcChiReduction(nharmonics,
                                cosdata, sindata, cosvar, sinvar,
                                alpha, beta, x);
    }

        
    gsl_matrix_free(alpha);
    gsl_vector_free(beta);
    gsl_vector_free(x);

    free(cosdata);
    free(sindata);
    free(cosvar);
    free(sinvar);

}
Пример #3
0
	inline int transform( DATA& data, size_t const stride = 1 ){
	  return gsl_fft_real_float_radix2_transform( data.data(), stride, data.size() / stride ); }