Chris@19: /* Chris@19: * Copyright (c) 2000 Matteo Frigo Chris@19: * Copyright (c) 2000 Massachusetts Institute of Technology Chris@19: * Chris@19: * This program is free software; you can redistribute it and/or modify Chris@19: * it under the terms of the GNU General Public License as published by Chris@19: * the Free Software Foundation; either version 2 of the License, or Chris@19: * (at your option) any later version. Chris@19: * Chris@19: * This program is distributed in the hope that it will be useful, Chris@19: * but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@19: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@19: * GNU General Public License for more details. Chris@19: * Chris@19: * You should have received a copy of the GNU General Public License Chris@19: * along with this program; if not, write to the Free Software Chris@19: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Chris@19: * Chris@19: */ Chris@19: Chris@19: Chris@19: #include Chris@19: #include Chris@19: Chris@19: #include "verify.h" Chris@19: Chris@19: void verify_problem(bench_problem *p, int rounds, double tol) Chris@19: { Chris@19: errors e; Chris@19: const char *pstring = p->pstring ? p->pstring : ""; Chris@19: Chris@19: switch (p->kind) { Chris@19: case PROBLEM_COMPLEX: verify_dft(p, rounds, tol, &e); break; Chris@19: case PROBLEM_REAL: verify_rdft2(p, rounds, tol, &e); break; Chris@19: case PROBLEM_R2R: verify_r2r(p, rounds, tol, &e); break; Chris@19: } Chris@19: Chris@19: if (verbose) Chris@19: ovtpvt("%s %g %g %g\n", pstring, e.l, e.i, e.s); Chris@19: } Chris@19: Chris@19: void verify(const char *param, int rounds, double tol) Chris@19: { Chris@19: bench_problem *p; Chris@19: Chris@19: p = problem_parse(param); Chris@19: problem_alloc(p); Chris@19: Chris@19: if (!can_do(p)) { Chris@19: ovtpvt_err("No can_do for %s\n", p->pstring); Chris@19: BENCH_ASSERT(0); Chris@19: } Chris@19: Chris@19: problem_zero(p); Chris@19: setup(p); Chris@19: Chris@19: verify_problem(p, rounds, tol); Chris@19: Chris@19: done(p); Chris@19: problem_destroy(p); Chris@19: } Chris@19: Chris@19: Chris@19: static void do_accuracy(bench_problem *p, int rounds, int impulse_rounds) Chris@19: { Chris@19: double t[6]; Chris@19: Chris@19: switch (p->kind) { Chris@19: case PROBLEM_COMPLEX: Chris@19: accuracy_dft(p, rounds, impulse_rounds, t); break; Chris@19: case PROBLEM_REAL: Chris@19: accuracy_rdft2(p, rounds, impulse_rounds, t); break; Chris@19: case PROBLEM_R2R: Chris@19: accuracy_r2r(p, rounds, impulse_rounds, t); break; Chris@19: } Chris@19: Chris@19: /* t[0] : L1 error Chris@19: t[1] : L2 error Chris@19: t[2] : Linf error Chris@19: t[3..5]: L1, L2, Linf backward error */ Chris@19: ovtpvt("%6.2e %6.2e %6.2e %6.2e %6.2e %6.2e\n", Chris@19: t[0], t[1], t[2], t[3], t[4], t[5]); Chris@19: } Chris@19: Chris@19: void accuracy(const char *param, int rounds, int impulse_rounds) Chris@19: { Chris@19: bench_problem *p; Chris@19: p = problem_parse(param); Chris@19: BENCH_ASSERT(can_do(p)); Chris@19: problem_alloc(p); Chris@19: problem_zero(p); Chris@19: setup(p); Chris@19: do_accuracy(p, rounds, impulse_rounds); Chris@19: done(p); Chris@19: problem_destroy(p); Chris@19: }