df_scalar

df_scalar
(
T
K
E = T
)
(
T delegate(
T
)
f
,
K p
,
E step = E.epsilon * 2
)
if (
isFloatingPoint!T &&
isFloatingPoint!E
&&
is(K : T)
)

Examples

1 auto pow2( double x ){ return x^^2; }
2 auto res1 = df_scalar( &pow2, 1 );
3 auto res2 = df_scalar( &pow2, 3 );
4 auto res3 = df_scalar( &pow2, -2 );
5 assert( abs(res1 - 2.0) < 2e-6 );
6 assert( abs(res2 - 6.0) < 2e-6 );
7 assert( abs(res3 + 4.0) < 2e-6 );

Meta