annotate liboctave/numeric/oct-fftw.cc @ 31605:e88a07dec498 stable

maint: Use macros to begin/end C++ namespaces. * oct-conf-post-public.in.h: Define two macros (OCTAVE_BEGIN_NAMESPACE, OCTAVE_END_NAMESPACE) that can be used to start/end a namespace. * mk-opts.pl, build-env.h, build-env.in.cc, __betainc__.cc, __contourc__.cc, __dsearchn__.cc, __eigs__.cc, __expint__.cc, __ftp__.cc, __gammainc__.cc, __ichol__.cc, __ilu__.cc, __isprimelarge__.cc, __lin_interpn__.cc, __magick_read__.cc, __pchip_deriv__.cc, __qp__.cc, amd.cc, auto-shlib.cc, auto-shlib.h, balance.cc, base-text-renderer.cc, base-text-renderer.h, besselj.cc, bitfcns.cc, bsxfun.cc, c-file-ptr-stream.cc, c-file-ptr-stream.h, call-stack.cc, call-stack.h, ccolamd.cc, cellfun.cc, chol.cc, colamd.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, data.h, debug.cc, defaults.cc, defaults.h, defun-int.h, defun.cc, det.cc, dirfns.cc, display.cc, display.h, dlmread.cc, dmperm.cc, dot.cc, dynamic-ld.cc, dynamic-ld.h, eig.cc, ellipj.cc, environment.cc, environment.h, error.cc, error.h, errwarn.h, event-manager.cc, event-manager.h, event-queue.cc, event-queue.h, fcn-info.cc, fcn-info.h, fft.cc, fft2.cc, fftn.cc, file-io.cc, filter.cc, find.cc, ft-text-renderer.cc, ft-text-renderer.h, gcd.cc, getgrent.cc, getpwent.cc, getrusage.cc, givens.cc, gl-render.cc, gl-render.h, gl2ps-print.cc, gl2ps-print.h, graphics-toolkit.cc, graphics-toolkit.h, graphics.cc, graphics.in.h, gsvd.cc, gtk-manager.cc, gtk-manager.h, hash.cc, help.cc, help.h, hess.cc, hex2num.cc, hook-fcn.cc, hook-fcn.h, input.cc, input.h, interpreter-private.cc, interpreter-private.h, interpreter.cc, interpreter.h, inv.cc, jsondecode.cc, jsonencode.cc, kron.cc, latex-text-renderer.cc, latex-text-renderer.h, load-path.cc, load-path.h, load-save.cc, load-save.h, lookup.cc, ls-ascii-helper.cc, ls-ascii-helper.h, ls-oct-text.cc, ls-utils.cc, ls-utils.h, lsode.cc, lu.cc, mappers.cc, matrix_type.cc, max.cc, mex-private.h, mex.cc, mgorth.cc, nproc.cc, oct-fstrm.cc, oct-fstrm.h, oct-hdf5-types.cc, oct-hdf5-types.h, oct-hist.cc, oct-hist.h, oct-iostrm.cc, oct-iostrm.h, oct-opengl.h, oct-prcstrm.cc, oct-prcstrm.h, oct-procbuf.cc, oct-procbuf.h, oct-process.cc, oct-process.h, oct-stdstrm.h, oct-stream.cc, oct-stream.h, oct-strstrm.cc, oct-strstrm.h, oct-tex-lexer.in.ll, oct-tex-parser.yy, ordqz.cc, ordschur.cc, pager.cc, pager.h, pinv.cc, pow2.cc, pr-flt-fmt.cc, pr-output.cc, procstream.cc, procstream.h, psi.cc, qr.cc, quad.cc, quadcc.cc, qz.cc, rand.cc, rcond.cc, regexp.cc, schur.cc, settings.cc, settings.h, sighandlers.cc, sighandlers.h, sparse-xdiv.cc, sparse-xdiv.h, sparse-xpow.cc, sparse-xpow.h, sparse.cc, spparms.cc, sqrtm.cc, stack-frame.cc, stack-frame.h, stream-euler.cc, strfind.cc, strfns.cc, sub2ind.cc, svd.cc, sylvester.cc, symbfact.cc, syminfo.cc, syminfo.h, symrcm.cc, symrec.cc, symrec.h, symscope.cc, symscope.h, symtab.cc, symtab.h, syscalls.cc, sysdep.cc, sysdep.h, text-engine.cc, text-engine.h, text-renderer.cc, text-renderer.h, time.cc, toplev.cc, tril.cc, tsearch.cc, typecast.cc, url-handle-manager.cc, url-handle-manager.h, urlwrite.cc, utils.cc, utils.h, variables.cc, variables.h, xdiv.cc, xdiv.h, xnorm.cc, xnorm.h, xpow.cc, xpow.h, __delaunayn__.cc, __fltk_uigetfile__.cc, __glpk__.cc, __init_fltk__.cc, __init_gnuplot__.cc, __ode15__.cc, __voronoi__.cc, audiodevinfo.cc, audioread.cc, convhulln.cc, fftw.cc, gzip.cc, mk-build-env-features.sh, mk-builtins.pl, cdef-class.cc, cdef-class.h, cdef-fwd.h, cdef-manager.cc, cdef-manager.h, cdef-method.cc, cdef-method.h, cdef-object.cc, cdef-object.h, cdef-package.cc, cdef-package.h, cdef-property.cc, cdef-property.h, cdef-utils.cc, cdef-utils.h, ov-base.cc, ov-base.h, ov-bool-mat.cc, ov-builtin.h, ov-cell.cc, ov-class.cc, ov-class.h, ov-classdef.cc, ov-classdef.h, ov-complex.cc, ov-fcn-handle.cc, ov-fcn-handle.h, ov-fcn.h, ov-java.cc, ov-java.h, ov-mex-fcn.h, ov-null-mat.cc, ov-oncleanup.cc, ov-struct.cc, ov-typeinfo.cc, ov-typeinfo.h, ov-usr-fcn.cc, ov-usr-fcn.h, ov.cc, ov.h, octave.cc, octave.h, mk-ops.sh, op-b-b.cc, op-b-bm.cc, op-b-sbm.cc, op-bm-b.cc, op-bm-bm.cc, op-bm-sbm.cc, op-cdm-cdm.cc, op-cell.cc, op-chm.cc, op-class.cc, op-cm-cm.cc, op-cm-cs.cc, op-cm-m.cc, op-cm-s.cc, op-cm-scm.cc, op-cm-sm.cc, op-cs-cm.cc, op-cs-cs.cc, op-cs-m.cc, op-cs-s.cc, op-cs-scm.cc, op-cs-sm.cc, op-dm-dm.cc, op-dm-scm.cc, op-dm-sm.cc, op-dm-template.cc, op-dms-template.cc, op-fcdm-fcdm.cc, op-fcm-fcm.cc, op-fcm-fcs.cc, op-fcm-fm.cc, op-fcm-fs.cc, op-fcn.cc, op-fcs-fcm.cc, op-fcs-fcs.cc, op-fcs-fm.cc, op-fcs-fs.cc, op-fdm-fdm.cc, op-fm-fcm.cc, op-fm-fcs.cc, op-fm-fm.cc, op-fm-fs.cc, op-fs-fcm.cc, op-fs-fcs.cc, op-fs-fm.cc, op-fs-fs.cc, op-i16-i16.cc, op-i32-i32.cc, op-i64-i64.cc, op-i8-i8.cc, op-int-concat.cc, op-m-cm.cc, op-m-cs.cc, op-m-m.cc, op-m-s.cc, op-m-scm.cc, op-m-sm.cc, op-mi.cc, op-pm-pm.cc, op-pm-scm.cc, op-pm-sm.cc, op-pm-template.cc, op-range.cc, op-s-cm.cc, op-s-cs.cc, op-s-m.cc, op-s-s.cc, op-s-scm.cc, op-s-sm.cc, op-sbm-b.cc, op-sbm-bm.cc, op-sbm-sbm.cc, op-scm-cm.cc, op-scm-cs.cc, op-scm-m.cc, op-scm-s.cc, op-scm-scm.cc, op-scm-sm.cc, op-sm-cm.cc, op-sm-cs.cc, op-sm-m.cc, op-sm-s.cc, op-sm-scm.cc, op-sm-sm.cc, op-str-m.cc, op-str-s.cc, op-str-str.cc, op-struct.cc, op-ui16-ui16.cc, op-ui32-ui32.cc, op-ui64-ui64.cc, op-ui8-ui8.cc, ops.h, anon-fcn-validator.cc, anon-fcn-validator.h, bp-table.cc, bp-table.h, comment-list.cc, comment-list.h, filepos.h, lex.h, lex.ll, oct-lvalue.cc, oct-lvalue.h, oct-parse.yy, parse.h, profiler.cc, profiler.h, pt-anon-scopes.cc, pt-anon-scopes.h, pt-arg-list.cc, pt-arg-list.h, pt-args-block.cc, pt-args-block.h, pt-array-list.cc, pt-array-list.h, pt-assign.cc, pt-assign.h, pt-binop.cc, pt-binop.h, pt-bp.cc, pt-bp.h, pt-cbinop.cc, pt-cbinop.h, pt-cell.cc, pt-cell.h, pt-check.cc, pt-check.h, pt-classdef.cc, pt-classdef.h, pt-cmd.h, pt-colon.cc, pt-colon.h, pt-const.cc, pt-const.h, pt-decl.cc, pt-decl.h, pt-eval.cc, pt-eval.h, pt-except.cc, pt-except.h, pt-exp.cc, pt-exp.h, pt-fcn-handle.cc, pt-fcn-handle.h, pt-id.cc, pt-id.h, pt-idx.cc, pt-idx.h, pt-jump.h, pt-loop.cc, pt-loop.h, pt-mat.cc, pt-mat.h, pt-misc.cc, pt-misc.h, pt-pr-code.cc, pt-pr-code.h, pt-select.cc, pt-select.h, pt-spmd.cc, pt-spmd.h, pt-stmt.cc, pt-stmt.h, pt-tm-const.cc, pt-tm-const.h, pt-unop.cc, pt-unop.h, pt-vm-eval.cc, pt-walk.cc, pt-walk.h, pt.cc, pt.h, token.cc, token.h, Range.cc, Range.h, idx-vector.cc, idx-vector.h, range-fwd.h, CollocWt.cc, CollocWt.h, aepbalance.cc, aepbalance.h, chol.cc, chol.h, gepbalance.cc, gepbalance.h, gsvd.cc, gsvd.h, hess.cc, hess.h, lo-mappers.cc, lo-mappers.h, lo-specfun.cc, lo-specfun.h, lu.cc, lu.h, oct-convn.cc, oct-convn.h, oct-fftw.cc, oct-fftw.h, oct-norm.cc, oct-norm.h, oct-rand.cc, oct-rand.h, oct-spparms.cc, oct-spparms.h, qr.cc, qr.h, qrp.cc, qrp.h, randgamma.cc, randgamma.h, randmtzig.cc, randmtzig.h, randpoisson.cc, randpoisson.h, schur.cc, schur.h, sparse-chol.cc, sparse-chol.h, sparse-lu.cc, sparse-lu.h, sparse-qr.cc, sparse-qr.h, svd.cc, svd.h, child-list.cc, child-list.h, dir-ops.cc, dir-ops.h, file-ops.cc, file-ops.h, file-stat.cc, file-stat.h, lo-sysdep.cc, lo-sysdep.h, lo-sysinfo.cc, lo-sysinfo.h, mach-info.cc, mach-info.h, oct-env.cc, oct-env.h, oct-group.cc, oct-group.h, oct-password.cc, oct-password.h, oct-syscalls.cc, oct-syscalls.h, oct-time.cc, oct-time.h, oct-uname.cc, oct-uname.h, action-container.cc, action-container.h, base-list.h, cmd-edit.cc, cmd-edit.h, cmd-hist.cc, cmd-hist.h, f77-fcn.h, file-info.cc, file-info.h, lo-array-errwarn.cc, lo-array-errwarn.h, lo-hash.cc, lo-hash.h, lo-ieee.h, lo-regexp.cc, lo-regexp.h, lo-utils.cc, lo-utils.h, oct-base64.cc, oct-base64.h, oct-glob.cc, oct-glob.h, oct-inttypes.h, oct-mutex.cc, oct-mutex.h, oct-refcount.h, oct-shlib.cc, oct-shlib.h, oct-sparse.cc, oct-sparse.h, oct-string.h, octave-preserve-stream-state.h, pathsearch.cc, pathsearch.h, quit.cc, quit.h, unwind-prot.cc, unwind-prot.h, url-transfer.cc, url-transfer.h : Use new macros to begin/end C++ namespaces.
author Rik <rik@octave.org>
date Thu, 01 Dec 2022 14:23:45 -0800
parents 68ec7f275f0e
children aac27ad79be6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 30102
diff changeset
3 // Copyright (C) 2001-2022 The Octave Project Developers
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21688
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21202
diff changeset
27 # include "config.h"
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
28 #endif
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
29
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
30 #if defined (HAVE_FFTW3_H)
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
31 # include <fftw3.h>
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
32 #endif
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
33
4786
fc316bde0053 [project @ 2004-02-18 12:52:20 by jwe]
jwe
parents: 4785
diff changeset
34 #include "lo-error.h"
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
35 #include "oct-fftw.h"
23475
d691ed308237 maint: Clean up #includes in liboctave/numeric directory.
Rik <rik@octave.org>
parents: 23457
diff changeset
36 #include "oct-locbuf.h"
4786
fc316bde0053 [project @ 2004-02-18 12:52:20 by jwe]
jwe
parents: 4785
diff changeset
37 #include "quit.h"
13983
7dd7cccf0757 clean up memory allocated for singletons before exit
John W. Eaton <jwe@octave.org>
parents: 11586
diff changeset
38 #include "singleton-cleanup.h"
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
39
21520
e1c921322ba2 Fix configuration conditions in oct-fftw.cc
Mike Miller <mtmiller@octave.org>
parents: 21451
diff changeset
40 #if defined (HAVE_FFTW3_THREADS) || defined (HAVE_FFTW3F_THREADS)
21893
0a6f387d18d3 * nproc.cc, oct-fftw.cc: Use octave_num_processors_wrapper.
John W. Eaton <jwe@octave.org>
parents: 21751
diff changeset
41 # include "nproc-wrapper.h"
15960
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
42 #endif
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
43
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31184
diff changeset
44 OCTAVE_BEGIN_NAMESPACE(octave)
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31184
diff changeset
45
21688
68ab693d16e4 * oct-fftw.cc: Allow compilation without FFTW.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
46 #if defined (HAVE_FFTW)
68ab693d16e4 * oct-fftw.cc: Allow compilation without FFTW.
John W. Eaton <jwe@octave.org>
parents: 21660
diff changeset
47
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
48 fftw_planner *fftw_planner::s_instance = nullptr;
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
49
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
50 // Helper class to create and cache FFTW plans for both 1D and
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
51 // 2D. This implementation defaults to using FFTW_ESTIMATE to create
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
52 // the plans, which in theory is suboptimal, but provides quite
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
53 // reasonable performance in practice.
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
54
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
55 // Also note that if FFTW_ESTIMATE is not used then the planner in FFTW3
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
56 // will destroy the input and output arrays. We must, therefore, create a
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
57 // temporary input array with the same size and 16-byte alignment as
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
58 // the original array when using a different planner strategy.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
59 // Note that we also use any wisdom that is available, either in a
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
60 // FFTW3 system wide file or as supplied by the user.
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
61
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
62 // FIXME: if we can ensure 16 byte alignment in Array<T>
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
63 // (<T> *data) the FFTW3 can use SIMD instructions for further
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
64 // acceleration.
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
65
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
66 // Note that it is profitable to store the FFTW3 plans, for small FFTs.
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
67
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
68 fftw_planner::fftw_planner (void)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
69 : m_meth (ESTIMATE), m_rplan (nullptr), m_rd (0), m_rs (0), m_rr (0),
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
70 m_rh (0), m_rn (), m_rsimd_align (false), m_nthreads (1)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
71 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
72 m_plan[0] = m_plan[1] = nullptr;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
73 m_d[0] = m_d[1] = m_s[0] = m_s[1] = m_r[0] = m_r[1] = m_h[0] = m_h[1] = 0;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
74 m_simd_align[0] = m_simd_align[1] = false;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
75 m_inplace[0] = m_inplace[1] = false;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
76 m_n[0] = m_n[1] = dim_vector ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
77
15960
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
78 #if defined (HAVE_FFTW3_THREADS)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
79 int init_ret = fftw_init_threads ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
80 if (! init_ret)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
81 (*current_liboctave_error_handler) ("Error initializing FFTW threads");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20955
diff changeset
82
31184
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
83 // Check number of processors available to the current process
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
84 m_nthreads =
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
85 octave_num_processors_wrapper (OCTAVE_NPROC_CURRENT_OVERRIDABLE);
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
86
31184
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
87 // Limit number of threads to 3 by default
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
88 // See: https://octave.discourse.group/t/3121
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
89 // This can be later changed with fftw ("threads", nthreads).
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
90 if (m_nthreads > 3)
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
91 m_nthreads = 3;
68ec7f275f0e fftw: Limit the default number of threads used by FFTW to 3.
Markus Mützel <markus.muetzel@gmx.de>
parents: 30564
diff changeset
92
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
93 fftw_plan_with_nthreads (m_nthreads);
15960
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
94 #endif
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
95
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
96 // If we have a system wide wisdom file, import it.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
97 fftw_import_system_wisdom ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
98 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
99
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
100 fftw_planner::~fftw_planner (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
101 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
102 fftw_plan *plan_p;
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
103
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
104 plan_p = reinterpret_cast<fftw_plan *> (&m_rplan);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
105 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
106 fftw_destroy_plan (*plan_p);
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
107
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
108 plan_p = reinterpret_cast<fftw_plan *> (&m_plan[0]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
109 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
110 fftw_destroy_plan (*plan_p);
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
111
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
112 plan_p = reinterpret_cast<fftw_plan *> (&m_plan[1]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
113 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
114 fftw_destroy_plan (*plan_p);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
115 }
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
116
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
117 bool
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
118 fftw_planner::instance_ok (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
119 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
120 bool retval = true;
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
121
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
122 if (! s_instance)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
123 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
124 s_instance = new fftw_planner ();
26369
0249ba4c9589 Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents: 26148
diff changeset
125 singleton_cleanup_list::add (cleanup_instance);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
126 }
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
127
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
128 return retval;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
129 }
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
130
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
131 void
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
132 fftw_planner::threads (int nt)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
133 {
21520
e1c921322ba2 Fix configuration conditions in oct-fftw.cc
Mike Miller <mtmiller@octave.org>
parents: 21451
diff changeset
134 #if defined (HAVE_FFTW3_THREADS)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
135 if (instance_ok () && nt != threads ())
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
136 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
137 s_instance->m_nthreads = nt;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
138 fftw_plan_with_nthreads (nt);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
139 // Clear the current plans.
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
140 s_instance->m_rplan = nullptr;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
141 s_instance->m_plan[0] = s_instance->m_plan[1] = nullptr;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
142 }
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
143 #else
26148
8c72f0345ee8 maint: Silence compiler warnings about unused or too many parameters.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 25688
diff changeset
144 octave_unused_parameter (nt);
8c72f0345ee8 maint: Silence compiler warnings about unused or too many parameters.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 25688
diff changeset
145
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
146 (*current_liboctave_warning_handler)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
147 ("unable to change number of threads without FFTW thread support");
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
148 #endif
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
149 }
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
150
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
151 #define CHECK_SIMD_ALIGNMENT(x) \
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
152 (((reinterpret_cast<std::ptrdiff_t> (x)) & 0xF) == 0)
4808
a9ec0ce18568 [project @ 2004-03-02 17:36:28 by jwe]
jwe
parents: 4788
diff changeset
153
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
154 void *
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
155 fftw_planner::do_create_plan (int dir, const int rank,
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
156 const dim_vector& dims,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
157 octave_idx_type howmany,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
158 octave_idx_type stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
159 octave_idx_type dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
160 const Complex *in, Complex *out)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
161 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
162 int which = (dir == FFTW_FORWARD) ? 0 : 1;
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
163 fftw_plan *cur_plan_p = reinterpret_cast<fftw_plan *> (&m_plan[which]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
164 bool create_new_plan = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
165 bool ioalign = CHECK_SIMD_ALIGNMENT (in) && CHECK_SIMD_ALIGNMENT (out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
166 bool ioinplace = (in == out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
167
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
168 // Don't create a new plan if we have a non SIMD plan already but
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
169 // can do SIMD. This prevents endlessly recreating plans if we
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
170 // change the alignment.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
171
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
172 if (m_plan[which] == nullptr || m_d[which] != dist || m_s[which] != stride
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
173 || m_r[which] != rank || m_h[which] != howmany
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
174 || ioinplace != m_inplace[which]
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
175 || ((ioalign != m_simd_align[which]) ? ! ioalign : false))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
176 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
177 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
178 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
179 // We still might not have the same shape of array.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
180
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
181 for (int i = 0; i < rank; i++)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
182 if (dims(i) != m_n[which](i))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
183 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
184 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
185 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
186 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
187 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
188
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
189 if (create_new_plan)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
190 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
191 m_d[which] = dist;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
192 m_s[which] = stride;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
193 m_r[which] = rank;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
194 m_h[which] = howmany;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
195 m_simd_align[which] = ioalign;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
196 m_inplace[which] = ioinplace;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
197 m_n[which] = dims;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
198
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
199 // Note reversal of dimensions for column major storage in FFTW.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
200 octave_idx_type nn = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
201 OCTAVE_LOCAL_BUFFER (int, tmp, rank);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
202
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
203 for (int i = 0, j = rank-1; i < rank; i++, j--)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
204 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
205 tmp[i] = dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
206 nn *= dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
207 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
208
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
209 int plan_flags = 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
210 bool plan_destroys_in = true;
4809
b60be7678bdc [project @ 2004-03-02 17:40:08 by jwe]
jwe
parents: 4808
diff changeset
211
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
212 switch (m_meth)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
213 {
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
214 case UNKNOWN:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
215 case ESTIMATE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
216 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
217 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
218 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
219 case MEASURE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
220 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
221 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
222 case PATIENT:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
223 plan_flags |= FFTW_PATIENT;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
224 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
225 case EXHAUSTIVE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
226 plan_flags |= FFTW_EXHAUSTIVE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
227 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
228 case HYBRID:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
229 if (nn < 8193)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
230 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
231 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
232 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
233 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
234 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
235 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
236 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
237 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
238
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
239 if (ioalign)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
240 plan_flags &= ~FFTW_UNALIGNED;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
241 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
242 plan_flags |= FFTW_UNALIGNED;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
243
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
244 if (*cur_plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
245 fftw_destroy_plan (*cur_plan_p);
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
246
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
247 if (plan_destroys_in)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
248 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
249 // Create matrix with the same size and 16-byte alignment as input
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
250 OCTAVE_LOCAL_BUFFER (Complex, itmp, nn * howmany + 32);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
251 itmp = reinterpret_cast<Complex *>
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
252 (((reinterpret_cast<std::ptrdiff_t> (itmp) + 15) & ~ 0xF) +
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
253 ((reinterpret_cast<std::ptrdiff_t> (in)) & 0xF));
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
254
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
255 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
256 = fftw_plan_many_dft (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
257 reinterpret_cast<fftw_complex *> (itmp),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
258 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
259 reinterpret_cast<fftw_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
260 nullptr, stride, dist, dir, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
261 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
262 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
263 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
264 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
265 = fftw_plan_many_dft (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
266 reinterpret_cast<fftw_complex *> (const_cast<Complex *> (in)),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
267 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
268 reinterpret_cast<fftw_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
269 nullptr, stride, dist, dir, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
270 }
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
271
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
272 if (*cur_plan_p == nullptr)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
273 (*current_liboctave_error_handler) ("Error creating FFTW plan");
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
274 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
275
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
276 return *cur_plan_p;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
277 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
278
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
279 void *
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
280 fftw_planner::do_create_plan (const int rank, const dim_vector& dims,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
281 octave_idx_type howmany,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
282 octave_idx_type stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
283 octave_idx_type dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
284 const double *in, Complex *out)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
285 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
286 fftw_plan *cur_plan_p = reinterpret_cast<fftw_plan *> (&m_rplan);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
287 bool create_new_plan = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
288 bool ioalign = CHECK_SIMD_ALIGNMENT (in) && CHECK_SIMD_ALIGNMENT (out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
289
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
290 // Don't create a new plan if we have a non SIMD plan already but
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
291 // can do SIMD. This prevents endlessly recreating plans if we
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
292 // change the alignment.
4808
a9ec0ce18568 [project @ 2004-03-02 17:36:28 by jwe]
jwe
parents: 4788
diff changeset
293
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
294 if (m_rplan == nullptr || m_rd != dist || m_rs != stride || m_rr != rank
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
295 || m_rh != howmany || ((ioalign != m_rsimd_align) ? ! ioalign : false))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
296 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
297 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
298 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
299 // We still might not have the same shape of array.
4809
b60be7678bdc [project @ 2004-03-02 17:40:08 by jwe]
jwe
parents: 4808
diff changeset
300
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
301 for (int i = 0; i < rank; i++)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
302 if (dims(i) != m_rn(i))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
303 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
304 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
305 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
306 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
307 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
308
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
309 if (create_new_plan)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
310 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
311 m_rd = dist;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
312 m_rs = stride;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
313 m_rr = rank;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
314 m_rh = howmany;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
315 m_rsimd_align = ioalign;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
316 m_rn = dims;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
317
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
318 // Note reversal of dimensions for column major storage in FFTW.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
319 octave_idx_type nn = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
320 OCTAVE_LOCAL_BUFFER (int, tmp, rank);
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
321
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
322 for (int i = 0, j = rank-1; i < rank; i++, j--)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
323 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
324 tmp[i] = dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
325 nn *= dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
326 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
327
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
328 int plan_flags = 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
329 bool plan_destroys_in = true;
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
330
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
331 switch (m_meth)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
332 {
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
333 case UNKNOWN:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
334 case ESTIMATE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
335 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
336 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
337 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
338 case MEASURE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
339 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
340 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
341 case PATIENT:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
342 plan_flags |= FFTW_PATIENT;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
343 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
344 case EXHAUSTIVE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
345 plan_flags |= FFTW_EXHAUSTIVE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
346 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
347 case HYBRID:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
348 if (nn < 8193)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
349 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
350 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
351 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
352 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
353 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
354 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
355 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
356 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
357
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
358 if (ioalign)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
359 plan_flags &= ~FFTW_UNALIGNED;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
360 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
361 plan_flags |= FFTW_UNALIGNED;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
362
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
363 if (*cur_plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
364 fftw_destroy_plan (*cur_plan_p);
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
365
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
366 if (plan_destroys_in)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
367 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
368 // Create matrix with the same size and 16-byte alignment as input
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
369 OCTAVE_LOCAL_BUFFER (double, itmp, nn + 32);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
370 itmp = reinterpret_cast<double *>
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
371 (((reinterpret_cast<std::ptrdiff_t> (itmp) + 15) & ~ 0xF) +
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
372 ((reinterpret_cast<std::ptrdiff_t> (in)) & 0xF));
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
373
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
374 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
375 = fftw_plan_many_dft_r2c (rank, tmp, howmany, itmp,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
376 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
377 reinterpret_cast<fftw_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
378 nullptr, stride, dist, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
379 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
380 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
381 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
382 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
383 = fftw_plan_many_dft_r2c (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
384 (const_cast<double *> (in)),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
385 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
386 reinterpret_cast<fftw_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
387 nullptr, stride, dist, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
388 }
6228
aa5df9ba98d5 [project @ 2007-01-05 22:49:03 by dbateman]
dbateman
parents: 5775
diff changeset
389
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
390 if (*cur_plan_p == nullptr)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
391 (*current_liboctave_error_handler) ("Error creating FFTW plan");
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
392 }
4808
a9ec0ce18568 [project @ 2004-03-02 17:36:28 by jwe]
jwe
parents: 4788
diff changeset
393
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
394 return *cur_plan_p;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
395 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
396
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
397 fftw_planner::FftwMethod
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
398 fftw_planner::do_method (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
399 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
400 return m_meth;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
401 }
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
402
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
403 fftw_planner::FftwMethod
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
404 fftw_planner::do_method (FftwMethod _meth)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
405 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
406 FftwMethod ret = m_meth;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
407 if (_meth == ESTIMATE || _meth == MEASURE
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
408 || _meth == PATIENT || _meth == EXHAUSTIVE
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
409 || _meth == HYBRID)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
410 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
411 if (m_meth != _meth)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
412 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
413 m_meth = _meth;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
414 if (m_rplan)
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
415 fftw_destroy_plan (reinterpret_cast<fftw_plan> (m_rplan));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
416 if (m_plan[0])
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
417 fftw_destroy_plan (reinterpret_cast<fftw_plan> (m_plan[0]));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
418 if (m_plan[1])
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
419 fftw_destroy_plan (reinterpret_cast<fftw_plan> (m_plan[1]));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
420 m_rplan = m_plan[0] = m_plan[1] = nullptr;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
421 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
422 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
423 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
424 ret = UNKNOWN;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
425 return ret;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
426 }
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
427
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
428 float_fftw_planner *float_fftw_planner::s_instance = nullptr;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
429
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
430 float_fftw_planner::float_fftw_planner (void)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
431 : m_meth (ESTIMATE), m_rplan (nullptr), m_rd (0), m_rs (0), m_rr (0),
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
432 m_rh (0), m_rn (), m_rsimd_align (false), m_nthreads (1)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
433 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
434 m_plan[0] = m_plan[1] = nullptr;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
435 m_d[0] = m_d[1] = m_s[0] = m_s[1] = m_r[0] = m_r[1] = m_h[0] = m_h[1] = 0;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
436 m_simd_align[0] = m_simd_align[1] = false;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
437 m_inplace[0] = m_inplace[1] = false;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
438 m_n[0] = m_n[1] = dim_vector ();
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
439
15960
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
440 #if defined (HAVE_FFTW3F_THREADS)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
441 int init_ret = fftwf_init_threads ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
442 if (! init_ret)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
443 (*current_liboctave_error_handler) ("Error initializing FFTW3F threads");
21136
7cac4e7458f2 maint: clean up code around calls to current_liboctave_error_handler.
Rik <rik@octave.org>
parents: 20955
diff changeset
444
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
445 // Use number of processors available to the current process
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
446 // This can be later changed with fftw ("threads", nthreads).
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
447 m_nthreads =
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
448 octave_num_processors_wrapper (OCTAVE_NPROC_CURRENT_OVERRIDABLE);
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
449
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
450 fftwf_plan_with_nthreads (m_nthreads);
15960
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
451 #endif
bde7731b2b83 added FFTW multithreaded library support
Andreas Weber <andy.weber.aw@gmail.com>
parents: 15271
diff changeset
452
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
453 // If we have a system wide wisdom file, import it.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
454 fftwf_import_system_wisdom ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
455 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
456
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
457 float_fftw_planner::~float_fftw_planner (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
458 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
459 fftwf_plan *plan_p;
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
460
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
461 plan_p = reinterpret_cast<fftwf_plan *> (&m_rplan);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
462 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
463 fftwf_destroy_plan (*plan_p);
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
464
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
465 plan_p = reinterpret_cast<fftwf_plan *> (&m_plan[0]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
466 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
467 fftwf_destroy_plan (*plan_p);
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
468
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
469 plan_p = reinterpret_cast<fftwf_plan *> (&m_plan[1]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
470 if (*plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
471 fftwf_destroy_plan (*plan_p);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
472 }
14078
941d19370065 Cleanup FFTW wisdom plans in class destructor and prevent a memory leak.
Rik <octave@nomad.inbox5.com>
parents: 13994
diff changeset
473
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
474 bool
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
475 float_fftw_planner::instance_ok (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
476 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
477 bool retval = true;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
478
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
479 if (! s_instance)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
480 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
481 s_instance = new float_fftw_planner ();
26369
0249ba4c9589 Fix static analyzer detected V668 issues (bug #55347).
Andreas Weber <octave@josoansi.de>
parents: 26148
diff changeset
482 singleton_cleanup_list::add (cleanup_instance);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
483 }
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
484
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
485 return retval;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
486 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
487
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
488 void
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
489 float_fftw_planner::threads (int nt)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
490 {
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
491 #if defined (HAVE_FFTW3F_THREADS)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
492 if (instance_ok () && nt != threads ())
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
493 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
494 s_instance->m_nthreads = nt;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
495 fftwf_plan_with_nthreads (nt);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
496 // Clear the current plans.
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
497 s_instance->m_rplan = nullptr;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
498 s_instance->m_plan[0] = s_instance->m_plan[1] = nullptr;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
499 }
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
500 #else
26148
8c72f0345ee8 maint: Silence compiler warnings about unused or too many parameters.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 25688
diff changeset
501 octave_unused_parameter (nt);
8c72f0345ee8 maint: Silence compiler warnings about unused or too many parameters.
Kai T. Ohlhus <k.ohlhus@gmail.com>
parents: 25688
diff changeset
502
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
503 (*current_liboctave_warning_handler)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
504 ("unable to change number of threads without FFTW thread support");
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
505 #endif
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
506 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
507
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
508 void *
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
509 float_fftw_planner::do_create_plan (int dir, const int rank,
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
510 const dim_vector& dims,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
511 octave_idx_type howmany,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
512 octave_idx_type stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
513 octave_idx_type dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
514 const FloatComplex *in,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
515 FloatComplex *out)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
516 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
517 int which = (dir == FFTW_FORWARD) ? 0 : 1;
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
518 fftwf_plan *cur_plan_p = reinterpret_cast<fftwf_plan *> (&m_plan[which]);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
519 bool create_new_plan = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
520 bool ioalign = CHECK_SIMD_ALIGNMENT (in) && CHECK_SIMD_ALIGNMENT (out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
521 bool ioinplace = (in == out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
522
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
523 // Don't create a new plan if we have a non SIMD plan already but
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
524 // can do SIMD. This prevents endlessly recreating plans if we
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
525 // change the alignment.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
526
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
527 if (m_plan[which] == nullptr || m_d[which] != dist || m_s[which] != stride
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
528 || m_r[which] != rank || m_h[which] != howmany
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
529 || ioinplace != m_inplace[which]
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
530 || ((ioalign != m_simd_align[which]) ? ! ioalign : false))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
531 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
532 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
533 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
534 // We still might not have the same shape of array.
21451
763e30285935 eliminate configuration macros from oct-fftw.h (bug #41027)
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
535
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
536 for (int i = 0; i < rank; i++)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
537 if (dims(i) != m_n[which](i))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
538 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
539 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
540 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
541 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
542 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
543
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
544 if (create_new_plan)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
545 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
546 m_d[which] = dist;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
547 m_s[which] = stride;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
548 m_r[which] = rank;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
549 m_h[which] = howmany;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
550 m_simd_align[which] = ioalign;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
551 m_inplace[which] = ioinplace;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
552 m_n[which] = dims;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
553
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
554 // Note reversal of dimensions for column major storage in FFTW.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
555 octave_idx_type nn = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
556 OCTAVE_LOCAL_BUFFER (int, tmp, rank);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
557
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
558 for (int i = 0, j = rank-1; i < rank; i++, j--)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
559 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
560 tmp[i] = dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
561 nn *= dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
562 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
563
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
564 int plan_flags = 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
565 bool plan_destroys_in = true;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
566
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
567 switch (m_meth)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
568 {
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
569 case UNKNOWN:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
570 case ESTIMATE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
571 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
572 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
573 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
574 case MEASURE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
575 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
576 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
577 case PATIENT:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
578 plan_flags |= FFTW_PATIENT;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
579 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
580 case EXHAUSTIVE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
581 plan_flags |= FFTW_EXHAUSTIVE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
582 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
583 case HYBRID:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
584 if (nn < 8193)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
585 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
586 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
587 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
588 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
589 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
590 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
591 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
592 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
593
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
594 if (ioalign)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
595 plan_flags &= ~FFTW_UNALIGNED;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
596 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
597 plan_flags |= FFTW_UNALIGNED;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
598
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
599 if (*cur_plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
600 fftwf_destroy_plan (*cur_plan_p);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
601
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
602 if (plan_destroys_in)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
603 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
604 // Create matrix with the same size and 16-byte alignment as input
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
605 OCTAVE_LOCAL_BUFFER (FloatComplex, itmp, nn * howmany + 32);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
606 itmp = reinterpret_cast<FloatComplex *>
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
607 (((reinterpret_cast<std::ptrdiff_t> (itmp) + 15) & ~ 0xF) +
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
608 ((reinterpret_cast<std::ptrdiff_t> (in)) & 0xF));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
609
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
610 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
611 = fftwf_plan_many_dft (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
612 reinterpret_cast<fftwf_complex *> (itmp),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
613 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
614 reinterpret_cast<fftwf_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
615 nullptr, stride, dist, dir, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
616 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
617 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
618 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
619 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
620 = fftwf_plan_many_dft (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
621 reinterpret_cast<fftwf_complex *> (const_cast<FloatComplex *> (in)),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
622 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
623 reinterpret_cast<fftwf_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
624 nullptr, stride, dist, dir, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
625 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
626
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
627 if (*cur_plan_p == nullptr)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
628 (*current_liboctave_error_handler) ("Error creating FFTW plan");
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
629 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
630
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
631 return *cur_plan_p;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
632 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
633
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
634 void *
23440
f15f0d8b78c8 pass dim_vector as const reference, not by value
John W. Eaton <jwe@octave.org>
parents: 23433
diff changeset
635 float_fftw_planner::do_create_plan (const int rank, const dim_vector& dims,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
636 octave_idx_type howmany,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
637 octave_idx_type stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
638 octave_idx_type dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
639 const float *in, FloatComplex *out)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
640 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
641 fftwf_plan *cur_plan_p = reinterpret_cast<fftwf_plan *> (&m_rplan);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
642 bool create_new_plan = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
643 bool ioalign = CHECK_SIMD_ALIGNMENT (in) && CHECK_SIMD_ALIGNMENT (out);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
644
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
645 // Don't create a new plan if we have a non SIMD plan already but
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
646 // can do SIMD. This prevents endlessly recreating plans if we
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
647 // change the alignment.
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
648
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
649 if (m_rplan == nullptr || m_rd != dist || m_rs != stride || m_rr != rank
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
650 || m_rh != howmany || ((ioalign != m_rsimd_align) ? ! ioalign : false))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
651 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
652 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
653 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
654 // We still might not have the same shape of array.
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
655
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
656 for (int i = 0; i < rank; i++)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
657 if (dims(i) != m_rn(i))
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
658 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
659 create_new_plan = true;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
660 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
661 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
662 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
663
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
664 if (create_new_plan)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
665 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
666 m_rd = dist;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
667 m_rs = stride;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
668 m_rr = rank;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
669 m_rh = howmany;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
670 m_rsimd_align = ioalign;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
671 m_rn = dims;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
672
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
673 // Note reversal of dimensions for column major storage in FFTW.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
674 octave_idx_type nn = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
675 OCTAVE_LOCAL_BUFFER (int, tmp, rank);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
676
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
677 for (int i = 0, j = rank-1; i < rank; i++, j--)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
678 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
679 tmp[i] = dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
680 nn *= dims(j);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
681 }
11586
12df7854fa7c strip trailing whitespace from source files
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
682
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
683 int plan_flags = 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
684 bool plan_destroys_in = true;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
685
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
686 switch (m_meth)
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
687 {
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
688 case UNKNOWN:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
689 case ESTIMATE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
690 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
691 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
692 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
693 case MEASURE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
694 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
695 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
696 case PATIENT:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
697 plan_flags |= FFTW_PATIENT;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
698 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
699 case EXHAUSTIVE:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
700 plan_flags |= FFTW_EXHAUSTIVE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
701 break;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
702 case HYBRID:
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
703 if (nn < 8193)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
704 plan_flags |= FFTW_MEASURE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
705 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
706 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
707 plan_flags |= FFTW_ESTIMATE;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
708 plan_destroys_in = false;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
709 }
10314
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
710 break;
07ebe522dac2 untabify liboctave C++ sources
John W. Eaton <jwe@octave.org>
parents: 10158
diff changeset
711 }
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
712
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
713 if (ioalign)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
714 plan_flags &= ~FFTW_UNALIGNED;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
715 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
716 plan_flags |= FFTW_UNALIGNED;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
717
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
718 if (*cur_plan_p)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
719 fftwf_destroy_plan (*cur_plan_p);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
720
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
721 if (plan_destroys_in)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
722 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
723 // Create matrix with the same size and 16-byte alignment as input
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
724 OCTAVE_LOCAL_BUFFER (float, itmp, nn + 32);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
725 itmp = reinterpret_cast<float *>
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
726 (((reinterpret_cast<std::ptrdiff_t> (itmp) + 15) & ~ 0xF) +
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
727 ((reinterpret_cast<std::ptrdiff_t> (in)) & 0xF));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
728
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
729 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
730 = fftwf_plan_many_dft_r2c (rank, tmp, howmany, itmp,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
731 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
732 reinterpret_cast<fftwf_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
733 nullptr, stride, dist, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
734 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
735 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
736 {
27277
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
737 *cur_plan_p
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
738 = fftwf_plan_many_dft_r2c (rank, tmp, howmany,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
739 (const_cast<float *> (in)),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
740 nullptr, stride, dist,
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
741 reinterpret_cast<fftwf_complex *> (out),
db687716fed6 style fixes: generally aim to break long lines before operators, not after
John W. Eaton <jwe@octave.org>
parents: 27032
diff changeset
742 nullptr, stride, dist, plan_flags);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
743 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
744
23795
980f39c3ab90 Use C++11 nullptr rather than 0 in code (bug #51565).
Rik <rik@octave.org>
parents: 23475
diff changeset
745 if (*cur_plan_p == nullptr)
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
746 (*current_liboctave_error_handler) ("Error creating FFTW plan");
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
747 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
748
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
749 return *cur_plan_p;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
750 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
751
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
752 float_fftw_planner::FftwMethod
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
753 float_fftw_planner::do_method (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
754 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
755 return m_meth;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
756 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
757
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
758 float_fftw_planner::FftwMethod
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
759 float_fftw_planner::do_method (FftwMethod _meth)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
760 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
761 FftwMethod ret = m_meth;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
762 if (_meth == ESTIMATE || _meth == MEASURE
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
763 || _meth == PATIENT || _meth == EXHAUSTIVE
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
764 || _meth == HYBRID)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
765 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
766 if (m_meth != _meth)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
767 {
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
768 m_meth = _meth;
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
769 if (m_rplan)
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
770 fftwf_destroy_plan (reinterpret_cast<fftwf_plan> (m_rplan));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
771 if (m_plan[0])
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
772 fftwf_destroy_plan (reinterpret_cast<fftwf_plan> (m_plan[0]));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
773 if (m_plan[1])
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
774 fftwf_destroy_plan (reinterpret_cast<fftwf_plan> (m_plan[1]));
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
775 m_rplan = m_plan[0] = m_plan[1] = nullptr;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
776 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
777 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
778 else
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
779 ret = UNKNOWN;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
780 return ret;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
781 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
782
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
783 template <typename T>
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
784 static inline void
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
785 convert_packcomplex_1d (T *out, std::size_t nr, std::size_t nc,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
786 octave_idx_type stride, octave_idx_type dist)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
787 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
788 octave_quit ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
789
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
790 // Fill in the missing data.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
791
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
792 for (std::size_t i = 0; i < nr; i++)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
793 for (std::size_t j = nc/2+1; j < nc; j++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
794 out[j*stride + i*dist] = conj (out[(nc - j)*stride + i*dist]);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
795
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
796 octave_quit ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
797 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
798
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
799 template <typename T>
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
800 static inline void
23433
c9fab0bc983e maint: Use convention 'int& x' for naming references.
Rik <rik@octave.org>
parents: 23220
diff changeset
801 convert_packcomplex_Nd (T *out, const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
802 {
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
803 std::size_t nc = dv(0);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
804 std::size_t nr = dv(1);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
805 std::size_t np = (dv.ndims () > 2 ? dv.numel () / nc / nr : 1);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
806 std::size_t nrp = nr * np;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
807 T *ptr1, *ptr2;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
808
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
809 octave_quit ();
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
810
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
811 // Create space for the missing elements.
9516
fb933db0c517 convert fftw planner classes to singleton objects
John W. Eaton <jwe@octave.org>
parents: 8920
diff changeset
812
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
813 for (std::size_t i = 0; i < nrp; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
814 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
815 ptr1 = out + i * (nc/2 + 1) + nrp*((nc-1)/2);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
816 ptr2 = out + i * nc;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
817 for (std::size_t j = 0; j < nc/2+1; j++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
818 *ptr2++ = *ptr1++;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
819 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
820
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
821 octave_quit ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
822
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
823 // Fill in the missing data for the rank = 2 case directly for speed.
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
824
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
825 for (std::size_t i = 0; i < np; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
826 {
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
827 for (std::size_t j = 1; j < nr; j++)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
828 for (std::size_t k = nc/2+1; k < nc; k++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
829 out[k + (j + i*nr)*nc] = conj (out[nc - k + ((i+1)*nr - j)*nc]);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
830
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
831 for (std::size_t j = nc/2+1; j < nc; j++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
832 out[j + i*nr*nc] = conj (out[(i*nr+1)*nc - j]);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
833 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
834
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
835 octave_quit ();
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
836
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
837 // Now do the permutations needed for rank > 2 cases.
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
838
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
839 std::size_t jstart = dv(0) * dv(1);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
840 std::size_t kstep = dv(0);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
841 std::size_t nel = dv.numel ();
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
842
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
843 for (int inner = 2; inner < dv.ndims (); inner++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
844 {
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
845 std::size_t jmax = jstart * dv(inner);
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
846 for (std::size_t i = 0; i < nel; i+=jmax)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
847 for (std::size_t j = jstart, jj = jmax-jstart; j < jj;
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
848 j+=jstart, jj-=jstart)
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
849 for (std::size_t k = 0; k < jstart; k+= kstep)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
850 for (std::size_t l = nc/2+1; l < nc; l++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
851 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
852 T tmp = out[i+ j + k + l];
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
853 out[i + j + k + l] = out[i + jj + k + l];
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
854 out[i + jj + k + l] = tmp;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
855 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
856 jstart = jmax;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
857 }
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
858
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
859 octave_quit ();
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
860 }
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
861
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
862 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
863 fftw::fft (const double *in, Complex *out, std::size_t npts,
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
864 std::size_t nsamples, octave_idx_type stride,
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
865 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
866 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
867 dist = (dist < 0 ? npts : dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
868
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
869 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
870 void *vplan = fftw_planner::create_plan (1, dv, nsamples,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
871 stride, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
872 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
873
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
874 fftw_execute_dft_r2c (m_plan, (const_cast<double *>(in)),
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
875 reinterpret_cast<fftw_complex *> (out));
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
876
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
877 // Need to create other half of the transform.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
878
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
879 convert_packcomplex_1d (out, nsamples, npts, stride, dist);
4785
d3018a33c584 [project @ 2004-02-17 21:58:17 by jwe]
jwe
parents: 4784
diff changeset
880
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
881 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
882 }
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
883
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
884 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
885 fftw::fft (const Complex *in, Complex *out, std::size_t npts,
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
886 std::size_t nsamples, octave_idx_type stride,
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
887 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
888 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
889 dist = (dist < 0 ? npts : dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
890
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
891 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
892 void *vplan = fftw_planner::create_plan (FFTW_FORWARD, 1, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
893 nsamples, stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
894 dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
895 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
896
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
897 fftw_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
898 reinterpret_cast<fftw_complex *> (const_cast<Complex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
899 reinterpret_cast<fftw_complex *> (out));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
900
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
901 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
902 }
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
903
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
904 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
905 fftw::ifft (const Complex *in, Complex *out, std::size_t npts,
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
906 std::size_t nsamples, octave_idx_type stride,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
907 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
908 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
909 dist = (dist < 0 ? npts : dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
910
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
911 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
912 void *vplan = fftw_planner::create_plan (FFTW_BACKWARD, 1, dv, nsamples,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
913 stride, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
914 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
915
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
916 fftw_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
917 reinterpret_cast<fftw_complex *> (const_cast<Complex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
918 reinterpret_cast<fftw_complex *> (out));
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
919
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
920 const Complex scale = npts;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
921 for (std::size_t j = 0; j < nsamples; j++)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
922 for (std::size_t i = 0; i < npts; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
923 out[i*stride + j*dist] /= scale;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
924
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
925 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
926 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
927
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
928 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
929 fftw::fftNd (const double *in, Complex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
930 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
931 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
932 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
933 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
934 dist *= dv(i);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
935
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
936 // Fool with the position of the start of the output matrix, so that
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
937 // creating other half of the matrix won't cause cache problems.
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
938
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
939 octave_idx_type offset = (dv.numel () / dv(0)) * ((dv(0) - 1) / 2);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
940
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
941 void *vplan = fftw_planner::create_plan (rank, dv, 1, 1, dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
942 in, out + offset);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
943 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
944
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
945 fftw_execute_dft_r2c (m_plan, (const_cast<double *>(in)),
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
946 reinterpret_cast<fftw_complex *> (out+ offset));
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
947
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
948 // Need to create other half of the transform.
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
949
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
950 convert_packcomplex_Nd (out, dv);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
951
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
952 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
953 }
4809
b60be7678bdc [project @ 2004-03-02 17:40:08 by jwe]
jwe
parents: 4808
diff changeset
954
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
955 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
956 fftw::fftNd (const Complex *in, Complex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
957 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
958 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
959 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
960 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
961 dist *= dv(i);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
962
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
963 void *vplan = fftw_planner::create_plan (FFTW_FORWARD, rank, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
964 1, 1, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
965 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
4809
b60be7678bdc [project @ 2004-03-02 17:40:08 by jwe]
jwe
parents: 4808
diff changeset
966
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
967 fftw_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
968 reinterpret_cast<fftw_complex *> (const_cast<Complex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
969 reinterpret_cast<fftw_complex *> (out));
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
970
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
971 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
972 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
973
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
974 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
975 fftw::ifftNd (const Complex *in, Complex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
976 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
977 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
978 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
979 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
980 dist *= dv(i);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
981
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
982 void *vplan = fftw_planner::create_plan (FFTW_BACKWARD, rank, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
983 1, 1, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
984 fftw_plan m_plan = reinterpret_cast<fftw_plan> (vplan);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
985
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
986 fftw_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
987 reinterpret_cast<fftw_complex *> (const_cast<Complex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
988 reinterpret_cast<fftw_complex *> (out));
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
989
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
990 const std::size_t npts = dv.numel ();
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
991 const Complex scale = npts;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
992 for (std::size_t i = 0; i < npts; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
993 out[i] /= scale;
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
994
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
995 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
996 }
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
997
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
998 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
999 fftw::fft (const float *in, FloatComplex *out, std::size_t npts,
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1000 std::size_t nsamples, octave_idx_type stride,
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1001 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1002 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1003 dist = (dist < 0 ? npts : dist);
4773
ccfbd6047a54 [project @ 2004-02-16 19:02:32 by jwe]
jwe
parents: 3874
diff changeset
1004
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1005 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1006 void *vplan = float_fftw_planner::create_plan (1, dv, nsamples, stride,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1007 dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1008 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
1009
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1010 fftwf_execute_dft_r2c (m_plan, (const_cast<float *>(in)),
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1011 reinterpret_cast<fftwf_complex *> (out));
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1012
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1013 // Need to create other half of the transform.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1014
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1015 convert_packcomplex_1d (out, nsamples, npts, stride, dist);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1016
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1017 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1018 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1019
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1020 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1021 fftw::fft (const FloatComplex *in, FloatComplex *out, std::size_t npts,
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1022 std::size_t nsamples, octave_idx_type stride,
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1023 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1024 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1025 dist = (dist < 0 ? npts : dist);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1026
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1027 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1028 void *vplan = float_fftw_planner::create_plan (FFTW_FORWARD, 1, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1029 nsamples, stride, dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1030 in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1031 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1032
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1033 fftwf_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1034 reinterpret_cast<fftwf_complex *> (const_cast<FloatComplex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1035 reinterpret_cast<fftwf_complex *> (out));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1036
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1037 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1038 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1039
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1040 int
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1041 fftw::ifft (const FloatComplex *in, FloatComplex *out, std::size_t npts,
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1042 std::size_t nsamples, octave_idx_type stride,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1043 octave_idx_type dist)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1044 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1045 dist = (dist < 0 ? npts : dist);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1046
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1047 dim_vector dv (npts, 1);
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1048 void *vplan = float_fftw_planner::create_plan (FFTW_BACKWARD, 1, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1049 nsamples, stride, dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1050 in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1051 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1052
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1053 fftwf_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1054 reinterpret_cast<fftwf_complex *> (const_cast<FloatComplex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1055 reinterpret_cast<fftwf_complex *> (out));
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1056
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1057 const FloatComplex scale = npts;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1058 for (std::size_t j = 0; j < nsamples; j++)
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1059 for (std::size_t i = 0; i < npts; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1060 out[i*stride + j*dist] /= scale;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1061
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1062 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1063 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1064
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1065 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1066 fftw::fftNd (const float *in, FloatComplex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1067 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1068 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1069 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1070 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1071 dist *= dv(i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1072
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1073 // Fool with the position of the start of the output matrix, so that
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1074 // creating other half of the matrix won't cause cache problems.
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1075
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1076 octave_idx_type offset = (dv.numel () / dv(0)) * ((dv(0) - 1) / 2);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1077
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1078 void *vplan = float_fftw_planner::create_plan (rank, dv, 1, 1, dist,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1079 in, out + offset);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1080 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1081
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1082 fftwf_execute_dft_r2c (m_plan, (const_cast<float *>(in)),
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1083 reinterpret_cast<fftwf_complex *> (out+ offset));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1084
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1085 // Need to create other half of the transform.
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1086
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1087 convert_packcomplex_Nd (out, dv);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1088
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1089 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1090 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1091
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1092 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1093 fftw::fftNd (const FloatComplex *in, FloatComplex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1094 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1095 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1096 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1097 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1098 dist *= dv(i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1099
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1100 void *vplan = float_fftw_planner::create_plan (FFTW_FORWARD, rank, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1101 1, 1, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1102 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1103
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1104 fftwf_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1105 reinterpret_cast<fftwf_complex *> (const_cast<FloatComplex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1106 reinterpret_cast<fftwf_complex *> (out));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1107
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1108 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1109 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1110
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1111 int
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1112 fftw::ifftNd (const FloatComplex *in, FloatComplex *out, const int rank,
25103
078b795c5219 maint: style check C++ ahead of 4.4 release.
Rik <rik@octave.org>
parents: 25054
diff changeset
1113 const dim_vector& dv)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1114 {
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1115 octave_idx_type dist = 1;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1116 for (int i = 0; i < rank; i++)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1117 dist *= dv(i);
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1118
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1119 void *vplan = float_fftw_planner::create_plan (FFTW_BACKWARD, rank, dv,
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1120 1, 1, dist, in, out);
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1121 fftwf_plan m_plan = reinterpret_cast<fftwf_plan> (vplan);
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1122
30102
eb10871a5882 maint: use "m_" prefix for member variables in class fftw_planner.
Rik <rik@octave.org>
parents: 29572
diff changeset
1123 fftwf_execute_dft (m_plan,
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1124 reinterpret_cast<fftwf_complex *> (const_cast<FloatComplex *>(in)),
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1125 reinterpret_cast<fftwf_complex *> (out));
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1126
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1127 const std::size_t npts = dv.numel ();
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1128 const FloatComplex scale = npts;
29572
aef11bb4e6d1 use std::size_t and std::ptrdiff_t in C++ code (bug #60471)
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
1129 for (std::size_t i = 0; i < npts; i++)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1130 out[i] /= scale;
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1131
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1132 return 0;
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1133 }
7789
82be108cc558 First attempt at single precision tyeps
David Bateman <dbateman@free.fr>
parents: 7017
diff changeset
1134
3828
adc217ebe692 [project @ 2001-05-02 14:50:46 by jwe]
jwe
parents:
diff changeset
1135 #endif
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21520
diff changeset
1136
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1137 std::string
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1138 fftw_version (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1139 {
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21520
diff changeset
1140 #if defined (HAVE_FFTW)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1141 return ::fftw_version;
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21520
diff changeset
1142 #else
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1143 return "none";
21600
184b85b31e03 more updates for version function
mmuetzel <markus.muetzel@gmx.de>
parents: 21520
diff changeset
1144 #endif
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1145 }
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1146
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1147 std::string
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1148 fftwf_version (void)
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1149 {
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1150 #if defined (HAVE_FFTW)
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1151 return ::fftwf_version;
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1152 #else
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1153 return "none";
21603
37cbdf7bffa9 Add fftwf_version (bug #45659)
mmuetzel <markus.muetzel@gmx.de>
parents: 21600
diff changeset
1154 #endif
23058
5839d16828cb move fftw classes inside octave namespace
John W. Eaton <jwe@octave.org>
parents: 22755
diff changeset
1155 }
31605
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31184
diff changeset
1156
e88a07dec498 maint: Use macros to begin/end C++ namespaces.
Rik <rik@octave.org>
parents: 31184
diff changeset
1157 OCTAVE_END_NAMESPACE(octave)