get_value Function

public function get_value(SA, subs) result(val)

Gets value of sparse array SA at the subscripts subs

Arguments

Type IntentOptional AttributesName
type(SparseArray), intent(in) :: SA

Sparse Array

integer, intent(in), dimension(:):: subs

Subscripts of Sparse Array

Return Value real(kind=Float64)

Value of SA at subs


Calls

proc~~get_value~~CallsGraph proc~get_value get_value proc~sub2ind sub2ind proc~get_value->proc~sub2ind

Contents

Source Code


Source Code

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