lcs_lengths Function

private pure function lcs_lengths(a, b) result(row)

row(k): the length of the longest common subsequence of a and b(1:k).

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: a(:)

line numbers of the two texts

integer, intent(in) :: b(:)

line numbers of the two texts

Return Value integer, (0:size(b))


Called by

proc~~lcs_lengths~~CalledByGraph proc~lcs_lengths lcs_lengths proc~lcs lcs proc~lcs->proc~lcs_lengths proc~lcs->proc~lcs proc~unified_diff unified_diff proc~unified_diff->proc~lcs proc~process_text process_text proc~process_text->proc~unified_diff proc~process_file process_file proc~process_file->proc~process_text proc~process_stdin process_stdin proc~process_stdin->proc~process_text proc~run run proc~run->proc~process_file proc~run->proc~process_stdin

Source Code

pure function lcs_lengths(a, b) result(row)
    !! `row(k)`: the length of the longest common subsequence of `a` and `b(1:k)`.
    integer, intent(in) :: a(:), b(:)   !! line numbers of the two texts
    integer :: row(0:size(b))
    integer :: prev(0:size(b))
    integer :: i, k
    row = 0
    do i = 1, size(a)
        prev = row
        do k = 1, size(b)
            if (a(i) == b(k)) then
                row(k) = prev(k - 1) + 1
            else
                row(k) = max(row(k - 1), prev(k))
            end if
        end do
    end do
end function lcs_lengths