Michael Cohen | 1 Mar 05:53
Picon
Favicon

Numpy/Scipy rfft transformations do not match?

Hi all,
Relatively new Scipy/numpy user.
I have been trying to switch from numpy.fft.rfft calls to 
scipy.fftpack.rfft calls in order to make use of fftw3, but I find that 
the array sizes are different.

With numpy, the size of the resulting array is n/2+1 where n is the size 
of the original array.  With scipy, the array has length n.
Additionally, scipy takes twice as long to compute the fft as numpy, 
presumably because it is computing twice as many values.
Is there a reason for this discrepancy?  What do I need to call from 
scipy to make the calls match?

Additionally, how do I check in a compiled & installed copy of scipy 
whether it is using fftw or its own fftpack routines?

Regards,
Michael
Picon
Picon
Favicon

Re: Numpy/Scipy rfft transformations do not match?

Hi Michael

2009/3/1 Michael Cohen <mcohen <at> caltech.edu>:
> I have been trying to switch from numpy.fft.rfft calls to
> scipy.fftpack.rfft calls in order to make use of fftw3, but I find that
> the array sizes are different.

NumPy's rfft returns a complex result, whether scipy unpacks the real
and imaginary components.  I wonder if this makes much sense, and
whether we shouldn't modify SciPy to yield the same output as NumPy?

Cheers
Stéfan
Michael Cohen | 1 Mar 18:30
Picon
Favicon

Re: Numpy/Scipy rfft transformations do not match?

Stéfan van der Walt wrote:
> NumPy's rfft returns a complex result, whether scipy unpacks the real
> and imaginary components.  I wonder if this makes much sense, and
> whether we shouldn't modify SciPy to yield the same output as NumPy?

Ah, that makes sense.
In order to switch to the scipy version, the speed improvement has to 
also take into account the fact that I have to recast the result into 
the numpy form then.
Right now, my scipy takes twice as long as it is.  How do I make sure 
it's using fftw3, and is there a way to make numpy use this library?

Cheers,
Michael
Picon
Picon
Favicon

Re: Numpy/Scipy rfft transformations do not match?

2009/3/1 Michael Cohen <mcohen <at> caltech.edu>:
> Right now, my scipy takes twice as long as it is.  How do I make sure
> it's using fftw3, and is there a way to make numpy use this library?

SciPy no longer builds against fftw, but uses fftpack.

David, is it possible to still use fftw at all?

Cheers
Stéfan
David Cournapeau | 1 Mar 18:48
Picon

Re: Numpy/Scipy rfft transformations do not match?

On Mon, Mar 2, 2009 at 2:47 AM, Stéfan van der Walt <stefan <at> sun.ac.za> wrote:

>
> David, is it possible to still use fftw at all?

No, not with scipy 0.7 and later.

David
_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Michael Cohen | 1 Mar 19:08
Picon
Favicon

Re: Numpy/Scipy rfft transformations do not match?

David Cournapeau wrote:
> On Mon, Mar 2, 2009 at 2:47 AM, Stéfan van der Walt <stefan <at> sun.ac.za> wrote:
> 
>> David, is it possible to still use fftw at all?
> 
> No, not with scipy 0.7 and later.

I'm working with scipy 0.6 right now.
Partly because of the hassle of shifting and partly because I don't 
administer the cluster and they are too busy to shift.  That's partly 
why I want to check whether their implementation of scipy is using fftw 
or not.

Michael
_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
David Cournapeau | 1 Mar 19:32
Picon

Re: Numpy/Scipy rfft transformations do not match?

On Mon, Mar 2, 2009 at 3:08 AM, Michael Cohen <mcohen <at> caltech.edu> wrote:
> David Cournapeau wrote:
>> On Mon, Mar 2, 2009 at 2:47 AM, Stéfan van der Walt <stefan <at> sun.ac.za> wrote:
>>
>>> David, is it possible to still use fftw at all?
>>
>> No, not with scipy 0.7 and later.
>
> I'm working with scipy 0.6 right now.
> Partly because of the hassle of shifting and partly because I don't
> administer the cluster and they are too busy to shift.  That's partly
> why I want to check whether their implementation of scipy is using fftw
> or not.

import scipy
scipy.show_config()

should give you that information,

David
_______________________________________________
SciPy-user mailing list
SciPy-user <at> scipy.org
http://projects.scipy.org/mailman/listinfo/scipy-user
Jochen Schroeder | 1 Mar 21:29
Picon

Re: Numpy/Scipy rfft transformations do not match?

On 01/03/09 09:30, Michael Cohen wrote:
> Stéfan van der Walt wrote:
> > NumPy's rfft returns a complex result, whether scipy unpacks the real
> > and imaginary components.  I wonder if this makes much sense, and
> > whether we shouldn't modify SciPy to yield the same output as NumPy?
> 
> Ah, that makes sense.
> In order to switch to the scipy version, the speed improvement has to 
> also take into account the fact that I have to recast the result into 
> the numpy form then.
> Right now, my scipy takes twice as long as it is.  How do I make sure 
> it's using fftw3, and is there a way to make numpy use this library?

Hi Michael,

the fftw3 implementation was never that fast on scipy and is not used in
0.7 anymore. I've written a wrapper around fftw3 using ctypes. The
interface follows the C-implementation of fftw3 so it's less "pythonic"
(i.e. you execute plans instead of doing y=fft(x)) however it's quite a
bit faster than both numpy and scipy on my machines. You can find it
here: http://developer.berlios.de/projects/pyfftw/

Cheers
Jochen
Robert Cimrman | 2 Mar 15:14
Picon

ANN: SfePy 2009.1

I am pleased to announce the release of SfePy 2009.1.

SfePy (simple finite elements in Python) is a finite element analysis 
software based primarily on Numpy and SciPy.

Mailing lists, issue tracking, git repository: http://sfepy.org
Home page: http://sfepy.kme.zcu.cz

Major improvements:
- new solvers:
   - simple backtracking steepest descent optimization solver
   - PETSc Krylov solvers via petsc4py, sequential mode
   - LOBPCG eigenvalue solver (SciPy implementation)
- new mesh readers:
    - mesh3d (hermes3d)
    - AVS UCD ascii mesh
    - Hypermesh ascii mesh
- homogenization framework:
   - unified approach to resolve data dependencies: HomogenizationEngine 
class
- switched DVCS from mercurial to git

Applications:
- phononic materials:
   - dispersion analysis, phase velocity computation for phononic materials
   - caching of coefficients to speed up parametric runs
- schroedinger.py:
   - fixed DFT iterations, iteration plot saving
   - basic smearing around Fermi limit

(Continue reading)

Ravi | 2 Mar 16:41

Re: reverse an array

On Friday 27 February 2009 22:02:30 Williamson, Ross wrote:
> Is there an easy way to reverse an array without converting it to a list?

Two ways:
   x = array([0,1,2,3,4])
   y1 = flipud( x ) # See also fliplr
   y2 = x[ ::-1 ]

Regards,
Ravi

Gmane