Thiele's interpolation formula: Difference between revisions

m
→‎{{header|D}}: change to use array operation instead of for-looping
m (→‎{{header|D}}: better naming)
m (→‎{{header|D}}: change to use array operation instead of for-looping)
Line 154:
=={{header|D}}==
{{works with|D|2.051}}
<lang d>import std.stdio, std.range, std.array, std.mathalgorithm ;
 
alias real delegate(real) RealFun ;
Line 182:
auto xrng = array(d.range) ;
real[] yfun ;
foreach(x; xrngd.range) yfun ~= fun(x) ; // yfun = map!f(xrng) not work ~_~#
this(yfun, xrng) ;
}
Line 189:
int N = x.length;
real[][] p = new real[][] (N, N) ;
for(int ip[0][] = 0y[] ; i// <array/vector N ;operation i++)follow
p[1][0..$-1] = (x[0..$-1] - x[1..$]) / (p[i0][0..$-1] =- yp[0][i1..$]) ;
for(int ij = 02; ij < N - 1 ; ij++) {
p[i][1]immutable M = (x[i]N - x[i+1]) / (p[i][0]j - p[i+1][0]) ;
for(int p[j][0..M] = p[j-2;][1..M+1] j+ < N(x[0..M] - 1; x[j..M++j]) /
for(int i = 0; i < N - j - (p[j-1][0..M] ;- i+p[j-1][1..M+1]) ;
}
p[i][j] = p[i+1][j-2] + (x[i] - x[i+j]) /
return array(pmap!"a[i][j-1] - "(p[i+1][j-1])).idup ;
return p[1].idup ;
}
 
Anonymous user