MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Fourier: Execution time for real and complex arguments

  • To: mathgroup at smc.vnet.net
  • Subject: [mg31840] Re: Fourier: Execution time for real and complex arguments
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 7 Dec 2001 05:55:56 -0500 (EST)
  • References: <9ul29u$6lr$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Silvia,
The difference seems to be due to packed array

    n=2^15;
    xRe=Table[Random[],{i,n}];
    x1=xRe+I 1.;
    x2=xRe+I Table[1.,{i,n}];

    Developer`PackedArrayQ/@{xRe,x1,x2}

        {True,True,False}

Now make thepacked array version of x2

    px2=Developer`ToPackedArray[x2];//Timing

        {0.49 Second,Null}

We get

    Timing[y=Fourier[xRe];] (*Real argument*)
    Timing[y=Fourier[x1];] (*Complex argument*)
    Timing[y=Fourier[x2];] (*Complex argument*)
    Timing[y=Fourier[px2];] (*Complex argument*)


        {2.69 Second,Null}

        {1.87 Second,Null}

        {6.26 Second,Null}

        {1.38 Second,Null}

So it seems to be advantageous to pack x2, even taking into account the time
taken to pack it.

--
Allan

---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565


"Silvia Raffaelli" <silviar at elmagn.chalmers.se> wrote in message
news:9ul29u$6lr$1 at smc.vnet.net...
> Hi,
>
> I am little curious about the behavior of the
> DFT-routine Fourier. Two quesions:
>
> 1. Why does Fourier take much more than twice the time
>    to calculate the DFT of a list of imaginary/complex
>    numbers compared to a equal-length list of real
>    numbers (floating-point)?
>
> 2. Why does the way I generate a list affect the
>    time it takes to run Fourier?
>
> Sample session:
>
> n   = 2^20;
> xRe = Table[Random[],{i,n}];
> x1  = xRe+I 1.;
> x2  = xRe+I Table[1.,{i,n}];
>
> Timing[ y=Fourier[xRe]; ]  (* Real argument *)
> Timing[ y=Fourier[x1];  ]  (* Complex argument *)
> Timing[ y=Fourier[x2];  ]  (* Complex argument *)
> Max[ Abs[x1 - x2] ]
> FullForm[x1] - FullForm[x2]
> Max[ Abs[ Fourier[x1] - Fourier[x2] ] ]
>
> Out[1]= {1.86 Second,Null}
>
> Out[2]= {4.24 Second,Null}
>
> Out[3]= {10.03 Second,Null}
>
> Out[4]= 0.
>
> Out[5]= 0
>
> Out[6]= 0.
>
>
> I can understand the difference between Out[1] and
> Out[2], but what about Out[3]? Any ideas?
> (Where's my mistake? ;-) )
>
> TIA,
>
> --
> Martin Johansson
> Ericsson Microwave Systems
> m.johansson at ericsson.com
>
>
>




  • Prev by Date: Re: Fit[]: how to obtain the parameter values?
  • Next by Date: Re: scope all wrong? in Mathematica 4.1
  • Previous by thread: Re: Fourier: Execution time for real and complex arguments
  • Next by thread: Re: coloring eveerything outside a circle