Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13580

Compiling numerical iterations

From firlefranz <cornelius.franz@gmx.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Compiling numerical iterations
Date 2013-02-23 12:01 +0000
Message-ID <kgab2i$c7f$1@smc.vnet.net> (permalink)
Organization Time-Warner Telecom

Show all headers | View raw


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

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Compiling numerical iterations firlefranz <cornelius.franz@gmx.net> - 2013-02-23 12:01 +0000
  Re: Compiling numerical iterations Ray Koopman <koopman@sfu.ca> - 2013-02-24 04:31 +0000
  Re: Compiling numerical iterations firlefranz <cornelius.franz@gmx.net> - 2013-02-26 06:09 +0000
    Re: Compiling numerical iterations Ray Koopman <koopman@sfu.ca> - 2013-02-27 08:04 +0000
    Re: Compiling numerical iterations David Bailey <dave@removedbailey.co.uk> - 2013-03-01 02:25 +0000
  Re: Compiling numerical iterations Peter Klamser <klamser@googlemail.com> - 2013-02-27 08:04 +0000
  Re: Compiling numerical iterations Peter Klamser <klamser@googlemail.com> - 2013-03-05 09:15 +0000

csiph-web