find_coo Subroutine

private subroutine find_coo(self, row, col, index)

Type Bound

type_coo

Arguments

Type IntentOptional Attributes Name
class(type_coo), intent(in) :: self
integer(kind=int32), intent(in) :: row
integer(kind=int32), intent(in) :: col
integer(kind=int32), intent(inout) :: index

Source Code

    subroutine find_coo(self, row, col, index)
        implicit none
        class(type_coo), intent(in) :: self
        integer(int32), intent(in) :: row, col
        integer(int32), intent(inout) :: index

        integer(int32) :: i

        if (self%nnz == 0) then
            index = -1
            return
        end if

        ! --- 二分探索で行と列の組み合わせを探す ---
        index = -1
        do i = 1, self%nnz
            if (self%row(i) == row .and. self%col(i) == col) then
                index = i
                return
            end if
        end do
    end subroutine find_coo