[Numpy-discussion] numpy.fft.rfftn -> non-contiguous

Pierre Thibault thibault at physics.cornell.edu
Fri Dec 1 23:09:32 EST 2006


Hello!

I'm a little confused about what rfftn is doing: It seems to me that
the best would be for it to return a C-contiguous array with the first
element reduced by a half (plus one), so that one can easily obtain
the non-repeated slices.

What I get is the following:

In [1]: from numpy import *

In [2]: a = random.rand(8,8,8)

In [3]: fa = fft.rfftn(a)

In [4]: fa.shape
Out[4]: (8, 8, 5)

In [5]: fa.flags
Out[5]:
  CONTIGUOUS : False
  FORTRAN : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

In [6]: fa.swapaxes(-1,-2).flags
Out[6]:
  CONTIGUOUS : True
  FORTRAN : False
  OWNDATA : False
  WRITEABLE : True
  ALIGNED : True
  UPDATEIFCOPY : False

What I would like to have is

fa.shape: (5,8,8)
fa.flags: CONTIGUOUS = True

So, now fa[0] is a contiguous block containing the data that is not
supposed to appear twice in the complex fft (that is, it would be nice
if fft.rfftn(a)[0] == fft.fftn(a)[0]).

I tried playing with the axes argument in rfftn, to no avail. I can do
without, but at least it looks kind of ugly to me that the array
returned by a built-in function is not contiguous.

By the way, I am using the official debian unstable numpy package. It
doesn't look like it is using fftw, and I don't know if any of this
behaviour would be different if I had compiled numpy by myself - I am
not even sure using fftw is an option with numpy.

Thanks for any answer/comments on that!

Pierre

-- 
Pierre Thibault
616 Clark Hall, Cornell University
(607) 255-5522



More information about the NumPy-Discussion mailing list