just a wrapper for compute_jacobian, that returns a dense (m x n
) matrix.
Note
This one will include the constant elements if the linear pattern is available.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(numdiff_type), | intent(inout) | :: | me | |||
real(kind=wp), | intent(in), | dimension(:) | :: | x |
vector of variables (size |
|
real(kind=wp), | intent(out), | dimension(:,:), allocatable | :: | jac |
the jacobian matrix |
subroutine compute_jacobian_dense(me,x,jac) implicit none class(numdiff_type),intent(inout) :: me real(wp),dimension(:),intent(in) :: x !! vector of variables (size `n`) real(wp),dimension(:,:),allocatable,intent(out) :: jac !! the jacobian matrix real(wp),dimension(:),allocatable :: jac_vec !! sparse jacobian representation integer :: i !! counter if (me%exception_raised) return ! check for exceptions ! size output matrix: allocate(jac(me%m,me%n)) ! convert to dense form: jac = zero ! compute sparse form of jacobian: call me%compute_jacobian(x,jac_vec) if (me%exception_raised) return ! check for exceptions if (allocated(jac_vec)) then ! add the nonlinear elements: do i = 1, me%sparsity%num_nonzero_elements jac(me%sparsity%irow(i),me%sparsity%icol(i)) = jac_vec(i) end do deallocate(jac_vec) end if ! add the constant elements if necessary: do i = 1, me%sparsity%num_nonzero_linear_elements jac(me%sparsity%linear_irow(i),me%sparsity%linear_icol(i)) = me%sparsity%linear_vals(i) end do end subroutine compute_jacobian_dense