comparison src/fftw-3.3.8/rdft/direct-r2r.c @ 167:bd3cc4d1df30

Add FFTW 3.3.8 source, and a Linux build
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Nov 2019 14:52:55 +0000
parents
children
comparison
equal deleted inserted replaced
166:cbd6d7e562c7 167:bd3cc4d1df30
1 /*
2 * Copyright (c) 2003, 2007-14 Matteo Frigo
3 * Copyright (c) 2003, 2007-14 Massachusetts Institute of Technology
4 *
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.
9 *
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.
14 *
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 *
19 */
20
21
22 /* direct RDFT solver, using r2r codelets */
23
24 #include "rdft/rdft.h"
25
26 typedef struct {
27 solver super;
28 const kr2r_desc *desc;
29 kr2r k;
30 } S;
31
32 typedef struct {
33 plan_rdft super;
34
35 INT vl, ivs, ovs;
36 stride is, os;
37 kr2r k;
38 const S *slv;
39 } P;
40
41 static void apply(const plan *ego_, R *I, R *O)
42 {
43 const P *ego = (const P *) ego_;
44 ASSERT_ALIGNED_DOUBLE;
45 ego->k(I, O, ego->is, ego->os, ego->vl, ego->ivs, ego->ovs);
46 }
47
48 static void destroy(plan *ego_)
49 {
50 P *ego = (P *) ego_;
51 X(stride_destroy)(ego->is);
52 X(stride_destroy)(ego->os);
53 }
54
55 static void print(const plan *ego_, printer *p)
56 {
57 const P *ego = (const P *) ego_;
58 const S *s = ego->slv;
59
60 p->print(p, "(rdft-%s-direct-r2r-%D%v \"%s\")",
61 X(rdft_kind_str)(s->desc->kind), s->desc->n,
62 ego->vl, s->desc->nam);
63 }
64
65 static int applicable(const solver *ego_, const problem *p_)
66 {
67 const S *ego = (const S *) ego_;
68 const problem_rdft *p = (const problem_rdft *) p_;
69 INT vl;
70 INT ivs, ovs;
71
72 return (
73 1
74 && p->sz->rnk == 1
75 && p->vecsz->rnk <= 1
76 && p->sz->dims[0].n == ego->desc->n
77 && p->kind[0] == ego->desc->kind
78
79 /* check strides etc */
80 && X(tensor_tornk1)(p->vecsz, &vl, &ivs, &ovs)
81
82 && (0
83 /* can operate out-of-place */
84 || p->I != p->O
85
86 /* computing one transform */
87 || vl == 1
88
89 /* can operate in-place as long as strides are the same */
90 || X(tensor_inplace_strides2)(p->sz, p->vecsz)
91 )
92 );
93 }
94
95 static plan *mkplan(const solver *ego_, const problem *p_, planner *plnr)
96 {
97 const S *ego = (const S *) ego_;
98 P *pln;
99 const problem_rdft *p;
100 iodim *d;
101
102 static const plan_adt padt = {
103 X(rdft_solve), X(null_awake), print, destroy
104 };
105
106 UNUSED(plnr);
107
108 if (!applicable(ego_, p_))
109 return (plan *)0;
110
111 p = (const problem_rdft *) p_;
112
113
114 pln = MKPLAN_RDFT(P, &padt, apply);
115
116 d = p->sz->dims;
117
118 pln->k = ego->k;
119
120 pln->is = X(mkstride)(d->n, d->is);
121 pln->os = X(mkstride)(d->n, d->os);
122
123 X(tensor_tornk1)(p->vecsz, &pln->vl, &pln->ivs, &pln->ovs);
124
125 pln->slv = ego;
126 X(ops_zero)(&pln->super.super.ops);
127 X(ops_madd2)(pln->vl / ego->desc->genus->vl,
128 &ego->desc->ops,
129 &pln->super.super.ops);
130
131 pln->super.super.could_prune_now_p = 1;
132
133 return &(pln->super.super);
134 }
135
136 /* constructor */
137 solver *X(mksolver_rdft_r2r_direct)(kr2r k, const kr2r_desc *desc)
138 {
139 static const solver_adt sadt = { PROBLEM_RDFT, mkplan, 0 };
140 S *slv = MKSOLVER(S, &sadt);
141 slv->k = k;
142 slv->desc = desc;
143 return &(slv->super);
144 }
145