File: eigen3_LukePratley.patch

package info (click to toggle)
purify 2.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 58,688 kB
  • sloc: cpp: 8,410; python: 375; makefile: 7
file content (456 lines) | stat: -rw-r--r-- 20,497 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
Author: Luke Pratley <luke.pratley.15@ucl.ac.uk>
Description: Patched version for Eigen3/unsupported/FFT, still not upstream

This patch concatenates three commit, taken from

  https://bitbucket.org/LukePratley/eigen/branch/3.2

* 87372ff: New function to interface FFTW for 2D matrices (2016-07-08)
* 37484f6: Added the ability to pass level of rigor when passing FFTW
           planning flags (2016-07-08)
* 2e4f59f: Added the ability to create a 2D FFTW plan without performing
           an FFT (2016-07-11)

diff -uNr orig/unsupported/eigen/FFT 3.2/unsupported/eigen/FFT
--- orig/unsupported/Eigen/FFT	2016-07-13 12:14:36.000000000 +0200
+++ 3.2/unsupported/Eigen/FFT	2016-07-13 12:14:36.000000000 +0200
@@ -197,13 +197,13 @@
         m_impl.fwd(dst,src,static_cast<int>(nfft));
     }
 
-    /*
+    
     inline 
-    void fwd2(Complex * dst, const Complex * src, int n0,int n1)
+    void fwd2(Complex * dst, const Complex * src, int n0,int n1, bool only_plan = false)
     {
-      m_impl.fwd2(dst,src,n0,n1);
+      m_impl.fwd2(dst,src,n0,n1, only_plan);
     }
-    */
+    
 
     template <typename _Input>
     inline
@@ -251,7 +251,47 @@
         fwd( &dst[0],&src[0],nfft );
       }
     }
- 
+
+     template<typename InputDerived, typename ComplexDerived>
+    inline
+    void fwd2( Eigen::PlainObjectBase<ComplexDerived> & dst, const Eigen::PlainObjectBase<InputDerived> & src, const int & FFTW_plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT, bool only_plan = false)
+    {
+      typedef typename ComplexDerived::Scalar dst_type;
+      typedef typename InputDerived::Scalar src_type;
+      EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ComplexDerived, InputDerived) // size at compile-time
+      EIGEN_STATIC_ASSERT((internal::is_same<dst_type, Complex>::value),
+            YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
+      EIGEN_STATIC_ASSERT(int(InputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit,
+            THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
+
+      if ( NumTraits< src_type >::IsComplex == 0 && HasFlag(HalfSpectrum) )
+        throw std::runtime_error("Not implemented yet");
+      else
+        dst.derived().resizeLike(src);
+
+      const int n0 = InputDerived::IsRowMajor ? src.rows(): src.cols();
+      const int n1 = InputDerived::IsRowMajor ? src.cols(): src.rows();
+      if ( src.innerStride() != 1 or src.outerStride() != n1 ) {
+        Matrix<src_type, Dynamic, Dynamic, Eigen::RowMajor> tmp = src;
+        fwd2( dst, tmp );
+        return;
+      }
+      //choosing new plan, and putting in dummy data for plan.
+      if (m_impl.plan_flag != FFTW_plan_flag)
+      {
+        set_plan_flag(FFTW_plan_flag); //choosing rigor flag for FFTW plans
+        if (FFTW_plan_flag != FFTW_ESTIMATE|FFTW_PRESERVE_INPUT)
+        {//dummy data for fftw planning, otherwise input/output data can be changed
+          Matrix<src_type, Dynamic, Dynamic, Eigen::RowMajor> tmp_src = src;
+          Matrix<dst_type, Dynamic, Dynamic, Eigen::RowMajor> tmp_dst = dst;
+          fwd2( tmp_dst.data(), tmp_src.data(), n0, n1, true );
+          if (only_plan)
+            return;
+        }
+      }
+      fwd2( dst.data(), src.data(), n0, n1 );
+    }
+
     template<typename InputDerived>
     inline
     fft_fwd_proxy< MatrixBase<InputDerived>, FFT<T_Scalar,T_Impl> >
@@ -344,6 +384,46 @@
       }
     }
 
