Exemple #1
0
double tf_shift(dofft_closure *k,
		int realp, const bench_tensor *sz,
		int n, int vecn, double sign,
		C *inA, C *inB, C *outA, C *outB, C *tmp,
		int rounds, double tol, int which_shift)
{
     int nb, na, dim, N = n * vecn;
     int i, j;
     double e = 0.0;

     /* test 3: check the time-shift property */
     /* the paper performs more tests, but this code should be fine too */

     nb = 1;
     na = n;

     /* check shifts across all SZ dimensions */
     for (dim = 0; dim < sz->rnk; ++dim) {
	  int ncur = sz->dims[dim].n;

	  na /= ncur;

	  for (j = 0; j < rounds; ++j) {
	       arand(inA, N);

	       if (which_shift == TIME_SHIFT) {
		    for (i = 0; i < vecn; ++i) {
			 if (realp) mkreal(inA + i * n, n);
			 arol(inB + i * n, inA + i * n, ncur, nb, na);
		    }
		    k->apply(k, inA, outA);
		    k->apply(k, inB, outB);
		    for (i = 0; i < vecn; ++i) 
			 aphase_shift(tmp + i * n, outB + i * n, ncur, 
				      nb, na, sign);
		    e = dmax(e, acmp(tmp, outA, N, "time shift", tol));
	       } else {
		    for (i = 0; i < vecn; ++i) {
			 if (realp) 
			      mkhermitian(inA + i * n, sz->rnk, sz->dims, 1);
			 aphase_shift(inB + i * n, inA + i * n, ncur,
				      nb, na, -sign);
		    }
		    k->apply(k, inA, outA);
		    k->apply(k, inB, outB);
		    for (i = 0; i < vecn; ++i) 
			 arol(tmp + i * n, outB + i * n, ncur, nb, na);
		    e = dmax(e, acmp(tmp, outA, N, "freq shift", tol));
	       }
	  }

	  nb *= ncur;
     }
     return e;
}
Exemple #2
0
static double verify_shift(fftd_func *dft,
			 int N, 
			 COMPLEX *inA,
			 COMPLEX *inB,
			 COMPLEX *outA,
			 COMPLEX *outB,
			 COMPLEX *tmp,
			 int rounds)
{
    const double twopin = 2 * M_PI / (double) N;
    int i, j;
    double e, maxerr = 0.0;

    /* test 3: check the time-shift property */
    /* the paper performs more tests, but this code should be fine too */

    for (i = 0; i < rounds; ++i) {
	  
	fill_random(inA, N);
	arol(inB, inA, N, 1);

	dft((double *)outA, (double *)inA);
	dft((double *)outB, (double *)inB);

	for (j = 0; j < N; ++j) {
	    double s = SIGN * sin(j * twopin);
	    double c = cos(j * twopin);
	    int index = j;
	    RE(tmp[index]) = RE(outB[index]) * c - IM(outB[index]) * s;
	    IM(tmp[index]) = RE(outB[index]) * s + IM(outB[index]) * c;
	}
	e = acmp(tmp, outA, N);
	if(e > maxerr) maxerr = e;
    }
    return maxerr;
}