MathGroup Archive 2013

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

Search the Archive

Compiling numerical iterations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129888] Compiling numerical iterations
  • From: firlefranz <cornelius.franz at gmx.net>
  • Date: Sat, 23 Feb 2013 07:01:06 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.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



  • Prev by Date: Re: ComplexExpand off by a factor of (-1)?
  • Next by Date: Re: ComplexExpand off by a factor of (-1)?
  • Previous by thread: Numerical integration of lists
  • Next by thread: Re: Compiling numerical iterations