[SciPy-Dev] vectorized newton proposal

Mark Alexander Mikofski mikofski at berkeley.edu
Sat Mar 17 07:06:58 EDT 2018


Hi all,

I've been working on a branch of scipy.optimize.zeros in PR #8357 that uses
NumPy to speed up the newton method if the initial guess is not scalar.

In benchmarks with arrays of 100,000 elements, the NumPy vectorized code is
about 40x faster that looping over the existing code.

If you have time, please consider reviewing the PR. Here's some background

* If the initial guess is scalar, then the old scalar newton code is used

* If the initial guess is *not* scalar then it calls a private method
called "_array_newton"

* there is a new flag called "failure_idx_flag" that in "_array_newton"
appends the indices of failures and indices of zero-derivative items to the
return as a tuple of 3 arrays (results, failures, zero-derivatives),
otherwise just the results are returned

* it only raises a "RuntimeError" if all items fail, otherwise it will
always return an array of results, but it warns a "RuntimeWarning" if there
are any possibly inaccurate guesses that didn't converge because the
derivative was zero (infinite newton step)

Thanks,
Mark

-- 
Mark Mikofski, PhD (2005)
*Fiat Lux*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180317/712a0465/attachment.html>


More information about the SciPy-Dev mailing list