vtjnash/ODE.jl — pull request #7 by tlycken (2013-07-24 00:54:15+00:00)
Title: WIP: Api changes

I've started polishing the API for the existing solvers, and would like some comments both on the API decisions and on the implementations of them.

The first of these commits makes a few simple changes to the api:
* it possible to run all the solvers for scalar equations, returning scalar results

tout, yout = ode45((t, y) -> 2t, 0:2, 0) # both tout and yout are now Vector{Float}
# before, yout would have been an Nx1 Float64 array

* `ode23` and `ode45` can take tolerances as keyword arguments: `ode23` takes two arguments `rtol` and `atol`, and `ode45` takes one argument `tol`. I would rather both methods took the same arguments (preferrably by introducing relative and absolute tolerance in `ode45`), but I didn't want to change anything in the implementation.

* `ode23` and `ode45` support non-standard vector norms for determining the error, by supplying a keyword argument `vecnorm` which is a function `(x,y) -> norm(x,y)` in the vector space of the solution (see https://groups.google.com/d/msg/julia-users/PouO26Q5C-c/6UBWYBq7wAwJ for some discussion) The default is the standard `norm` function from Base.

The second commit introduces the the notion of a "solver object" which can be re-used. It currently only handles very basic setup (no kwargs, for example), but it might be used like this:

solver = ode(:ode23, (t,x) -> 2t, 0:2, 0)
t1, y1 = solver.solve() # solves y' = 2t, y(0) = 0 until t = 2 using ode23
solver.solver = ode45
t2, y2 = solver.solve() # solves the same problem using ode45, without restating the problem

In the implementation of this, I am especially uncertain on whether it's better to use symbols (`:ode23`) or direct references to the functions (`ode23`) - look at the implementation to see what I mean. It could probably be prettier =)