MathGroup Archive 2008

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

Search the Archive

Re: Compiled function slowdown

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86726] Re: [mg86682] Compiled function slowdown
  • From: DrMajorBob <drmajorbob at bigfoot.com>
  • Date: Wed, 19 Mar 2008 05:27:09 -0500 (EST)
  • References: <9949215.1205837642926.JavaMail.root@m08>
  • Reply-to: drmajorbob at longhorns.com

I take it back; it needs more than e1, e2, and fComp to make this  
meaningful. For instance, your Do has just one argument, where it needs at  
least two.

Post working code, even if it accomplishes nothing.

Bobby

On Tue, 18 Mar 2008 04:50:04 -0500, mm1q <epv001 at lvc.edu> wrote:

> Hello,
>
> In a program I'm currently working on, I need to loop through a functi on 
> ~100,000 times.  I thought I'd try compiling it to save on time.   
> However, it takes more than 10 times longer to run than the uncompiled 
> (module) version.  Are there any general guidelines as to when a  
> compiled function will be slower than its uncompiled counterpart in  
> Mathematica (such as with the use of many conditional statements)?  I've  
> included my function below (sorry if it's a mess; e1, e2 and fComp are 
> very simple compiled functions), though a general response to the above  
> question would be just fine.  Thanks!
>
> generator = Compile[{stepTotAccum_Real, {dxTable, _Real, 1},
> pTile_Real, area_Real},
>       Do[
>         While[True,
>             u = Random[];
>             If[ u < stepTotAccum,
>               stats = 1 + 4*Floor[u/pTile];
>               cand = (u - dxTable[[stats + 2]])/dxTable[[stats + 1]]+
>             dxTable[[stats]];
>               If[Random[]*dxTable[[stats + 3]] < fComp[cand],
>                 Return[cand * (-1)^Random[Integer]]
>                 ];
>               ,
>               cand = e1[u];
>               If[e2[Random[], cand, area] < fComp[cand],
>                 Return[cand * (-1)^Random[Integer]]
>                 ];
>               ];
>             ];
>         ]
>       ];
>
>



-- 

DrMajorBob at longhorns.com


  • Prev by Date: Re: importing nb files
  • Next by Date: Re: V.6.0.2 gripes...
  • Previous by thread: Re: Compiled function slowdown
  • Next by thread: Re: Compiled function slowdown