Compute the first derivative using the complex-step method. This is Equation 6 from Reference [1].
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
procedure(func) | :: | f | ||||
complex(kind=wp), | intent(in) | :: | x | |||
real(kind=wp), | intent(in) | :: | h | |||
real(kind=wp), | intent(out) | :: | dfdx |
subroutine complex_step_derivative(f,x,h,dfdx) implicit none procedure(func) :: f complex(wp),intent(in) :: x real(wp),intent(in) :: h real(wp),intent(out) :: dfdx dfdx = AIMAG(f(cmplx(real(x,wp),AIMAG(x)+h,wp)))/h end subroutine complex_step_derivative