I do auto ranging based on a step size per number unit. So if your function runs from 0 to 5 and you ask for 5 steps per number, then you would end up with 5*5+1 = 26 max steps. The +1 comes from the initial value at the start of the range, then you would do 5 steps in the 1 interval, 5 steps in the 2 interval, and so on.
Source code is here:
https://github.com/BuckRogers1965/Examples/blob/master/Math/NumericAnalysis/RungeKuttaTest.c
https://github.com/BuckRogers1965/Examples/blob/master/Math/NumericAnalysis/RungeKutta.h
https://github.com/BuckRogers1965/Examples/blob/master/Math/NumericAnalysis/RungeKutta.c
The example program, you pass in the starting value, the start and end points, the step per unit, and the function you are interpolating. The object does the rest with the interface below: |
The output for the example from the book, exact same values. |
No comments:
Post a Comment