complex_step_derivative Subroutine

public subroutine complex_step_derivative(f, x, h, dfdx)

Compute the first derivative using the complex-step method. This is Equation 6 from Reference [1].

Arguments

Type IntentOptional Attributes Name
procedure(func) :: f
complex(kind=wp), intent(in) :: x
real(kind=wp), intent(in) :: h
real(kind=wp), intent(out) :: dfdx

Called by

proc~~complex_step_derivative~~CalledByGraph proc~complex_step_derivative complex_step_module::complex_step_derivative proc~complex_step_test complex_step_module::complex_step_test proc~complex_step_test->proc~complex_step_derivative

Source Code

    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