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