JuliaLang/ODE.jl — pull request #49 by pwl (2014-10-21 18:54:27+00:00)
Title: [WIP] Adding iterators

Hi,
I have been playing around with iterator version of `oderkf` and came up with my own implementation. My idea was what follows: make `oderkf(F,x0,tspan::Vector)` behave as previously and add `oderkf(F,x0,tstart::Number)` which creates an iterator. I reimplemented `oderkf(F,x0,tspan::Vector)` using the iterator version of `oderkf`, so that both implementations are not redundant. I also made changes to the keyword arguments accepted by `oderkf`

* New keyword arguments: `minstep`, `maxstep`, `initstep`, I decided that `hmin` and `hmax` from the previous implementation were already arbitrary, so why not allow the user to define his own problem specific values? In the previous implementation `hmin` and `hmax` were computed from maximal and minimal time, for iterator this is impossible because, in principle, we might not now the maximal time. Therefore, I set the default value of `minstep` to `eps(T)^(1/3)`, where `T` is the type of `tstart`; the default value for `initstep` is `minstep` while `maxstep=1/minstep`. Alternatively we could set `maxstep=Inf`, but all these values are a matter for a discussion.

* I added a `tstop=Inf` optional argument to the iterator version of `oderkf`, naturally `oderkf` stops the integration exactly when `t=tstop` is reached.

* I changed the reaction for `abs(h)x, 1., 0., tstop = 10))`.

You can now do something similar to what @ivarne had in mind in issue #27 :
```
ode = ode45((t,x)->x, 1., 0.)
for (t,y) in ode
if y > 10
@show (t,y)
break
end
end
```

With iterators we would be one step closer to implementing root finding for solutions to ODE's. I am curious if iterators could get along with dense output #40 #44 .

PS I know that API is not fixed yet, but I needed iterators for my own purposes and decided to share this draft with you.

Cheers,
Paweł