On Sunday, April 26, 2015 at 10:06:09 AM UTC+2, Alex wrote > > This is also covered in the performance tips, but two points you should > keep in mind: > - put const in front of all globals > - run the function you want to time once before timing otherwise you will > measure (mainly) compilation time > - just as a remark: instead of t_right[length(t_right)] you can just write > t_right[end] >
Thanks. Here is a first draft of the code. - The solver has a state that maintains a table of already computed values. The input delta_t_save controls how often you want to save the results - The functions that describes the ODE mutates dy_dt for efficiency (don't need to create array at each call) I've implemented the Euler and RungeKutta4 methods. I have one suggestion: If one implements y = y + delta_t * dy_dt in the code with a Vector, you create a lot of heap arrays that has a huge cost (It seems that ODE.jl is doing that by the way). So you are forced to loop over the vector elements, which does not look really good. How about implementing a add_linear_combination!(y, delta_t, dy_dt) which would make things easier to extend for any kind of "Vector". This is exactly what people from odeint have been doing and it looks like a nice idea. If you want to go crazy you can event implement a MPI vector whose memory is scattered around different nodes. Then you just implement the add_linear_combination for your array, and you are done. Any thought?
