lu1pq1 Subroutine

private subroutine lu1pq1(m, n, len, iperm, loc, inv, num)

Arguments

Type IntentOptional Attributes Name
integer(kind=ip), intent(in) :: m
integer(kind=ip), intent(in) :: n
integer(kind=ip), intent(in) :: len(m)
integer(kind=ip), intent(out) :: iperm(m)
integer(kind=ip), intent(out) :: loc(n)
integer(kind=ip), intent(out) :: inv(m)
integer(kind=ip), intent(out) :: num(n)

Called by

proc~~lu1pq1~~CalledByGraph proc~lu1pq1 lusol::lu1pq1 proc~lu1fac lusol::lu1fac proc~lu1fac->proc~lu1pq1 proc~solve lusol_ez_module::solve proc~solve->proc~lu1fac proc~test_1 main::test_1 proc~test_1->proc~solve proc~test_2 main::test_2 proc~test_2->proc~solve program~main~2 main program~main~2->proc~test_1 program~main~2->proc~test_2

Source Code

  subroutine lu1pq1( m, n, len, iperm, loc, inv, num )

    integer(ip),   intent(in)    :: m, n
    integer(ip),   intent(in)    :: len(m)
    integer(ip),   intent(out)   :: iperm(m), loc(n), inv(m)
    integer(ip),   intent(out)   :: num(n) ! workspace

    !------------------------------------------------------------------
    ! lu1pq1  constructs a permutation  iperm  from the array  len.
    !
    ! On entry:
    ! len(i)  holds the number of nonzeros in the i-th row (say)
    !         of an m by n matrix.
    ! num(*)  can be anything (workspace).
    !
    ! On exit:
    ! iperm   contains a list of row numbers in the order
    !         rows of length 0,  rows of length 1,..., rows of length n.
    ! loc(nz) points to the first row containing  nz  nonzeros,
    !         nz = 1, n.
    ! inv(i)  points to the position of row i within iperm(*).
    !
    ! 10 Jan 2010: First f90 version.
    ! 12 Dec 2011: Declare intent and local variables.
    !------------------------------------------------------------------

    integer(ip)        :: i, l, nz, nzero

    ! Count the number of rows of each length.

    nzero    = 0
    num(1:n) = 0
    loc(1:n) = 0

    do i = 1, m
       nz      = len(i)
       if (nz == 0) then
          nzero   = nzero   + 1
       else
          num(nz) = num(nz) + 1
       end if
    end do

    ! Set starting locations for each length.

    l      = nzero + 1
    do nz  = 1, n
       loc(nz) = l
       l       = l + num(nz)
       num(nz) = 0
    end do

    ! Form the list.

    nzero  = 0
    do i = 1, m
       nz = len(i)
       if (nz == 0) then
          nzero = nzero + 1
          iperm(nzero) = i
       else
          l        = loc(nz) + num(nz)
          iperm(l) = i
          num(nz)  = num(nz) + 1
       end if
    end do

    ! Define the inverse of iperm.

    do l = 1, m
       i      = iperm(l)
       inv(i) = l
    end do

  end subroutine lu1pq1