2
* Copyright (c) 2003 Matteo Frigo
3
* Copyright (c) 2003 Massachusetts Institute of Technology
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
/* $Id: hc2hc-dit.c,v 1.16 2003/03/15 20:29:43 stevenj Exp $ */
23
/* decimation in time Cooley-Tukey */
27
static void apply(const plan *ego_, R *I, R *O)
29
const plan_hc2hc *ego = (const plan_hc2hc *) ego_;
31
/* two-dimensional r x vl sub-transform: */
33
plan_rdft *cld = (plan_rdft *) ego->cld;
34
cld->apply((plan *) cld, I, O);
38
plan_rdft *cld0 = (plan_rdft *) ego->cld0;
39
plan_rdft *cldm = (plan_rdft *) ego->cldm;
40
int i, r = ego->r, m = ego->m, vl = ego->vl;
41
int os = ego->os, ovs = ego->ovs;
43
for (i = 0; i < vl; ++i, O += ovs) {
44
cld0->apply((plan *) cld0, O, O);
45
ego->k(O + os, O + (r * m - 1) * os, ego->W, ego->ios, m, os);
46
cldm->apply((plan *) cldm, O + os*(m/2), O + os*(m/2));
51
static int applicable0(const solver_hc2hc *ego, const problem *p_,
55
if (X(rdft_hc2hc_applicable)(ego, p_)) {
58
const hc2hc_desc *e = ego->desc;
59
const problem_rdft *p = (const problem_rdft *) p_;
60
iodim *d = p->sz->dims;
61
int m = d[0].n / e->radix;
62
X(tensor_tornk1)(p->vecsz, &vl, &ivs, &ovs);
64
&& (e->genus->okp(e, p->O + d[0].os,
65
p->O + (e->radix * m - 1) * d[0].os,
66
(int)m * d[0].os, 0, m, d[0].os))
67
&& (e->genus->okp(e, p->O + ovs + d[0].os,
68
p->O + ovs + (e->radix * m - 1) * d[0].os,
69
(int)m * d[0].os, 0, m, d[0].os))
75
static int applicable(const solver_hc2hc *ego, const problem *p_,
78
const problem_rdft *p;
80
if (!applicable0(ego, p_, plnr)) return 0;
82
p = (const problem_rdft *) p_;
84
/* emulate fftw2 behavior */
85
if (NO_VRECURSEP(plnr) && (p->vecsz->rnk > 0)) return 0;
88
if (X(ct_uglyp)(16, p->sz->dims[0].n, ego->desc->radix)) return 0;
89
if (NONTHREADED_ICKYP(plnr))
90
return 0; /* prefer threaded version */
96
static void finish(plan_hc2hc *ego)
98
const hc2hc_desc *d = ego->slv->desc;
101
ego->ios = X(mkstride)(ego->r, ego->m * ego->os);
103
X(ops_add)(&ego->cld0->ops, &ego->cldm->ops, &t);
104
X(ops_madd)(ego->vl, &t, &ego->cld->ops, &ego->super.super.ops);
105
X(ops_madd2)(ego->vl * ((ego->m - 1)/2) / d->genus->vl, &d->ops,
106
&ego->super.super.ops);
110
static plan *mkplan(const solver *ego, const problem *p, planner *plnr)
112
static const hc2hcadt adt = {
114
X(rdft_mkcldrn_dit), finish, applicable, apply
116
return X(mkplan_rdft_hc2hc)((const solver_hc2hc *) ego, p, plnr, &adt);
120
solver *X(mksolver_rdft_hc2hc_dit)(khc2hc codelet, const hc2hc_desc *desc)
122
static const solver_adt sadt = { mkplan };
123
static const char name[] = "rdft-dit";
125
return X(mksolver_rdft_hc2hc)(codelet, desc, name, &sadt);