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: Compiling numerical iterations
Replies: 3   Last Post: Feb 27, 2013 3:04 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Dr. Peter Klamser

Posts: 23
Registered: 6/11/11
Re: Compiling numerical iterations
Posted: Feb 23, 2013 11:31 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Compiling functions with Complie[{...},...] was once ago (I think
version 5 or earlier) interesting for simple problems. Complex
algorithmen was always useless to compile.

For versions ealier then 5 it was a nice approach to write small c
programs for small modules:

http://onlinelibrary.wiley.com/doi/10.1002/piuz.19970280618/abstract

Today it only interesting exporting your results to c so it can be
integrated into a softwar, that runs outside a Mathematica workplace.

Kind regards from

Peter

2013/2/23 firlefranz <cornelius.franz@gmx.net>:
> Hi,
>
> to speed up some calculations I'd like to use this relatively new method of compiling equations or export them to C. But since I'm very new in these things, I have really problems to use this c-compiling function.
> Can someone show me on this simple part of code (calculation of a correlation function of a 1D random walk), how it should be implemented?
>
> num = 1000;
> tab = Table[0, {i, 1, num}];
> corr = Table[0, {i, 1, num/10}];
> For[l = 1, l <= 1000, l++,
> a = 0;
> For[i = 1, i <= num, i++,
> tab[[i]] = tab[[i]] + a/10;
> If[RandomReal[{-1, 1}] < 0, a = a + 1, a = a - 1];
> ]
> ]
> For[k = 1, k <= num/10, k++,
> For[n = 1, n <= num/10*9, n++,
> corr[[k]] = corr[[k]] + tab[[n]]*tab[[n + k - 1]]/num*10/9];
> ]
> ListPlot[{corr}, Joined -> False]
>
> Best regards
> Cornelius
>





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.