Re: Compiling numerical iterations

• To: mathgroup at smc.vnet.net
• Subject: [mg129900] Re: Compiling numerical iterations
• From: Peter Klamser <klamser at googlemail.com>
• Date: Sat, 23 Feb 2013 23:32:40 -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
• References: <20130223120106.68F4E68EC@smc.vnet.net>

```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 at 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
>

```

• Prev by Date: A nonconventional ListContourPlot
• Next by Date: Re: Mathematica and Lisp
• Previous by thread: Compiling numerical iterations
• Next by thread: Re: Compiling numerical iterations
{"ft_lang_label":"__label__en","ft_lang_prob":0.7338337,"math_prob":0.93801475,"size":1935,"snap":"2023-40-2023-50","text_gpt3_token_len":622,"char_repetition_ratio":0.09269808,"word_repetition_ratio":0.013157895,"special_character_ratio":0.3503876,"punctuation_ratio":0.215,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9652318,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-11-30T00:54:48Z\",\"WARC-Record-ID\":\"<urn:uuid:438a3110-2fb1-431e-b26b-997f9933286e>\",\"Content-Length\":\"45764\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e54fd202-425f-4008-ae18-8a80a3d7c276>\",\"WARC-Concurrent-To\":\"<urn:uuid:a695bc18-22e1-4908-ac8a-4692b4147567>\",\"WARC-IP-Address\":\"140.177.9.73\",\"WARC-Target-URI\":\"https://forums.wolfram.com/mathgroup/archive/2013/Feb/msg00264.html\",\"WARC-Payload-Digest\":\"sha1:ZSGB2GXV3JGBLUEN3GBRTU5IDKFTUIJI\",\"WARC-Block-Digest\":\"sha1:ITZPBBHPASQOIWWXXO2F67B3CDI4YRMK\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100164.15_warc_CC-MAIN-20231130000127-20231130030127-00836.warc.gz\"}"}