Gets value of sparse array SA
at the subscripts subs
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(SparseArray), | intent(in) | :: | SA | Sparse Array |
||
integer, | intent(in), | dimension(:) | :: | subs | Subscripts of Sparse Array |
Value of SA
at subs
function get_value(SA, subs) result (val)
!+ Gets value of sparse array `SA` at the subscripts `subs`
type(SparseArray), intent(in) :: SA
!+ Sparse Array
integer, dimension(:), intent(in) :: subs
!+ Subscripts of Sparse Array
real(Float64) :: val
!+ Value of `SA` at `subs`
integer :: ind, cind
val = 0.d0
if(SA%nnz.eq.0) return
ind = sub2ind(SA%dims, subs)
cind = search_sorted_first(SA%inds, ind)
if(ind.eq.SA%inds(cind))then
val = SA%vals(cind)
endif
end function get_value