+    template<typename InputDerived, typename ComplexDerived>
+    inline
+    void inv2( PlainObjectBase<ComplexDerived> & dst, const PlainObjectBase<InputDerived> & src, const int & FFTW_plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT, bool only_plan = false)
+    {
+      typedef typename ComplexDerived::Scalar dst_type;
+      typedef typename InputDerived::Scalar src_type;
+      EIGEN_STATIC_ASSERT_SAME_MATRIX_SIZE(ComplexDerived, InputDerived) // size at compile-time
+      EIGEN_STATIC_ASSERT((internal::is_same<dst_type, Complex>::value),
+            YOU_MIXED_DIFFERENT_NUMERIC_TYPES__YOU_NEED_TO_USE_THE_CAST_METHOD_OF_MATRIXBASE_TO_CAST_NUMERIC_TYPES_EXPLICITLY)
+      EIGEN_STATIC_ASSERT(int(InputDerived::Flags)&int(ComplexDerived::Flags)&DirectAccessBit,
+            THIS_METHOD_IS_ONLY_FOR_EXPRESSIONS_WITH_DIRECT_MEMORY_ACCESS_SUCH_AS_MAP_OR_PLAIN_MATRICES)
+
+      if ( NumTraits< src_type >::IsComplex == 0 && HasFlag(HalfSpectrum) )
+        throw std::runtime_error("Not implemented yet");
+      else
+        dst.derived().resizeLike(src);
+
+      const int n0 = InputDerived::IsRowMajor ? src.rows(): src.cols();
+      const int n1 = InputDerived::IsRowMajor ? src.cols(): src.rows();
+      if ( src.innerStride() != 1 or src.outerStride() != n1 ) {
+        Matrix<src_type, Dynamic, Dynamic, Eigen::RowMajor> tmp = src;
+        inv2( dst, tmp );
+        return;
+      }
+      //choosing new plan, and putting in dummy data for plan.
+      if (m_impl.plan_flag != FFTW_plan_flag)
+      {
+        set_plan_flag(FFTW_plan_flag); //choosing rigor flag for FFTW plans
+        if (FFTW_plan_flag != FFTW_ESTIMATE|FFTW_PRESERVE_INPUT)
+        {//dummy data for fftw planning, otherwise input/output data can be changed
+          Matrix<src_type, Dynamic, Dynamic, Eigen::RowMajor> tmp_src = src;
+          Matrix<dst_type, Dynamic, Dynamic, Eigen::RowMajor> tmp_dst = dst;
+          inv2( tmp_dst.data(), tmp_src.data(), n0, n1, true );
+          if (only_plan)
+            return;
+        }
+      }
+      inv2( dst.data(), src.data(), n0, n1 );
+    }
+
     template <typename _Output>
     inline
     void inv( std::vector<_Output> & dst, const std::vector<Complex> & src,Index nfft=-1)
@@ -355,19 +435,31 @@
     }
 
 
-    /*
+    
     // TODO: multi-dimensional FFTs
     inline 
-    void inv2(Complex * dst, const Complex * src, int n0,int n1)
+    void inv2(Complex * dst, const Complex * src, int n0,int n1, bool only_plan = false)
     {
-      m_impl.inv2(dst,src,n0,n1);
+      m_impl.inv2(dst,src,n0,n1, only_plan);
       if ( HasFlag( Unscaled ) == false)
           scale(dst,1./(n0*n1),n0*n1);
     }
-  */
+  
 
     inline
     impl_type & impl() {return m_impl;}
+    inline
+    void set_plan_flag(const int new_plan_flag){
+      if (m_impl.plan_flag != new_plan_flag)
+      {
+        m_impl.clear();
+        m_impl.plan_flag = new_plan_flag;
+      }
+    };
+    inline
+    void clear_plans(){
+      m_impl.clear();
+    }
   private:
 
     template <typename T_Data>
