Create an identity matrix (boolean sparse, represented in Yale format) of dimension .
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=ip), | intent(in) | :: | n |
Rank of the output matrix |
||
type(yale_sparse), | intent(out) | :: | res |
Output matrix |
subroutine sparse_identity(n, res)
!! Create an identity matrix (boolean sparse, represented in
!! Yale format) of dimension \(n\).
implicit none
integer(ip), intent(in) :: n
!! Rank of the output matrix
type(yale_sparse), intent(out) :: res
!! Output matrix
integer(ip) :: i
res%n = n
allocate(res%ci(res%n))
allocate(res%ri(res%n+1))
!$omp parallel do
do i = 1, n
res%ci(i) = i
res%ri(i) = i
end do
res%ri(n+1) = n+1
end subroutine sparse_identity