def ifft(af, a=None, inplace=0, nthreads=1): #CHECK b type size global shape, s2 if inplace: inplace = _dfftw.FFTW_IN_PLACE # == 8 shape = af.shape else: shape = af.shape inplace = 0 dir = _sfftw.FFTW_BACKWARD if af.dtype == _N.complex64: if a is not None and (not a.flags.carray or a.dtype != _N.complex64): raise RuntimeError("a needs to be well behaved complex64 array") key = ("si%d" % inplace, shape) try: p = _splans[key] except: p = _sfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError("could not create plan") _splans[key] = p if inplace: _sfftw.fftwnd_one(p, af, None) if a is None: s2 = shape a = _N.ndarray(buffer=af, shape=s2, dtype=_N.complex64) return a else: if a is None: s2 = shape a = _N.empty(shape=s2, dtype=_N.complex64) _sfftw.fftwnd_one(p, af, a) return a else: _sfftw.fftwnd_one(p, af, a) elif af.dtype == _N.complex128: if a is not None and (not a.flags.carray or a.dtype != _N.complex128): raise RuntimeError("a needs to be well behaved complex128 array") key = ("di%d" % inplace, shape) try: p = _dplans[key] except: p = _dfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError("could not create plan") _dplans[key] = p if inplace: _dfftw.fftwnd_one(p, af, None) if a is None: s2 = shape a = _N.ndarray(buffer=af, shape=s2, dtype=_N.complex128) return a else: if a is None: s2 = shape a = _N.empty(shape=s2, dtype=_N.complex128) _dfftw.fftwnd_one(p, af, a) return a else: _dfftw.fftwnd_one(p, af, a) else: raise TypeError("complex64 and complex128 must be used consistently (%s %s)"%\ ((a is None and "a is None" or "a.dtype=%s"%a.dtype), (af is None and "af is None" or "af.dtype=%s"%af.dtype)))
def ifft(af, a=None, inplace=0): #CHECK b type size global shape,s2 if inplace: inplace = _dfftw.FFTW_IN_PLACE # == 8 shape = af.shape else: shape = af.shape inplace = 0 dir = _sfftw.FFTW_BACKWARD if af.dtype == _N.complex64: if a is not None and (not a.flags.carray or a.dtype != _N.complex64): raise RuntimeError, "a needs to be well behaved complex64 array" key = ("si%d"%inplace, shape ) try: p = _splans[ key ] except: p = _sfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError, "could not create plan" _splans[ key ] = p if inplace: _sfftw.fftwnd_one(p,af,None) if a is None: s2 = shape a = _N.ndarray(buffer=af, shape=s2,dtype=_N.complex64) return a else: if a is None: s2 = shape a = _N.empty(shape=s2, dtype=_N.complex64) _sfftw.fftwnd_one(p,af,a) return a else: _sfftw.fftwnd_one(p,af,a) elif af.dtype == _N.complex128: if a is not None and (not a.flags.carray or a.dtype != _N.complex128): raise RuntimeError, "a needs to be well behaved complex128 array" key = ("di%d"%inplace, shape ) try: p = _dplans[ key ] except: p = _dfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError, "could not create plan" _dplans[ key ] = p if inplace: _dfftw.fftwnd_one(p,af,None) if a is None: s2 = shape a = _N.ndarray(buffer=af, shape=s2,dtype=_N.complex128) return a else: if a is None: s2 = shape a = _N.empty(shape=s2, dtype=_N.complex128) _dfftw.fftwnd_one(p,af,a) return a else: _dfftw.fftwnd_one(p,af,a) else: raise TypeError, "complex64 and complex128 must be used consistently (%s %s)"%\ ((a is None and "a is None" or "a.dtype=%s"%a.dtype), (af is None and "af is None" or "af.dtype=%s"%af.dtype))
def fft(a, af=None, inplace=0): #CHECK b type size if inplace: inplace = _sfftw.FFTW_IN_PLACE # == 8 shape = a.shape else: shape = a.shape inplace = 0 dir = _sfftw.FFTW_FORWARD if a.dtype == _N.complex64: if af is not None and (not af.flags.carray or af.dtype != _N.complex64): raise RuntimeError, "af needs to be well behaved complex64 array" key = ("s%d" % inplace, shape) try: p = _splans[key] except: p = _sfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError, "could not create plan" _splans[key] = p if inplace: _sfftw.fftwnd_one(p, a, None) if af is None: s2 = shape af = _N.ndarray(buffer=a, shape=s2, dtype=_N.complex64) return af else: if af is None: s2 = shape af = _N.empty(shape=s2, dtype=_N.complex64) _sfftw.fftwnd_one(p, a, af) return af else: _sfftw.fftwnd_one(p, a, af) elif a.dtype == _N.complex128: if af is not None and (not af.flags.carray or af.dtype != _N.complex128): raise RuntimeError, "af needs to be well behaved complex128 array" key = ("d%d" % inplace, shape) try: p = _dplans[key] except: p = _dfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError, "could not create plan" _dplans[key] = p if inplace: _dfftw.fftwnd_one(p, a, None) if af is None: s2 = shape af = _N.ndarray(buffer=a, shape=s2, dtype=_N.complex128) return af else: if af is None: s2 = shape af = _N.empty(shape=s2, dtype=_N.complex128) _dfftw.fftwnd_one(p, a, af) return af else: _dfftw.fftwnd_one(p, a, af) else: raise TypeError, "complex64 and complex128 must be used consistently (%s %s)"%\ ((a is None and "a is None" or "a.dtype=%s"%a.dtype), (af is None and "af is None" or "af.dtype=%s"%af.dtype))
def fft(a,af=None, inplace=0, nthreads=1): #CHECK b type size if inplace: inplace = _sfftw.FFTW_IN_PLACE # == 8 shape = a.shape else: shape = a.shape inplace = 0 dir = _sfftw.FFTW_FORWARD if a.dtype == _N.complex64: if af is not None and (not af.flags.carray or af.dtype != _N.complex64): raise RuntimeError("af needs to be well behaved complex64 array") key = ("s%d"%inplace, shape ) try: p = _splans[ key ] except: p = _sfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError("could not create plan") _splans[ key ] = p if inplace: _sfftw.fftwnd_one(p,a,None) if af is None: s2 = shape af = _N.ndarray(buffer=a, shape=s2, dtype=_N.complex64) return af else: if af is None: s2 = shape af = _N.empty(shape=s2, dtype=_N.complex64) _sfftw.fftwnd_one(p,a,af) return af else: _sfftw.fftwnd_one(p,a,af) elif a.dtype == _N.complex128: if af is not None and (not af.flags.carray or af.dtype != _N.complex128): raise RuntimeError("af needs to be well behaved complex128 array") key = ("d%d"%inplace, shape ) try: p = _dplans[ key ] except: p = _dfftw.fftwnd_create_plan(len(shape), _N.array(shape, dtype=_N.int32), dir, _measure | inplace) if p is None: raise RuntimeError("could not create plan") _dplans[ key ] = p if inplace: _dfftw.fftwnd_one(p,a,None) if af is None: s2 = shape af = _N.ndarray(buffer=a, shape=s2,dtype=_N.complex128) return af else: if af is None: s2 = shape af = _N.empty(shape=s2, dtype=_N.complex128) _dfftw.fftwnd_one(p,a,af) return af else: _dfftw.fftwnd_one(p,a,af) else: raise TypeError("complex64 and complex128 must be used consistently (%s %s)"%\ ((a is None and "a is None" or "a.dtype=%s"%a.dtype), (af is None and "af is None" or "af.dtype=%s"%af.dtype)))