diff -uNr orig/unsupported/eigen/src/FFT/ei_fftw_impl.h 3.2/unsupported/eigen/src/FFT/ei_fftw_impl.h
--- orig/unsupported/Eigen/src/FFT/ei_fftw_impl.h	2016-07-13 12:14:36.000000000 +0200
+++ 3.2/unsupported/Eigen/src/FFT/ei_fftw_impl.h	2016-07-13 12:14:36.000000000 +0200
@@ -52,41 +52,47 @@
   {
       typedef float scalar_type;
       typedef fftwf_complex complex_type;
+      int plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT;
       fftwf_plan m_plan;
       fftw_plan() :m_plan(NULL) {}
       ~fftw_plan() {if (m_plan) fftwf_destroy_plan(m_plan);}
 
       inline
-      void fwd(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwf_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft( m_plan, src,dst);
+      void fwd(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft( m_plan, src,dst);
       }
       inline
-      void inv(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwf_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft( m_plan, src,dst);
+      void inv(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft( m_plan, src,dst);
       }
       inline
-      void fwd(complex_type * dst,scalar_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwf_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft_r2c( m_plan,src,dst);
+      void fwd(complex_type * dst,scalar_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_r2c_1d(nfft,src,dst, plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft_r2c( m_plan,src,dst);
       }
       inline
-      void inv(scalar_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL)
-              m_plan = fftwf_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft_c2r( m_plan, src,dst);
+      void inv(scalar_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_c2r_1d(nfft,src,dst, plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft_c2r( m_plan, src,dst);
       }
 
       inline 
-      void fwd2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft( m_plan, src,dst);
+      void fwd2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD, plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft( m_plan, src,dst);
       }
       inline 
-      void inv2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwf_execute_dft( m_plan, src,dst);
+      void inv2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwf_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD, plan_flag);
+          if (not only_plan)
+            fftwf_execute_dft( m_plan, src,dst);
       }
 
   };
@@ -95,40 +101,46 @@
   {
       typedef double scalar_type;
       typedef fftw_complex complex_type;
+      int plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT;
       ::fftw_plan m_plan;
       fftw_plan() :m_plan(NULL) {}
       ~fftw_plan() {if (m_plan) fftw_destroy_plan(m_plan);}
 
       inline
-      void fwd(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftw_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft( m_plan, src,dst);
+      void fwd(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, plan_flag);
+          if (not only_plan)
+            fftw_execute_dft( m_plan, src,dst);
       }
       inline
-      void inv(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftw_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft( m_plan, src,dst);
+      void inv(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , plan_flag);
+          if (not only_plan)
+            fftw_execute_dft( m_plan, src,dst);
       }
       inline
-      void fwd(complex_type * dst,scalar_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftw_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft_r2c( m_plan,src,dst);
+      void fwd(complex_type * dst,scalar_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_r2c_1d(nfft,src,dst,plan_flag);
+          if (not only_plan)
+            fftw_execute_dft_r2c( m_plan,src,dst);
       }
       inline
-      void inv(scalar_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL)
-              m_plan = fftw_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft_c2r( m_plan, src,dst);
+      void inv(scalar_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_c2r_1d(nfft,src,dst,plan_flag);
+          if (not only_plan)    
+            fftw_execute_dft_c2r( m_plan, src,dst);
       }
       inline 
-      void fwd2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftw_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft( m_plan, src,dst);
+      void fwd2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,plan_flag);
+          if (not only_plan)
+            fftw_execute_dft( m_plan, src,dst);
       }
       inline 
-      void inv2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftw_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftw_execute_dft( m_plan, src,dst);
+      void inv2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftw_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,plan_flag);
+          if (not only_plan)
+            fftw_execute_dft( m_plan, src,dst);
       }
   };
   template <> 
@@ -137,39 +149,45 @@
       typedef long double scalar_type;
       typedef fftwl_complex complex_type;
       fftwl_plan m_plan;
+      int plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT;
       fftw_plan() :m_plan(NULL) {}
       ~fftw_plan() {if (m_plan) fftwl_destroy_plan(m_plan);}
 
       inline
