Mercurial > hg > octave-lyh
annotate liboctave/oct-fftw.h @ 9516:fb933db0c517
convert fftw planner classes to singleton objects
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 11 Aug 2009 23:52:20 -0400 |
parents | eb63fbe60fab |
children | 0ce82753dd72 |
rev | line source |
---|---|
3828 | 1 /* |
2 | |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
3 Copyright (C) 2001, 2004, 2005, 2007, 2008, 2009 John W. Eaton |
7017 | 4 |
3828 | 5 This file is part of Octave. |
6 | |
7 Octave is free software; you can redistribute it and/or modify it | |
8 under the terms of the GNU General Public License as published by the | |
7016 | 9 Free Software Foundation; either version 3 of the License, or (at your |
10 option) any later version. | |
3828 | 11 |
12 Octave is distributed in the hope that it will be useful, but WITHOUT | |
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
15 for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
7016 | 18 along with Octave; see the file COPYING. If not, see |
19 <http://www.gnu.org/licenses/>. | |
3828 | 20 |
21 */ | |
22 | |
23 #if !defined (octave_oct_fftw_h) | |
24 #define octave_oct_fftw_h 1 | |
25 | |
26 #include <cstddef> | |
4773 | 27 #include <fftw3.h> |
3828 | 28 |
29 #include "oct-cmplx.h" | |
4773 | 30 #include "dim-vector.h" |
3828 | 31 |
32 class | |
6256 | 33 OCTAVE_API |
6228 | 34 octave_fftw_planner |
35 { | |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
36 protected: |
6228 | 37 |
38 octave_fftw_planner (void); | |
39 | |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
40 public: |
6228 | 41 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
42 ~octave_fftw_planner (void) { } |
6228 | 43 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
44 enum FftwMethod |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
45 { |
6228 | 46 UNKNOWN = -1, |
47 ESTIMATE, | |
48 MEASURE, | |
49 PATIENT, | |
50 EXHAUSTIVE, | |
51 HYBRID | |
52 }; | |
53 | |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
54 static bool instance_ok (void); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
55 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
56 static fftw_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
57 create_plan (int dir, const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
58 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
59 octave_idx_type dist, const Complex *in, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
60 Complex *out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
61 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
62 static fftw_plan dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
63 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
64 return instance_ok () |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
65 ? instance->do_create_plan (dir, rank, dims, howmany, stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
66 dist, in, out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
67 : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
68 } |
6228 | 69 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
70 static fftw_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
71 create_plan (const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
72 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
73 octave_idx_type dist, const double *in, Complex *out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
74 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
75 static fftw_plan dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
76 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
77 return instance_ok () |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
78 ? instance->do_create_plan (rank, dims, howmany, stride, dist, in, out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
79 : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
80 } |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
81 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
82 static FftwMethod method (void) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
83 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
84 static FftwMethod dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
85 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
86 return instance_ok () ? instance->do_method () : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
87 } |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
88 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
89 static FftwMethod method (FftwMethod _meth) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
90 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
91 static FftwMethod dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
92 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
93 return instance_ok () ? instance->do_method (_meth) : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
94 } |
6228 | 95 |
96 private: | |
97 | |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
98 static octave_fftw_planner *instance; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
99 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
100 fftw_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
101 do_create_plan (int dir, const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
102 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
103 octave_idx_type dist, const Complex *in, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
104 Complex *out); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
105 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
106 fftw_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
107 do_create_plan (const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
108 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
109 octave_idx_type dist, const double *in, Complex *out); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
110 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
111 FftwMethod do_method (void); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
112 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
113 FftwMethod do_method (FftwMethod _meth); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
114 |
6228 | 115 FftwMethod meth; |
116 | |
117 // FIXME -- perhaps this should be split into two classes? | |
118 | |
119 // Plan for fft and ifft of complex values | |
120 fftw_plan plan[2]; | |
121 | |
122 // dist | |
123 octave_idx_type d[2]; | |
124 | |
125 // stride | |
126 octave_idx_type s[2]; | |
127 | |
128 // rank | |
129 int r[2]; | |
130 | |
131 // howmany | |
132 octave_idx_type h[2]; | |
133 | |
134 // dims | |
135 dim_vector n[2]; | |
136 | |
137 bool simd_align[2]; | |
138 bool inplace[2]; | |
139 | |
140 // Plan for fft of real values | |
141 fftw_plan rplan; | |
142 | |
143 // dist | |
144 octave_idx_type rd; | |
145 | |
146 // stride | |
147 octave_idx_type rs; | |
148 | |
149 // rank | |
150 int rr; | |
151 | |
152 // howmany | |
153 octave_idx_type rh; | |
154 | |
155 // dims | |
156 dim_vector rn; | |
157 | |
158 bool rsimd_align; | |
159 }; | |
160 | |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
161 class |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
162 OCTAVE_API |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
163 octave_float_fftw_planner |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
164 { |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
165 protected: |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
166 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
167 octave_float_fftw_planner (void); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
168 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
169 public: |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
170 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
171 ~octave_float_fftw_planner (void) { } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
172 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
173 enum FftwMethod |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
174 { |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
175 UNKNOWN = -1, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
176 ESTIMATE, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
177 MEASURE, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
178 PATIENT, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
179 EXHAUSTIVE, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
180 HYBRID |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
181 }; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
182 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
183 static bool instance_ok (void); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
184 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
185 static fftwf_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
186 create_plan (int dir, const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
187 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
188 octave_idx_type dist, const FloatComplex *in, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
189 FloatComplex *out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
190 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
191 static fftwf_plan dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
192 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
193 return instance_ok () |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
194 ? instance->do_create_plan (dir, rank, dims, howmany, stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
195 dist, in, out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
196 : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
197 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
198 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
199 static fftwf_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
200 create_plan (const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
201 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
202 octave_idx_type dist, const float *in, FloatComplex *out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
203 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
204 static fftwf_plan dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
205 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
206 return instance_ok () |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
207 ? instance->do_create_plan (rank, dims, howmany, stride, dist, in, out) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
208 : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
209 } |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
210 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
211 static FftwMethod method (void) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
212 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
213 static FftwMethod dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
214 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
215 return instance_ok () ? instance->method () : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
216 } |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
217 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
218 static FftwMethod method (FftwMethod _meth) |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
219 { |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
220 static FftwMethod dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
221 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
222 return instance_ok () ? instance->method (_meth) : dummy; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
223 } |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
224 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
225 private: |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
226 |
9516
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
227 static octave_float_fftw_planner *instance; |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
228 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
229 fftwf_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
230 do_create_plan (int dir, const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
231 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
232 octave_idx_type dist, const FloatComplex *in, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
233 FloatComplex *out); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
234 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
235 fftwf_plan |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
236 do_create_plan (const int rank, const dim_vector dims, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
237 octave_idx_type howmany, octave_idx_type stride, |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
238 octave_idx_type dist, const float *in, FloatComplex *out); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
239 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
240 FftwMethod do_method (void); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
241 |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
242 FftwMethod do_method (FftwMethod _meth); |
fb933db0c517
convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents:
8920
diff
changeset
|
243 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
244 FftwMethod meth; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
245 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
246 // FIXME -- perhaps this should be split into two classes? |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
247 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
248 // Plan for fft and ifft of complex values |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
249 fftwf_plan plan[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
250 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
251 // dist |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
252 octave_idx_type d[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
253 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
254 // stride |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
255 octave_idx_type s[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
256 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
257 // rank |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
258 int r[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
259 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
260 // howmany |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
261 octave_idx_type h[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
262 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
263 // dims |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
264 dim_vector n[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
265 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
266 bool simd_align[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
267 bool inplace[2]; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
268 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
269 // Plan for fft of real values |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
270 fftwf_plan rplan; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
271 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
272 // dist |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
273 octave_idx_type rd; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
274 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
275 // stride |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
276 octave_idx_type rs; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
277 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
278 // rank |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
279 int rr; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
280 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
281 // howmany |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
282 octave_idx_type rh; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
283 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
284 // dims |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
285 dim_vector rn; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
286 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
287 bool rsimd_align; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
288 }; |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
289 |
6228 | 290 class |
6583 | 291 OCTAVE_API |
3828 | 292 octave_fftw |
293 { | |
294 public: | |
4773 | 295 static int fft (const double *in, Complex *out, size_t npts, |
5275 | 296 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
4773 | 297 static int fft (const Complex *in, Complex *out, size_t npts, |
5275 | 298 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
4773 | 299 static int ifft (const Complex *in, Complex *out, size_t npts, |
5275 | 300 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
3828 | 301 |
4773 | 302 static int fftNd (const double*, Complex*, const int, const dim_vector &); |
303 static int fftNd (const Complex*, Complex*, const int, | |
304 const dim_vector &); | |
305 static int ifftNd (const Complex*, Complex*, const int, | |
306 const dim_vector &); | |
3828 | 307 |
7789
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
308 static int fft (const float *in, FloatComplex *out, size_t npts, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
309 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
310 static int fft (const FloatComplex *in, FloatComplex *out, size_t npts, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
311 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
312 static int ifft (const FloatComplex *in, FloatComplex *out, size_t npts, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
313 size_t nsamples = 1, octave_idx_type stride = 1, octave_idx_type dist = -1); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
314 |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
315 static int fftNd (const float*, FloatComplex*, const int, const dim_vector &); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
316 static int fftNd (const FloatComplex*, FloatComplex*, const int, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
317 const dim_vector &); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
318 static int ifftNd (const FloatComplex*, FloatComplex*, const int, |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
319 const dim_vector &); |
82be108cc558
First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents:
7017
diff
changeset
|
320 |
3828 | 321 private: |
322 octave_fftw (); | |
323 octave_fftw (const octave_fftw&); | |
324 octave_fftw& operator = (const octave_fftw&); | |
325 }; | |
326 | |
327 #endif | |
328 | |
329 /* | |
330 ;;; Local Variables: *** | |
331 ;;; mode: C++ *** | |
332 ;;; End: *** | |
333 */ | |
334 |