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