[SciPy-User] Optimizing integration routine
Mon Nov 22 13:25:10 CST 2010
On Mon, Nov 22, 2010 at 2:15 PM, R. O'Gara <firstname.lastname@example.org> wrote:
> Hi all,
> I am interested in calculating many integrals of the form f(x,y,A,B)dxdy,
> hence integrating over x,y given parameters A,B,....
> Since I'm exploring parameter space A,B I was first doing nested for loops,
> for iA in listA:
> for iB in listB:
> dblquad(f(x,y,iA,iB), etc...)
> but the problem is that it just seems to take way too long. Is there a way
> this could be optimized? I figured I could vectorize f and make A, B numpy
> arrays but scipy dbquad would give me "the function does not return a valid
> float" message.
> Or would rewriting this in C/Fortran be any more efficient?
> Any hints/ideas are appreciated. Thank you for your time
If you can vectorize, and precision doesn't matter too much, and there are
no memory problems, then I would just calculate with on a grid with 4
dimensions (x,y,iA,iB) and sum over x and y.
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User