Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • $\begingroup$ No fair! Blasted v8 compile-to-C... $\endgroup$ Commented Jul 30, 2012 at 19:44
  • $\begingroup$ I get error messages for RandomReal input. Should timing include Compileoverhead as well? $\endgroup$ Commented Jul 31, 2012 at 6:47
  • 2
    $\begingroup$ @Yves he compiled for _Integer values; you'd need to compile a separate function for _Real values, then craft a function to select between them, as well as intelligently handle lists that are not packed and may contain mixed types. I don't think compilation overhead should be included in timings unless it uses pre-calculation. $\endgroup$ Commented Jul 31, 2012 at 11:03
  • $\begingroup$ @YvesKlett As Mr.W says it's compiled for Integers, and would need to be recompiled for reals. I don't know if timing should include compilation overhead; to be honest, I offer this is what I'd do if I needed it to be as fast as possible. It's clearly not leveraging Mathematica's strengths, nor is particularly pretty or clever. $\endgroup$ Commented Jul 31, 2012 at 13:25
  • $\begingroup$ How about a short-circuited version of the loop that keeps testing Compile`GetElement[l, i] until it fins something positive? (i.e., use Break[]) somewhere. $\endgroup$ Commented Apr 17, 2013 at 4:41