-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Vectorized computations in approx_derivative #6345
Conversation
Do we really need to support non-vectorized computations? |
@ev-br missed your comment. I'm glad that you looked into this. Someone may have a complicated function (integration of ODE for example), which can't be vectorized efficiently (and vectorizing it is just a tedious and pointless job). So I guess it's necessary to provide both variants, although I agree it would be good to decrease the number of options. Another thing is that non-vectorized version is already used in So what do you think of this pull request? |
I think it's a worthy feature. If there's a function which can handle vectorized evaluations, why taking a perf hit of python looping. However, I'm a bit wary of adding this much of almost-but-not-completely duplicated code. |
what is the status of this PR? |
I think it is a useful addition and generally the right way to do things in scipy (i. e. allowing for "doubly" vectorized functions). I don't know, I think it even can be merged right now, then we can include it into By the way, why are you asking? |
Yes, I'd suggest the same. If the user function can't do vectorized calculations, then we Since this has been inactive for a while and there are merge conflicts, I'll go ahead and close, but all should feel free to reopen to complete this enhancement. |
Jacobian is estimated numerically for a function
fun(x)
. Iffun
is implemented such that it accepts and returns 2-d arrays (it is very easy to achieve usingvstack
whenfun
is coded in terms of numpy functions), thenfun
will be called only once to compute all necessary values.The idea is simple, but it can give substantial speed-ups for estimating Jacobians. Currently only
least_squares
usesapprox_derivative
. I will fill an issue thatleast_squares
should be adjusted to allow vectorized Jacobian estimation (when this PR is in).@ev-br @pv, please look when you have time.