Exemplo n.º 1
0
void accuracy_test(dofft_closure *k, aconstrain constrain,
		   int sign, int n, C *a, C *b, int rounds, int impulse_rounds,
		   double t[6])
{
     int r, i;
     int ntests = 0;
     bench_complex czero = {0, 0};

     for (i = 0; i < 6; ++i) t[i] = 0.0;

     for (r = 0; r < rounds; ++r) {
	  arand(a, n);
	  if (one_accuracy_test(k, constrain, sign, n, a, b, t))
	       ++ntests;
     }

     /* impulses at beginning of array */
     for (r = 0; r < impulse_rounds; ++r) {
	  if (r > n - r - 1)
	       continue;
	  
	  caset(a, n, czero);
	  c_re(a[r]) = c_im(a[r]) = 1.0;
	  
	  if (one_accuracy_test(k, constrain, sign, n, a, b, t))
	       ++ntests;
     }
     
     /* impulses at end of array */
     for (r = 0; r < impulse_rounds; ++r) {
	  if (r <= n - r - 1)
	       continue;
	  
	  caset(a, n, czero);
	  c_re(a[n - r - 1]) = c_im(a[n - r - 1]) = 1.0;
	  
	  if (one_accuracy_test(k, constrain, sign, n, a, b, t))
	       ++ntests;
     }
     
     /* randomly-located impulses */
     for (r = 0; r < impulse_rounds; ++r) {
	  caset(a, n, czero);
	  i = rand() % n;
	  c_re(a[i]) = c_im(a[i]) = 1.0;
	  
	  if (one_accuracy_test(k, constrain, sign, n, a, b, t))
	       ++ntests;
     }

     t[0] /= ntests;
     t[1] = sqrt(t[1] / ntests);
     t[3] /= ntests;
     t[4] = sqrt(t[4] / ntests);

     fftaccuracy_done();
}
Exemplo n.º 2
0
/* set I/O arrays to zero.  Default routine */
void problem_zero(bench_problem *p)
{
     bench_complex czero = {0, 0};
     if (p->kind == PROBLEM_COMPLEX) {
	  caset((bench_complex *) p->inphys, p->iphyssz, czero);
	  caset((bench_complex *) p->outphys, p->ophyssz, czero);
     } else if (p->kind == PROBLEM_R2R) {
	  aset((bench_real *) p->inphys, p->iphyssz, 0.0);
	  aset((bench_real *) p->outphys, p->ophyssz, 0.0);
     } else if (p->kind == PROBLEM_REAL && p->sign < 0) {
	  aset((bench_real *) p->inphys, p->iphyssz, 0.0);
	  caset((bench_complex *) p->outphys, p->ophyssz, czero);
     } else if (p->kind == PROBLEM_REAL && p->sign > 0) {
	  caset((bench_complex *) p->inphys, p->iphyssz, czero);
	  aset((bench_real *) p->outphys, p->ophyssz, 0.0);
     } else {
	  BENCH_ASSERT(0); /* TODO */
     }
}