mpi4py_fft.fftw package¶
Submodules¶
mpi4py_fft.fftw.fftw_xfftn module¶
-
class
mpi4py_fft.fftw.fftw_xfftn.
FFT
¶ Bases:
object
Unified class for FFTs of multidimensional arrays
This class is used for any type of transform defined in the user manual of FFTW.
- Parameters
input_array (array) – real or complex input array
output_array (array) – real or complex output array
axes (sequence of ints, optional) – The axes to transform over, starting from the last
kind (int or sequence of ints, optional) –
Any one of
FFTW_FORWARD (-1)
FFTW_R2HC (0)
FFTW_BACKWARD (1)
FFTW_HC2R (1)
FFTW_DHT (2)
FFTW_REDFT00 (3)
FFTW_REDFT01 (4)
FFTW_REDFT10 (5)
FFTW_REDFT11 (6)
FFTW_RODFT00 (7)
FFTW_RODFT01 (8)
FFTW_RODFT10 (9)
FFTW_RODFT11 (10)
threads (int, optional) – Number of threads to use in transforms
flags (int or sequence of ints, optional) –
Any one of, but not necessarily for all transforms or all combinations
FFTW_MEASURE (0)
FFTW_DESTROY_INPUT (1)
FFTW_UNALIGNED (2)
FFTW_CONSERVE_MEMORY (4)
FFTW_EXHAUSTIVE (8)
FFTW_PRESERVE_INPUT (16)
FFTW_PATIENT (32)
FFTW_ESTIMATE (64)
FFTW_WISDOM_ONLY (2097152)
normalization (float, optional) – Normalization factor
-
__call__
()¶ Signature:
__call__(input_array=None, output_array=None, implicit=True, normalize=False, **kw)
Compute transform and return output array
- Parameters
input_array (array, optional) – If not provided, then use internally stored array
output_array (array, optional) – If not provided, then use internally stored array
implicit (bool, optional) – If True, then use an implicit method that acts by applying the plan directly on the given input array. If False, then use an explicit method that first copies the given input_array into the internal _input_array. The explicit method is generally safer, because it always preserves the provided input_array. The implicit method can be faster because it may be done without any copying. However, the contents of the input_array may be destroyed during computation. So use with care!
normalize (bool, optional) – If True, normalize transform with internally stored normalization factor. The internally set normalization factor is possible to obtain through
FFT.get_normalization()
kw (dict, optional)
Note
If the transform has been planned with FFTW_PRESERVE_INPUT, then both the two methods (implicit=True/False) will preserve the provided input_array. If not planned with this flag, then the implicit=True method may cause the input_array to be overwritten during computation.
-
destroy
()¶
-
get_normalization
()¶ Return the internally set normalization factor
-
input_array
¶
-
output_array
¶
-
print_plan
()¶
-
update_arrays
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
alignment_of
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
cleanup
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
export_wisdom
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
forget_wisdom
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
import_wisdom
()¶
-
mpi4py_fft.fftw.fftw_xfftn.
set_timelimit
()¶
mpi4py_fft.fftw.fftwf_xfftn module¶
-
class
mpi4py_fft.fftw.fftwf_xfftn.
FFT
¶ Bases:
object
Unified class for FFTs of multidimensional arrays
This class is used for any type of transform defined in the user manual of FFTW.
- Parameters
input_array (array) – real or complex input array
output_array (array) – real or complex output array
axes (sequence of ints, optional) – The axes to transform over, starting from the last
kind (int or sequence of ints, optional) –
Any one of
FFTW_FORWARD (-1)
FFTW_R2HC (0)
FFTW_BACKWARD (1)
FFTW_HC2R (1)
FFTW_DHT (2)
FFTW_REDFT00 (3)
FFTW_REDFT01 (4)
FFTW_REDFT10 (5)
FFTW_REDFT11 (6)
FFTW_RODFT00 (7)
FFTW_RODFT01 (8)
FFTW_RODFT10 (9)
FFTW_RODFT11 (10)
threads (int, optional) – Number of threads to use in transforms
flags (int or sequence of ints, optional) –
Any one of, but not necessarily for all transforms or all combinations
FFTW_MEASURE (0)
FFTW_DESTROY_INPUT (1)
FFTW_UNALIGNED (2)
FFTW_CONSERVE_MEMORY (4)
FFTW_EXHAUSTIVE (8)
FFTW_PRESERVE_INPUT (16)
FFTW_PATIENT (32)
FFTW_ESTIMATE (64)
FFTW_WISDOM_ONLY (2097152)
normalization (float, optional) – Normalization factor
-
__call__
()¶ Signature:
__call__(input_array=None, output_array=None, implicit=True, normalize=False, **kw)
Compute transform and return output array
- Parameters
input_array (array, optional) – If not provided, then use internally stored array
output_array (array, optional) – If not provided, then use internally stored array
implicit (bool, optional) – If True, then use an implicit method that acts by applying the plan directly on the given input array. If False, then use an explicit method that first copies the given input_array into the internal _input_array. The explicit method is generally safer, because it always preserves the provided input_array. The implicit method can be faster because it may be done without any copying. However, the contents of the input_array may be destroyed during computation. So use with care!
normalize (bool, optional) – If True, normalize transform with internally stored normalization factor. The internally set normalization factor is possible to obtain through
FFT.get_normalization()
kw (dict, optional)
Note
If the transform has been planned with FFTW_PRESERVE_INPUT, then both the two methods (implicit=True/False) will preserve the provided input_array. If not planned with this flag, then the implicit=True method may cause the input_array to be overwritten during computation.
-
destroy
()¶
-
get_normalization
()¶ Return the internally set normalization factor
-
input_array
¶
-
output_array
¶
-
print_plan
()¶
-
update_arrays
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
alignment_of
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
cleanup
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
export_wisdom
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
forget_wisdom
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
import_wisdom
()¶
-
mpi4py_fft.fftw.fftwf_xfftn.
set_timelimit
()¶
mpi4py_fft.fftw.fftwl_xfftn module¶
-
class
mpi4py_fft.fftw.fftwl_xfftn.
FFT
¶ Bases:
object
Unified class for FFTs of multidimensional arrays
This class is used for any type of transform defined in the user manual of FFTW.
- Parameters
input_array (array) – real or complex input array
output_array (array) – real or complex output array
axes (sequence of ints, optional) – The axes to transform over, starting from the last
kind (int or sequence of ints, optional) –
Any one of
FFTW_FORWARD (-1)
FFTW_R2HC (0)
FFTW_BACKWARD (1)
FFTW_HC2R (1)
FFTW_DHT (2)
FFTW_REDFT00 (3)
FFTW_REDFT01 (4)
FFTW_REDFT10 (5)
FFTW_REDFT11 (6)
FFTW_RODFT00 (7)
FFTW_RODFT01 (8)
FFTW_RODFT10 (9)
FFTW_RODFT11 (10)
threads (int, optional) – Number of threads to use in transforms
flags (int or sequence of ints, optional) –
Any one of, but not necessarily for all transforms or all combinations
FFTW_MEASURE (0)
FFTW_DESTROY_INPUT (1)
FFTW_UNALIGNED (2)
FFTW_CONSERVE_MEMORY (4)
FFTW_EXHAUSTIVE (8)
FFTW_PRESERVE_INPUT (16)
FFTW_PATIENT (32)
FFTW_ESTIMATE (64)
FFTW_WISDOM_ONLY (2097152)
normalization (float, optional) – Normalization factor
-
__call__
()¶ Signature:
__call__(input_array=None, output_array=None, implicit=True, normalize=False, **kw)
Compute transform and return output array
- Parameters
input_array (array, optional) – If not provided, then use internally stored array
output_array (array, optional) – If not provided, then use internally stored array
implicit (bool, optional) – If True, then use an implicit method that acts by applying the plan directly on the given input array. If False, then use an explicit method that first copies the given input_array into the internal _input_array. The explicit method is generally safer, because it always preserves the provided input_array. The implicit method can be faster because it may be done without any copying. However, the contents of the input_array may be destroyed during computation. So use with care!
normalize (bool, optional) – If True, normalize transform with internally stored normalization factor. The internally set normalization factor is possible to obtain through
FFT.get_normalization()
kw (dict, optional)
Note
If the transform has been planned with FFTW_PRESERVE_INPUT, then both the two methods (implicit=True/False) will preserve the provided input_array. If not planned with this flag, then the implicit=True method may cause the input_array to be overwritten during computation.
-
destroy
()¶
-
get_normalization
()¶ Return the internally set normalization factor
-
input_array
¶
-
output_array
¶
-
print_plan
()¶
-
update_arrays
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
alignment_of
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
cleanup
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
export_wisdom
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
forget_wisdom
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
import_wisdom
()¶
-
mpi4py_fft.fftw.fftwl_xfftn.
set_timelimit
()¶
mpi4py_fft.fftw.factory module¶
-
mpi4py_fft.fftw.factory.
export_wisdom
(filename)[source]¶ Export FFTW wisdom
- Parameters
filename (str) – Name of file used to export wisdom to
Note
Wisdom is stored for all precisions available: float, double and long double, using, respectively, prefix
Fn_
,Dn_
andGn_
, where n is the rank of the processor. Wisdom is imported usingimport_wisdom()
, which must be called with the same MPI configuration as used withexport_wisdom()
.See also
-
mpi4py_fft.fftw.factory.
get_fftw_lib
(dtype)[source]¶ Return compiled fftw module interfacing the FFTW library
- Parameters
dtype (dtype) – Data precision
- Returns
Module can be either
fftwf_xfftn
,fftw_xfftn
orfftwl_xfftn
, depending on precision.- Return type
Module or
None
-
mpi4py_fft.fftw.factory.
get_planned_FFT
(input_array, output_array, axes=(- 1), kind=- 1, threads=1, flags=(0), normalization=1.0)[source]¶ Return instance of transform class
- Parameters
input_array (array) – real or complex input array
output_array (array) – real or complex output array
axes (sequence of ints, optional) – The axes to transform over, starting from the last
kind (int or sequence of ints, optional) –
Any one of (or possibly several for real-to-real)
FFTW_FORWARD (-1)
FFTW_R2HC (0)
FFTW_BACKWARD (1)
FFTW_HC2R (1)
FFTW_DHT (2)
FFTW_REDFT00 (3)
FFTW_REDFT01 (4)
FFTW_REDFT10 (5)
FFTW_REDFT11 (6)
FFTW_RODFT00 (7)
FFTW_RODFT01 (8)
FFTW_RODFT10 (9)
FFTW_RODFT11 (10)
threads (int, optional) – Number of threads to use in transforms
flags (int or sequence of ints, optional) –
Any one of, but not necessarily for all transforms or all combinations
FFTW_MEASURE (0)
FFTW_DESTROY_INPUT (1)
FFTW_UNALIGNED (2)
FFTW_CONSERVE_MEMORY (4)
FFTW_EXHAUSTIVE (8)
FFTW_PRESERVE_INPUT (16)
FFTW_PATIENT (32)
FFTW_ESTIMATE (64)
FFTW_WISDOM_ONLY (2097152)
normalization (float, optional) – Normalization factor
- Returns
An instance of the return type configured for the desired transforms
- Return type
-
mpi4py_fft.fftw.factory.
import_wisdom
(filename)[source]¶ Import FFTW wisdom
- Parameters
filename (str) – Name of file used to import wisdom from
Note
Wisdom is imported for all available precisions: float, double and long double, using, respectively, prefix
Fn_
,Dn_
andGn_
, where n is the rank of the processor. Wisdom is exported usingexport_wisdom()
. Note that importing wisdom only works when using the same MPI configuration as used withexport_wisdom()
.See also
mpi4py_fft.fftw.utilities module¶
-
mpi4py_fft.fftw.utilities.
aligned
()¶ Returned array with byte-alignment according to n
- Parameters
shape (sequence of ints) – The shape of the array to be created
n (int, optional) – The chosen byte-alignment
dtype (np.dtype, optional) – The type of the returned array
fill (None or number, optional) – If number then fill returned array with this number, otherwise return empty array
- Returns
byte-aligned array
- Return type
array
-
mpi4py_fft.fftw.utilities.
aligned_like
()¶ Return array with byte-alignment, shape and type like array z
- Parameters
z (array) – An array with shape and type we want to recreate
fill (None or number, optional) – If number then fill returned array with this number, otherwise return empty array
- Returns
byte-aligned array
- Return type
array
-
mpi4py_fft.fftw.utilities.
get_alignment
()¶ Return alignment assuming highest allowed is 32
- Parameters
array (array)
mpi4py_fft.fftw.xfftn module¶
-
mpi4py_fft.fftw.xfftn.
dctn
(input_array, s=None, axes=(- 1), type=2, threads=1, flags=(0), output_array=None)[source]¶ Return discrete cosine transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the real-to-real dct.
type (int, optional) –
Type of dct
1 - FFTW_REDFT00
2 - FFTW_REDFT10,
3 - FFTW_REDFT01,
4 - FFTW_REDFT11
threads (int, optional) – Number of threads used in computing dct.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-real dct transforms of given type
- Return type
Note
This routine does not compute the dct, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import dctn as plan_dct >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> dct = plan_dct(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = dct() >>> print(B) [20. -6.30864406 0. -0.44834153] >>> assert id(A) == id(dct.input_array) >>> assert id(B) == id(dct.output_array)
-
mpi4py_fft.fftw.xfftn.
dstn
(input_array, s=None, axes=(- 1), type=2, threads=1, flags=(0), output_array=None)[source]¶ Return discrete sine transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the real-to-real dst.
type (int, optional) –
Type of dst
1 - FFTW_RODFT00
2 - FFTW_RODFT10
3 - FFTW_RODFT01
4 - FFTW_RODFT11
threads (int, optional) – Number of threads used in computing dst.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-real dst transforms of given type
- Return type
Note
This routine does not compute the dst, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import dstn as plan_dst >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> dst = plan_dst(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = dst() >>> print(B) [13.06562965 -5.65685425 5.411961 -4. ] >>> assert id(A) == id(dst.input_array) >>> assert id(B) == id(dst.output_array)
-
mpi4py_fft.fftw.xfftn.
fftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return complex-to-complex forward transform object
- Parameters
input_array (complex array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the FFT.
threads (int, optional) – Number of threads used in computing FFT.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (complex array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for complex-to-complex transforms
- Return type
Note
This routine does not compute the fftn, it merely returns an instance of a class that can do it. The contents of the input_array may be overwritten during planning. Make sure to keep a copy if needed.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import fftn as plan_fftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='D') >>> fftn = plan_fftn(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = fftn() >>> print(B) [10.+0.j -2.+2.j -2.+0.j -2.-2.j] >>> assert id(A) == id(fftn.input_array) >>> assert id(B) == id(fftn.output_array)
-
mpi4py_fft.fftw.xfftn.
get_normalization
(kind, shape, axes)[source]¶ Return normalization factor for multidimensional transform
The normalization factor is, for Fourier transforms:
1./np.prod(np.take(shape, axes))
where shape is the global shape of the array that is input to the forward transform, and axes are the axes transformed over.
For real-to-real transforms the normalization factor for each axis is
REDFT00 - 2(N-1)
REDFT01 - 2N
REDFT10 - 2N
REDFT11 - 2N
RODFT00 - 2(N+1)
RODFT01 - 2N
RODFT10 - 2N
RODFT11 - 2N
where N is the length of the input array along that axis.
- Parameters
kind (sequence of ints) – The kind of transform along each axis
shape (sequence of ints) – The shape of the global transformed array (input to the forward transform)
axes (sequence of ints) – The axes transformed over
Note
The returned normalization factor is the inverse of the product of the normalization factors for the axes it is transformed over.
-
mpi4py_fft.fftw.xfftn.
hfftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return transform object for an array with Hermitian symmetry
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the hfftn.
threads (int, optional) – Number of threads used in computing hfftn.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for complex-to-real hfftn transforms
- Return type
Note
This routine does not compute the hfttn, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import hfftn as plan_hfftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='D') >>> hfftn = plan_hfftn(A, flags=(FFTW_ESTIMATE,)) # no shape given for output >>> A[:] = 1, 2, 3, 4 >>> B = hfftn() >>> print(B) [15. -4. 0. -1. 0. -4.] >>> hfftn = plan_hfftn(A, s=(7,), flags=(FFTW_ESTIMATE,)) # output shape given >>> B = hfftn() >>> print(B) [19. -5.04891734 -0.30797853 -0.64310413 -0.64310413 -0.30797853 -5.04891734] >>> assert id(B) == id(hfftn.output_array) >>> assert id(A) == id(hfftn.input_array)
-
mpi4py_fft.fftw.xfftn.
idctn
(input_array, s=None, axes=(- 1), type=2, threads=1, flags=(0), output_array=None)[source]¶ Return inverse discrete cosine transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the real-to-real idct.
type (int, optional) –
Type of idct
1 - FFTW_REDFT00
2 - FFTW_REDFT01
3 - FFTW_REDFT10
4 - FFTW_REDFT11
threads (int, optional) – Number of threads used in computing idct.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-real idct transforms of given type
- Return type
Note
This routine does not compute the idct, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import idctn as plan_idct >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> idct = plan_idct(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = idct() >>> print(B) [11.99962628 -9.10294322 2.61766184 -1.5143449 ] >>> assert id(A) == id(idct.input_array) >>> assert id(B) == id(idct.output_array)
-
mpi4py_fft.fftw.xfftn.
idstn
(input_array, s=None, axes=(- 1), type=2, threads=1, flags=(0), output_array=None)[source]¶ Return inverse discrete sine transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the real-to-real inverse dst.
type (int, optional) –
Type of idst
1 - FFTW_RODFT00
2 - FFTW_RODFT01
3 - FFTW_RODFT10
4 - FFTW_RODFT11
threads (int, optional) – Number of threads used in computing inverse dst.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-real idst transforms of given type
- Return type
Note
This routine does not compute the idst, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import idstn as plan_idst >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> idst = plan_idst(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = idst() >>> print(B) [13.13707118 -1.6199144 0.72323135 -0.51978306] >>> assert id(A) == id(idst.input_array) >>> assert id(B) == id(idst.output_array)
-
mpi4py_fft.fftw.xfftn.
ifftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return complex-to-complex inverse transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the inverse FFT.
threads (int, optional) – Number of threads used in computing FFT.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for complex-to-complex inverse transforms
- Return type
Note
This routine does not compute the ifftn, it merely returns an instance of a class that can do it. The contents of the input_array may be overwritten during planning. Make sure that you keep a copy if needed.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import ifftn as plan_ifftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, FFTW_PRESERVE_INPUT, aligned >>> A = aligned(4, dtype='D') >>> ifftn = plan_ifftn(A, flags=(FFTW_ESTIMATE, FFTW_PRESERVE_INPUT)) >>> A[:] = 1, 2, 3, 4 >>> B = ifftn() >>> print(B) [10.+0.j -2.-2.j -2.+0.j -2.+2.j] >>> assert id(B) == id(ifftn.output_array) >>> assert id(A) == id(ifftn.input_array)
-
mpi4py_fft.fftw.xfftn.
ihfftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return inverse transform object for an array with Hermitian symmetry
- Parameters
input_array (array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the ihfftn.
threads (int, optional) – Number of threads used in computing ihfftn.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-complex ihfftn transforms
- Return type
Note
This routine does not compute the ihfttn, it merely returns an instance of a class that can do it.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import ihfftn as plan_ihfftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> ihfftn = plan_ihfftn(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = ihfftn() >>> print(B) [10.+0.j -2.+2.j -2.+0.j] >>> assert id(A) == id(ihfftn.input_array) >>> assert id(B) == id(ihfftn.output_array)
-
mpi4py_fft.fftw.xfftn.
irfftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return inverse complex-to-real transform object
- Parameters
input_array (array)
s (sequence of ints, optional) – Shape of output array along each of the transformed axes. Must be same length as axes (len(s) == len(axes)). If not given it is assumed that the shape of the output along the first transformed axis (i.e., axes[-1]) is an even number. It is not possible to determine exactly, because for a real transform the output of a real array of length N is N//2+1. However, both N=4 and N=5 gives 4//2+1=3 and 5//2+1=3, so it is not possible to determine whether 4 or 5 is correct. Hence it must be given.
axes (sequence of ints, optional) – Axes over which to compute the real to complex FFT.
threads (int, optional) – Number of threads used in computing FFT.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for complex-to-real transforms
- Return type
Note
This routine does not compute the irfftn, it merely returns an instance of a class that can do it. The irfftn is not possible to use with the FFTW_PRESERVE_INPUT flag.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import irfftn as plan_irfftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='D') >>> irfftn = plan_irfftn(A, flags=(FFTW_ESTIMATE,)) # no shape given for output >>> A[:] = 1, 2, 3, 4 >>> B = irfftn() >>> print(B) [15. -4. 0. -1. 0. -4.] >>> irfftn = plan_irfftn(A, s=(7,), flags=(FFTW_ESTIMATE,)) # output shape given >>> B = irfftn() >>> print(B) [19. -5.04891734 -0.30797853 -0.64310413 -0.64310413 -0.30797853 -5.04891734] >>> assert id(B) == id(irfftn.output_array) >>> assert id(A) == id(irfftn.input_array)
-
mpi4py_fft.fftw.xfftn.
rfftn
(input_array, s=None, axes=(- 1), threads=1, flags=(0), output_array=None)[source]¶ Return real-to-complex transform object
- Parameters
input_array (real array)
s (sequence of ints, optional) – Not used - included for compatibility with Numpy
axes (sequence of ints, optional) – Axes over which to compute the real to complex FFT.
threads (int, optional) – Number of threads used in computing FFT.
flags (sequence of ints, optional) –
Flags from
FFTW_MEASURE
FFTW_EXHAUSTIVE
FFTW_PATIENT
FFTW_DESTROY_INPUT
FFTW_PRESERVE_INPUT
FFTW_UNALIGNED
FFTW_CONSERVE_MEMORY
FFTW_ESTIMATE
output_array (array, optional) – Array to be used as output array. Must be of correct shape, type, strides and alignment
- Returns
An instance of the return type configured for real-to-complex transforms
- Return type
Note
This routine does not compute the rfftn, it merely returns an instance of a class that can do it. The contents of the input_array may be overwritten during planning. Make sure that you keep a copy if needed.
Examples
>>> import numpy as np >>> from mpi4py_fft.fftw import rfftn as plan_rfftn >>> from mpi4py_fft.fftw import FFTW_ESTIMATE, aligned >>> A = aligned(4, dtype='d') >>> rfftn = plan_rfftn(A, flags=(FFTW_ESTIMATE,)) >>> A[:] = 1, 2, 3, 4 >>> B = rfftn() >>> print(B) [10.+0.j -2.+2.j -2.+0.j] >>> assert id(A) == id(rfftn.input_array) >>> assert id(B) == id(rfftn.output_array)