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