Skip to content

Commit

Permalink
ENH: Document LSODA changes
Browse files Browse the repository at this point in the history
Co-authored-by: Albert Steppi <albert.steppi@gmail.com>
  • Loading branch information
Patol75 and steppi committed Jun 2, 2023
1 parent c81da26 commit 7040629
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scipy/integrate/_ivp/lsoda.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,32 @@ def _dense_output_impl(self):
iwork = self._lsoda_solver._integrator.iwork
rwork = self._lsoda_solver._integrator.rwork

# We want to produce the Nordsieck history array, yh, up to the order
# used in the last successful iteration. The step size is unimportant
# because it will be scaled out in LsodaDenseOutput. Some additional
# work may be required because ODEPACK's LSODA implementation produces
# the Nordsieck history in the state needed for the next iteration.

# iwork[13] contains order from last successful iteration, while
# iwork[14] contains order to be attempted next.
order = iwork[13]

# rwork[11] contains the step size to be attempted next, while
# rwork[10] contains step size from last successful iteration.
h = rwork[11]

# rwork[20:20 + (iwork[14] + 1) * self.n] contains entries of the
# Nordsieck array in state needed for next iteration. We want
# the entries up to order for the last successful step so use the
# following.
yh = np.reshape(rwork[20:20 + (order + 1) * self.n],
(self.n, order + 1), order='F').copy()
if iwork[14] < order:
# If the order is set to decrease then the final column of yh
# has not been updated within ODEPACK's LSODA
# implementation because this column will not be used in the
# next iteration. We must rescale this column to make the
# associated step size consistent with the other columns.
yh[:, -1] *= (h / rwork[10]) ** order

return LsodaDenseOutput(self.t_old, self.t, h, order, yh)
Expand Down

0 comments on commit 7040629

Please sign in to comment.