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

1 import des.math.linear.vector;
2 import des.math.util.mathstruct;
3 
4 static struct Point
5 {
6     vec3 pos, vel;
7     mixin( BasicMathOp!"pos vel" );
8 }
9 
10 Point rpart( in Point p, double time )
11 { return Point( p.vel, vec3(0,0,0) ); }
12 
13 auto v = Point( vec3(10,3,1), vec3(5,4,3) );
14 
15 double time = 0, ft = 10, step = .01;
16 foreach( i; 0 .. 1000 )
17     v = runge( v, &rpart, time+=step, step );
18 
19 assert( eq_approx( v.pos, vec3(60,43,31),  1e-3 ) );

Meta