runge

T
runge
(
T
E1
E2
E3
)
(
in T x
,
T delegate
(
in T
,
E1
)
f
,
E2 time
,
E3 h
)
if (
hasBasicMathOp!T &&
allSatisfy!(isFloatingPoint, E1, E2, E3)
)

Examples

import des.math.linear.vector;
import des.math.util.mathstruct;

static struct Point
{
    vec3 pos, vel;
    mixin( BasicMathOp!"pos vel" );
}

Point rpart( in Point p, double time )
{ return Point( p.vel, vec3(0,0,0) ); }

auto v = Point( vec3(10,3,1), vec3(5,4,3) );

double time = 0, ft = 10, step = .01;
foreach( i; 0 .. 1000 )
    v = runge( v, &rpart, time+=step, step );

assert( eq_approx( v.pos, vec3(60,43,31),  1e-3 ) );

Meta