pivot_partial Subroutine

public subroutine pivot_partial(A, P)

Arguments

Type IntentOptional Attributes Name
real(kind=dp), intent(in), dimension(:, :) :: A
real(kind=dp), intent(out), dimension(size(A, 1), size(A, 1)) :: P

Calls

proc~~pivot_partial~~CallsGraph proc~pivot_partial pivot_partial proc~identity_n Identity_n proc~pivot_partial->proc~identity_n

Source Code

    subroutine pivot_partial(A, P)
        real(dp), dimension(:, :), intent(in) :: A
        real(dp), dimension(size(A, 1), size(A, 1)), intent(out) :: P
        integer, dimension(1) :: vlmax
        integer :: N, lmax, k
        real(dp), dimension(size(A, 1), size(A, 1)) :: P_tmp

        N = size(A, 1)
        P = Identity_n(N)

        do k = 1, N - 1

            ! Find the maximum absolute value in the column from row k to N
            vlmax = maxloc(abs(A(k:N, k)))
            lmax = vlmax(1) + k - 1

            !calculate permutation matrix P
            P_tmp = Identity_n(N)
            if (k /= lmax) then
                P_tmp([k, lmax], :) = P_tmp([lmax, k], :)
            end if
            P = matmul(P_tmp, P)

        end do

    end subroutine pivot_partial