37 @deftypefn {Loadable Function} {@var{method} =} fftw (\"planner\")\n\
38 @deftypefnx {Loadable Function} {} fftw (\"planner\", @var{method})\n\
39 @deftypefnx {Loadable Function} {@var{wisdom} =} fftw (\"dwisdom\")\n\
40 @deftypefnx {Loadable Function} {} fftw (\"dwisdom\", @var{wisdom})\n\
41 @deftypefnx {Loadable Function} {} fftw (\"threads\", @var{nthreads})\n\
42 @deftypefnx {Loadable Function} {@var{nthreads} =} fftw (\"threads\")\n\
44 Manage @sc{fftw} wisdom data. Wisdom data can be used to significantly\n\
45 accelerate the calculation of the FFTs, but implies an initial cost\n\
46 in its calculation. When the @sc{fftw} libraries are initialized, they read\n\
47 a system wide wisdom file (typically in @file{/etc/fftw/wisdom}), allowing\n\
48 wisdom to be shared between applications other than Octave. Alternatively,\n\
49 the @code{fftw} function can be used to import wisdom. For example,\n\
52 @var{wisdom} = fftw (\"dwisdom\")\n\
56 will save the existing wisdom used by Octave to the string @var{wisdom}.\n\
57 This string can then be saved to a file and restored using the @code{save}\n\
58 and @code{load} commands respectively. This existing wisdom can be\n\
59 re-imported as follows\n\
62 fftw (\"dwisdom\", @var{wisdom})\n\
65 If @var{wisdom} is an empty string, then the wisdom used is cleared.\n\
67 During the calculation of Fourier transforms further wisdom is generated.\n\
68 The fashion in which this wisdom is generated is also controlled by\n\
69 the @code{fftw} function. There are five different manners in which the\n\
70 wisdom can be treated:\n\
73 @item @qcode{\"estimate\"}\n\
74 Specifies that no run-time measurement of the optimal means of\n\
75 calculating a particular is performed, and a simple heuristic is used\n\
76 to pick a (probably sub-optimal) plan. The advantage of this method is\n\
77 that there is little or no overhead in the generation of the plan, which\n\
78 is appropriate for a Fourier transform that will be calculated once.\n\
80 @item @qcode{\"measure\"}\n\
81 In this case a range of algorithms to perform the transform is considered\n\
82 and the best is selected based on their execution time.\n\
84 @item @qcode{\"patient\"}\n\
85 Similar to @qcode{\"measure\"}, but a wider range of algorithms is\n\
88 @item @qcode{\"exhaustive\"}\n\
89 Like @qcode{\"measure\"}, but all possible algorithms that may be used to\n\
90 treat the transform are considered.\n\
92 @item @qcode{\"hybrid\"}\n\
93 As run-time measurement of the algorithm can be expensive, this is a\n\
94 compromise where @qcode{\"measure\"} is used for transforms up to the size\n\
95 of 8192 and beyond that the @qcode{\"estimate\"} method is used.\n\
98 The default method is @qcode{\"estimate\"}. The current method can\n\
102 @var{method} = fftw (\"planner\")\n\
109 fftw (\"planner\", @var{method})\n\
112 Note that calculated wisdom will be lost when restarting Octave. However,\n\
113 the wisdom data can be reloaded if it is saved to a file as described\n\
114 above. Saved wisdom files should not be used on different platforms since\n\
115 they will not be efficient and the point of calculating the wisdom is lost.\n\
117 The number of threads used for computing the plans and executing the\n\
118 transforms can be set with\n\
121 fftw (\"threads\", @var{NTHREADS})\n\
124 Note that octave must be compiled with multi-threaded @sc{fftw} support for\n\
125 this feature. The number of processors available to the current process is\n\
128 @seealso{fft, ifft, fft2, ifft2, fftn, ifftn}\n\
133 int nargin = args.
length ();
135 if (nargin < 1 || nargin > 2)
141 #if defined (HAVE_FFTW)
142 if (args(0).is_string ())
147 if (arg0 ==
"planner")
151 if (args(1).is_string ())
156 std::string arg1 = args(1).string_value ();
160 arg1.begin (), tolower);
166 if (arg1 ==
"estimate")
171 else if (arg1 ==
"measure")
176 else if (arg1 ==
"patient")
181 else if (arg1 ==
"exhaustive")
186 else if (arg1 ==
"hybrid")
192 error (
"unrecognized planner METHOD");
213 error (
"fftw planner expects a string value as METHOD");
232 else if (arg0 ==
"dwisdom")
236 if (args(1).is_string ())
241 std::string arg1 = args(1).string_value ();
244 char *str = fftw_export_wisdom_to_string ();
246 if (arg1.length () < 1)
247 fftw_forget_wisdom ();
248 else if (! fftw_import_wisdom_from_string (arg1.c_str ()))
249 error (
"could not import supplied WISDOM");
260 char *str = fftw_export_wisdom_to_string ();
265 else if (arg0 ==
"swisdom")
270 if (args(1).is_string ())
275 std::string arg1 = args(1).string_value ();
278 char *str = fftwf_export_wisdom_to_string ();
280 if (arg1.length () < 1)
281 fftwf_forget_wisdom ();
282 else if (! fftwf_import_wisdom_from_string (arg1.c_str ()))
283 error (
"could not import supplied WISDOM");
294 char *str = fftwf_export_wisdom_to_string ();
299 else if (arg0 ==
"threads")
303 if (args(1).is_real_scalar ())
305 int nthreads = args(1).int_value();
308 #if defined (HAVE_FFTW3_THREADS)
311 warning (
"this copy of Octave was not configured to use the multithreaded fftw libraries.");
313 #if defined (HAVE_FFTW3F_THREADS)
316 warning (
"this copy of Octave was not configured to use the multithreaded fftwf libraries.");
320 error (
"number of threads must be >=1");
323 error (
"setting threads needs one integer argument.");
326 #if defined (HAVE_FFTW3_THREADS)
333 error (
"unrecognized argument");
337 error (
"unrecognized argument");
340 warning (
"fftw: this copy of Octave was not configured to use the FFTW3 planner");