-      void fwd(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwl_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft( m_plan, src,dst);
+      void fwd(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_1d(nfft,src,dst, FFTW_FORWARD, plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft( m_plan, src,dst);
       }
       inline
-      void inv(complex_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwl_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft( m_plan, src,dst);
+      void inv(complex_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_1d(nfft,src,dst, FFTW_BACKWARD , plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft( m_plan, src,dst);
       }
       inline
-      void fwd(complex_type * dst,scalar_type * src,int nfft) {
-          if (m_plan==NULL) m_plan = fftwl_plan_dft_r2c_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft_r2c( m_plan,src,dst);
+      void fwd(complex_type * dst,scalar_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_r2c_1d(nfft,src,dst,plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft_r2c( m_plan,src,dst);
       }
       inline
-      void inv(scalar_type * dst,complex_type * src,int nfft) {
-          if (m_plan==NULL)
-              m_plan = fftwl_plan_dft_c2r_1d(nfft,src,dst,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft_c2r( m_plan, src,dst);
+      void inv(scalar_type * dst,complex_type * src,int nfft, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_c2r_1d(nfft,src,dst,plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft_c2r( m_plan, src,dst);
       }
       inline 
-      void fwd2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft( m_plan, src,dst);
+      void fwd2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_FORWARD,plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft( m_plan, src,dst);
       }
       inline 
-      void inv2( complex_type * dst,complex_type * src,int n0,int n1) {
-          if (m_plan==NULL) m_plan = fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,FFTW_ESTIMATE|FFTW_PRESERVE_INPUT);
-          fftwl_execute_dft( m_plan, src,dst);
+      void inv2( complex_type * dst,complex_type * src,int n0,int n1, bool only_plan) {
+          if (m_plan==NULL) m_plan = fftwl_plan_dft_2d(n0,n1,src,dst,FFTW_BACKWARD,plan_flag);
+          if (not only_plan)
+            fftwl_execute_dft( m_plan, src,dst);
       }
   };
 
@@ -178,7 +196,7 @@
   {
       typedef _Scalar Scalar;
       typedef std::complex<Scalar> Complex;
-
+      int plan_flag = FFTW_ESTIMATE|FFTW_PRESERVE_INPUT;
       inline
       void clear() 
       {
@@ -187,44 +205,44 @@
 
       // complex-to-complex forward FFT
       inline
-      void fwd( Complex * dst,const Complex *src,int nfft)
+      void fwd( Complex * dst,const Complex *src,int nfft, bool only_plan = false)
       {
-        get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src),nfft );
+        get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src),nfft, only_plan);
       }
 
       // real-to-complex forward FFT
       inline
-      void fwd( Complex * dst,const Scalar * src,int nfft) 
+      void fwd( Complex * dst,const Scalar * src,int nfft, bool only_plan = false) 
       {
-          get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src) ,nfft);
+          get_plan(nfft,false,dst,src).fwd(fftw_cast(dst), fftw_cast(src) ,nfft, only_plan);
       }
 
       // 2-d complex-to-complex
       inline
-      void fwd2(Complex * dst, const Complex * src, int n0,int n1)
+      void fwd2(Complex * dst, const Complex * src, int n0,int n1, bool only_plan = false)
       {
-          get_plan(n0,n1,false,dst,src).fwd2(fftw_cast(dst), fftw_cast(src) ,n0,n1);
+          get_plan(n0,n1,false,dst,src).fwd2(fftw_cast(dst), fftw_cast(src) ,n0,n1, only_plan);
       }
 
       // inverse complex-to-complex
       inline
-      void inv(Complex * dst,const Complex  *src,int nfft)
+      void inv(Complex * dst,const Complex  *src,int nfft, bool only_plan = false)
       {
-        get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft );
+        get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft, only_plan);
       }
 
       // half-complex to scalar
       inline
-      void inv( Scalar * dst,const Complex * src,int nfft) 
+      void inv( Scalar * dst,const Complex * src,int nfft, bool only_plan = false) 
       {
-        get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft );
+        get_plan(nfft,true,dst,src).inv(fftw_cast(dst), fftw_cast(src),nfft, only_plan);
       }
 
       // 2-d complex-to-complex
       inline
-      void inv2(Complex * dst, const Complex * src, int n0,int n1)
+      void inv2(Complex * dst, const Complex * src, int n0,int n1, bool only_plan = false)
       {
-        get_plan(n0,n1,true,dst,src).inv2(fftw_cast(dst), fftw_cast(src) ,n0,n1);
+        get_plan(n0,n1,true,dst,src).inv2(fftw_cast(dst), fftw_cast(src) ,n0,n1, only_plan);
       }
 
 
@@ -234,13 +252,13 @@
       typedef std::map<int64_t,PlanData> PlanMap;
 
       PlanMap m_plans;
-
       inline
       PlanData & get_plan(int nfft,bool inverse,void * dst,const void * src)
       {
           bool inplace = (dst==src);
           bool aligned = ( (reinterpret_cast<size_t>(src)&15) | (reinterpret_cast<size_t>(dst)&15) ) == 0;
           int64_t key = ( (nfft<<3 ) | (inverse<<2) | (inplace<<1) | aligned ) << 1;
+          m_plans[key].plan_flag = plan_flag;
           return m_plans[key];
       }
 
@@ -250,6 +268,7 @@
           bool inplace = (dst==src);
           bool aligned = ( (reinterpret_cast<size_t>(src)&15) | (reinterpret_cast<size_t>(dst)&15) ) == 0;
           int64_t key = ( ( (((int64_t)n0) << 30)|(n1<<3 ) | (inverse<<2) | (inplace<<1) | aligned ) << 1 ) + 1;
+          m_plans[key].plan_flag = plan_flag;
           return m_plans[key];
       }
   };