
Re: Compiling numerical iterations
Posted:
Feb 23, 2013 11:31 PM


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 ccompiling 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 >

