[SciPy-Dev] vectorized scipy.integrate.quad
Christoph Groth
christoph at grothesque.org
Mon Sep 28 06:28:14 EDT 2015
Nathan Woods wrote:
> Unless I'm mistaken, though, integration of a python function seems
> unlikely to take advantage of a vectorized C integrator, so the speed
> ups would be limited to those calling quad with ctypes functions.
What I proposed is making it possible that the integrand gets called
with a sequence of x-values instead of a single x-value at a time. It
would be then up to the user-specified integrand function to perform the
computation. I can think of at least three ways that can provide speed-ups:
• vectorized evaluation using vectorized numpy operations (it should be faster
to call np.sin(x) once with x being an array of 21 elements than to
call math.sin(x) 21 times).
• concurrent.futures
• MPI
Is there a problem that I fail to see?
> Also, I think breaking the API would be a bad idea, but you could, for
> instance, allow quad to accept both numbers and sequences, and then
> wrap the number in an array before sending it on to the
> integrator. This would preserve the API, while allowing the desired
> vectorization.
Of course breaking the API is a bad idea. That’s why I have in mind
keeping scipy.integrate.quad as it is, and adding a sibling that could
be called scipy.integrate.vectorized_quad. If the algorithm of
vectorized_quad remains the same (as planned), quad could be eventually
implemented as a thin wrapper around vectorized_quad. This would allow
to remove the unomodified QUADPACK from scipy.
I am sorry, I do not understand your proposal for extending the API in a
backwards-compatible way without introducing a new function. Could you
please explain it in more detail?
Christoph
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 810 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20150928/8339e5ef/attachment.sig>
More information about the SciPy-Dev
mailing list