fft.py 1.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
# Copyright(C) 2013-2019 Max-Planck-Society
#
# NIFTy is being developed at the Max-Planck-Institut fuer Astrophysik.

18
import pypocketfft
19

Martin Reinecke's avatar
Martin Reinecke committed
20
_nthreads = 1
21

Martin Reinecke's avatar
Martin Reinecke committed
22

Martin Reinecke's avatar
Martin Reinecke committed
23
24
def nthreads():
    return _nthreads
Martin Reinecke's avatar
Martin Reinecke committed
25
26


Martin Reinecke's avatar
Martin Reinecke committed
27
28
29
def set_nthreads(nthr):
    global _nthreads
    _nthreads = nthr
Martin Reinecke's avatar
Martin Reinecke committed
30
31


Martin Reinecke's avatar
Martin Reinecke committed
32
def fftn(a, axes=None):
33
    return pypocketfft.c2c(a, axes=axes, nthreads=_nthreads)
Martin Reinecke's avatar
Martin Reinecke committed
34
35
36


def ifftn(a, axes=None):
37
38
    return pypocketfft.c2c(a, axes=axes, inorm=2, forward=False,
                           nthreads=_nthreads)
39
40
41


def hartley(a, axes=None):
42
    return pypocketfft.genuine_hartley(a, axes=axes, nthreads=_nthreads)