Which version of Julia are you using? One thing that stands out is the 
anonymous function y->1/g(y) being passed as an argument to quadgk. I'm not 
an expert, but I've heard this is slow in v0.4 and below, but should be 
fast in v0.5. Just a though.

On Saturday, June 18, 2016 at 8:53:57 PM UTC+8, Marius Millea wrote:
>
> Hi all, I'm sort of just starting out with Julia, I'm trying to get gauge 
> of how fast I can make some code of which I have Cython and Fortran 
> versions to see if I should continue down the path of converting more or my 
> stuff to Julia (which in general I'd very much like to, if I can get it 
> fast enough). I thought maybe I'd post the code in question here to see if 
> I could get any tips. I've stripped down the original thing to what I think 
> are the important parts, a nested integration with an inner function 
> closure and some global variables. 
>
> module test
>
> const a = 1.
>
> function f(x)
>     quadgk(y->1/g(y),0,x)[1]  # <=== outer integral
> end
>
> function g(y)
>     integrand(x) = x^2*sqrt(x^2*y^2+a)/(exp(sqrt(x^2+y^2))+a)
>     quadgk(integrand,0,Inf)[1]   # <=== inner integral
> end
>
> end
>
>
> > @timeit test.f(1.)
> 100 loops, best of 3: 3.10 ms per loop
>
>
>
>
> Does anyone have any tips that squeezes a little more out of this code? I 
> have run ProfileView on it, and although I'm not sure I fully understand 
> how to read its output, I think it's saying the majority of runtime is 
> spent in quadgk itself. So perhaps I should look into using a different 
> integration library? 
>
> Thanks for any help. 
>
>

Reply via email to