compute the gradient of the function (Jacobian):
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(nlesolver_type), | intent(inout) | :: | me | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| real(kind=wp), | intent(out), | dimension(:) | :: | g |
subroutine grad_sparse(me,x,g) !! compute the gradient of the function (Jacobian): implicit none class(nlesolver_type),intent(inout) :: me real(wp),dimension(:),intent(in) :: x real(wp),dimension(:),intent(out) :: g real(wp),dimension(m,n) :: g_dense ! for this example, just convert the dense ! jacobian to the sparse representation call grad(me,x,g_dense) g(1) = g_dense(1,1) g(2) = g_dense(1,2) g(3) = g_dense(2,2) f_evals = f_evals + 2 ! to approximate forward diff derivatives end subroutine grad_sparse