annotate fft/fftw/fftw-3.3.4/libbench2/verify.c @ 40:223f770b5341 kissfft-double tip

Try a double-precision kissfft
author Chris Cannam
date Wed, 07 Sep 2016 10:40:32 +0100
parents 26056e866c29
children
rev   line source
Chris@19 1 /*
Chris@19 2 * Copyright (c) 2000 Matteo Frigo
Chris@19 3 * Copyright (c) 2000 Massachusetts Institute of Technology
Chris@19 4 *
Chris@19 5 * This program is free software; you can redistribute it and/or modify
Chris@19 6 * it under the terms of the GNU General Public License as published by
Chris@19 7 * the Free Software Foundation; either version 2 of the License, or
Chris@19 8 * (at your option) any later version.
Chris@19 9 *
Chris@19 10 * This program is distributed in the hope that it will be useful,
Chris@19 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@19 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@19 13 * GNU General Public License for more details.
Chris@19 14 *
Chris@19 15 * You should have received a copy of the GNU General Public License
Chris@19 16 * along with this program; if not, write to the Free Software
Chris@19 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Chris@19 18 *
Chris@19 19 */
Chris@19 20
Chris@19 21
Chris@19 22 #include <stdio.h>
Chris@19 23 #include <stdlib.h>
Chris@19 24
Chris@19 25 #include "verify.h"
Chris@19 26
Chris@19 27 void verify_problem(bench_problem *p, int rounds, double tol)
Chris@19 28 {
Chris@19 29 errors e;
Chris@19 30 const char *pstring = p->pstring ? p->pstring : "<unknown problem>";
Chris@19 31
Chris@19 32 switch (p->kind) {
Chris@19 33 case PROBLEM_COMPLEX: verify_dft(p, rounds, tol, &e); break;
Chris@19 34 case PROBLEM_REAL: verify_rdft2(p, rounds, tol, &e); break;
Chris@19 35 case PROBLEM_R2R: verify_r2r(p, rounds, tol, &e); break;
Chris@19 36 }
Chris@19 37
Chris@19 38 if (verbose)
Chris@19 39 ovtpvt("%s %g %g %g\n", pstring, e.l, e.i, e.s);
Chris@19 40 }
Chris@19 41
Chris@19 42 void verify(const char *param, int rounds, double tol)
Chris@19 43 {
Chris@19 44 bench_problem *p;
Chris@19 45
Chris@19 46 p = problem_parse(param);
Chris@19 47 problem_alloc(p);
Chris@19 48
Chris@19 49 if (!can_do(p)) {
Chris@19 50 ovtpvt_err("No can_do for %s\n", p->pstring);
Chris@19 51 BENCH_ASSERT(0);
Chris@19 52 }
Chris@19 53
Chris@19 54 problem_zero(p);
Chris@19 55 setup(p);
Chris@19 56
Chris@19 57 verify_problem(p, rounds, tol);
Chris@19 58
Chris@19 59 done(p);
Chris@19 60 problem_destroy(p);
Chris@19 61 }
Chris@19 62
Chris@19 63
Chris@19 64 static void do_accuracy(bench_problem *p, int rounds, int impulse_rounds)
Chris@19 65 {
Chris@19 66 double t[6];
Chris@19 67
Chris@19 68 switch (p->kind) {
Chris@19 69 case PROBLEM_COMPLEX:
Chris@19 70 accuracy_dft(p, rounds, impulse_rounds, t); break;
Chris@19 71 case PROBLEM_REAL:
Chris@19 72 accuracy_rdft2(p, rounds, impulse_rounds, t); break;
Chris@19 73 case PROBLEM_R2R:
Chris@19 74 accuracy_r2r(p, rounds, impulse_rounds, t); break;
Chris@19 75 }
Chris@19 76
Chris@19 77 /* t[0] : L1 error
Chris@19 78 t[1] : L2 error
Chris@19 79 t[2] : Linf error
Chris@19 80 t[3..5]: L1, L2, Linf backward error */
Chris@19 81 ovtpvt("%6.2e %6.2e %6.2e %6.2e %6.2e %6.2e\n",
Chris@19 82 t[0], t[1], t[2], t[3], t[4], t[5]);
Chris@19 83 }
Chris@19 84
Chris@19 85 void accuracy(const char *param, int rounds, int impulse_rounds)
Chris@19 86 {
Chris@19 87 bench_problem *p;
Chris@19 88 p = problem_parse(param);
Chris@19 89 BENCH_ASSERT(can_do(p));
Chris@19 90 problem_alloc(p);
Chris@19 91 problem_zero(p);
Chris@19 92 setup(p);
Chris@19 93 do_accuracy(p, rounds, impulse_rounds);
Chris@19 94 done(p);
Chris@19 95 problem_destroy(p);
Chris@19 96 }