Copy out the column indices and values stored in row i.
Both outputs are allocated to the number of stored entries in that
row, which is zero for an empty row. A row index outside 1:nrow
reports ERROR_VALIDATION and yields zero-size outputs.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(csr_t), | intent(in) | :: | self | |||
| integer(kind=default_int), | intent(in) | :: | i |
Row to read, in |
||
| integer(kind=default_int), | intent(out), | allocatable | :: | cols(:) |
Column indices of row |
|
| real(kind=dp), | intent(out), | allocatable | :: | vals(:) |
Values of row |
|
| type(error_t), | intent(out), | optional | :: | err |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=default_int), | private | :: | hi | ||||
| integer(kind=default_int), | private | :: | k | ||||
| integer(kind=default_int), | private | :: | lo | ||||
| integer(kind=default_int), | private | :: | n |
subroutine csr_row_slice(self, i, cols, vals, err) !! Copy out the column indices and values stored in row `i`. !! !! Both outputs are allocated to the number of stored entries in that !! row, which is zero for an empty row. A row index outside `1:nrow` !! reports `ERROR_VALIDATION` and yields zero-size outputs. class(csr_t), intent(in) :: self integer(default_int), intent(in) :: i !! Row to read, in `1:nrow` integer(default_int), allocatable, intent(out) :: cols(:) !! Column indices of row `i`, ascending real(dp), allocatable, intent(out) :: vals(:) !! Values of row `i`, parallel to `cols` type(error_t), intent(out), optional :: err integer(default_int) :: lo, hi, n, k if (.not. self%is_valid(err)) then allocate (cols(0)) allocate (vals(0)) return end if if (i < 1 .or. i > self%nrow) then call fail(err, "pic_csr: row_slice got a row index outside 1:n_rows") allocate (cols(0)) allocate (vals(0)) return end if lo = self%row_ptr(i) hi = self%row_ptr(i + 1) - 1 n = hi - lo + 1 allocate (cols(n)) allocate (vals(n)) do k = 1, n cols(k) = self%col_idx(lo + k - 1) vals(k) = self%values(lo + k - 1) end do end subroutine csr_row_slice