Module osl_diff
module osl_diff
! Uses
use osl_core, wp => osl_wp
! Variables
integer, public, parameter :: osl_diff_backward = -1
integer, public, parameter :: osl_diff_central = 0
integer, public, parameter :: osl_diff_forward = 1
! Subroutines and functions
public subroutine osl_gradient(func_n, x, grad, method, epsf, ctx)
public subroutine osl_jacobian(func_nm, x, jac, epsf, ctx)
public subroutine osl_hessian(func_n, x, hess, epsf, ctx)
end module osl_diff
Description of Variables
osl_diff_backward
integer, public, parameter :: osl_diff_backward = -1
osl_diff_central
integer, public, parameter :: osl_diff_central = 0
osl_diff_forward
integer, public, parameter :: osl_diff_forward = 1
Description of Subroutines and Functions
osl_gradient
public subroutine osl_gradient(func_n, x, grad, method, epsf, ctx)
interface func_n
subroutine func_n(x, y, ctx)
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), intent(out) :: y
integer, optional, dimension(:), intent(in) :: ctx
end subroutine func_n
end interface func_n
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), dimension(size(x)), intent(out) :: grad
integer, optional, intent(in) :: method
real (kind=wp), optional, intent(in) :: epsf
integer, optional, dimension(:), intent(in) :: ctx
! Calls: func_n
end subroutine osl_gradient
Calculate a central-difference approximation to the gradient of an arbitrary real-valued function FUNC_N at a given point X. Upon return, the gradient is stored in GRAD. An optional context argument CTX will be passed to FUNC_N if provided. The function accuracy EPSF is used to determine the stepsize if provided, otherwise machine precision is used by default. METHOD may be one of OSL_DIFF_BACKWARD, OSL_DIFF_CENTRAL (default), or OSL_DIFF_FORWARD.
osl_jacobian
public subroutine osl_jacobian(func_nm, x, jac, epsf, ctx)
interface func_nm
subroutine func_nm(x, y, ctx)
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), dimension(:), intent(out) :: y
integer, optional, dimension(:), intent(in) :: ctx
end subroutine func_nm
end interface func_nm
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), dimension(:,:), intent(out) :: jac
real (kind=wp), optional, intent(in) :: epsf
integer, optional, dimension(:), intent(in) :: ctx
! Calls: func_nm, osl_error
end subroutine osl_jacobian
Calculate a central-difference approximation to the Jacobian of an arbitrary real-vector-valued function FUNC_NM at a given point X. Upon return, the Jacobian is stored in JAC. An optional context argument CTX will be passed to FUNC_NM if provided. The function accuracy EPSF is used to determine the stepsize if provided, otherwise machine precision is used by default.
osl_hessian
public subroutine osl_hessian(func_n, x, hess, epsf, ctx)
interface func_n
subroutine func_n(x, y, ctx)
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), intent(out) :: y
integer, optional, dimension(:), intent(in) :: ctx
end subroutine func_n
end interface func_n
real (kind=wp), dimension(:), intent(in) :: x
real (kind=wp), dimension(size(x),size(x)), intent(out) :: hess
real (kind=wp), optional, intent(in) :: epsf
integer, optional, dimension(:), intent(in) :: ctx
! Calls: func_n
end subroutine osl_hessian
Calculate a central-difference approximation to the Hessian of an arbitrary real-valued function FUNC_N at a given point X. Upon return, the Hessian is stored in HESS. An optional context argument CTX will be passed to FUNC_NM if provided. The function accuracy EPSF is used to determine the stepsize if provided, otherwise machine precision is used by default.