Runge-Kutta method: Difference between revisions

Stronger static typing in the D entry
(+ D entry)
(Stronger static typing in the D entry)
Line 88:
=={{header|D}}==
{{trans|Ada}}
<lang d>import std.stdio, std.math, std.typecons;
 
alias real FP;
alias Typedef!(FP[101]) FPs;
 
void runge(in FP function(in FP, in FP) pure nothrow yp_func,
FP[]ref FPs t, FP[]ref FPs y, in FP dt) pure nothrow {
foreach (n; 0 .. t.length - 1) {
FP dy1 = dt * yp_func(t[n], y[n]);
Line 111 ⟶ 112:
void main() {
enum FP dt = 0.10;
enumFPs size_tt_arr, N = 101y_arr;
FP[N] t_arr, y_arr;
 
t_arr[0] = 0.0;