Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Could someone help optimize this for Mathematica 9?
Replies: 3   Last Post: Dec 5, 2012 3:11 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Christoph Lhotka

Posts: 39
Registered: 2/9/12
Re: Could someone help optimize this for Mathematica 9?
Posted: Dec 5, 2012 3:11 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Dear Paul,

I did not investigate the issue further but I have the feeling that it
has to do something with packed arrays:

I get a speed up of a factor of 6.5 if I change your code into (I just
add a '.' after 100000 and 10):

mNumberSamples = 100000.;
mFrequency = 10.;
m = Table[{t/mNumberSamples,
Sin[t/mNumberSamples mFrequency*2 \[Pi]]}*1.0, {t, 1,
mNumberSamples}]; mStartTime = SessionTime[];
ListLinePlot[m]
mStopTime = SessionTime[];
StringForm["Elapsed time = ``", N[mStopTime - mStartTime]]

If you try your original code Developer`PackedArrayQ[m] returns False while
in my modified code Developer`PackedArrayQ[m] returns True. So I guess
that ListLinePlot works faster with packed arrays.

Best,

Christoph




On 12/04/2012 10:14 AM, McHale, Paul wrote:
> We have a strong need to view large numbers of data points. Mathematica 8 was excellent at this. The following code executed under both 8 and 9 (Windows):
>
> Mathematica 8: Less than 0.5 seconds
> Mathematica 9: Greater than 4 seconds
>
> mNumberSamples=100000;
> mFrequency=10;
> m=Table[{t/mNumberSamples ,Sin[t/mNumberSamples mFrequency*2 \[Pi]]}*1.0,{t,1,mNumberSamples}];mStartTime=SessionTime[];
> ListLinePlot[m]
> mStopTime=SessionTime[];
> StringForm["Elapsed time = ``", N[mStopTime-mStartTime]]
>
> I have tried the code on a slower mac laptop (version 9 only) and had the same slower results. Any input welcome as this functionality is extremely important to us.
>
>
> Paul McHale | Electrical Engineer, Energetics Systems | Excelitas Technologies Corp.
>
>
>
>
>
> Phone: +1 937.865.3004 | Fax: +1 937.865.5170 | Mobile: +1 937.371.2828
> 1100 Vanguard Blvd, Miamisburg, Ohio 45342-0312 USA
> Paul.McHale@Excelitas.com
> www.excelitas.com
>
>
>
>






Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.