setr Subroutine

private subroutine setr(m, n, Indrow, Jpntr, Indcol, Ipntr, Iwa)

given a column-oriented definition of the sparsity pattern of an m by n matrix a, this subroutine determines a row-oriented definition of the sparsity pattern of a.

on input the column-oriented definition is specified by the arrays indrow and jpntr. on output the row-oriented definition is specified by the arrays indcol and ipntr.

Arguments

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

a positive integer input variable set to the number of rows of a.

integer, intent(in) :: n

a positive integer input variable set to the number of columns of a.

integer, dimension(*) :: Indrow

an integer input array which contains the row indices for the non-zeroes in the matrix a.

integer, dimension(n+1) :: Jpntr

an integer input array of length n + 1 which specifies the locations of the row indices in indrow. the row indices for column j are indrow(k), k = jpntr(j),...,jpntr(j+1)-1. note that jpntr(n+1)-1 is then the number of non-zero elements of the matrix a.

integer, dimension(*) :: Indcol

an integer output array which contains the column indices for the non-zeroes in the matrix a.

integer, dimension(m+1) :: Ipntr

an integer output array of length m + 1 which specifies the locations of the column indices in indcol. the column indices for row i are indcol(k), k = ipntr(i),...,ipntr(i+1)-1. note that ipntr(1) is set to 1 and that ipntr(m+1)-1 is then the number of non-zero elements of the matrix a.

integer, dimension(m) :: Iwa

an integer work array of length m.


Called by

proc~~setr~~CalledByGraph proc~setr dsm_module::setr proc~dsm dsm_module::dsm proc~dsm->proc~setr proc~dsm_wrapper numerical_differentiation_module::sparsity_pattern%dsm_wrapper proc~dsm_wrapper->proc~dsm proc~compute_sparsity_random numerical_differentiation_module::compute_sparsity_random proc~compute_sparsity_random->proc~dsm_wrapper proc~compute_sparsity_random_2 numerical_differentiation_module::compute_sparsity_random_2 proc~compute_sparsity_random_2->proc~dsm_wrapper proc~set_sparsity_pattern numerical_differentiation_module::numdiff_type%set_sparsity_pattern proc~set_sparsity_pattern->proc~dsm_wrapper

Source Code

    subroutine setr(m,n,Indrow,Jpntr,Indcol,Ipntr,Iwa)

    implicit none

    integer,intent(in)     :: m       !! a positive integer input variable set to the number
                                      !! of rows of `a`.
    integer,intent(in)     :: n       !! a positive integer input variable set to the number
                                      !! of columns of `a`.
    integer,dimension(*)   :: Indrow  !! an integer input array which contains the row
                                      !! indices for the non-zeroes in the matrix `a`.
    integer,dimension(n+1) :: Jpntr   !! an integer input array of length `n + 1` which
                                      !! specifies the locations of the row indices in `indrow`.
                                      !! the row indices for column `j` are
                                      !! `indrow(k), k = jpntr(j),...,jpntr(j+1)-1`.
                                      !! **note** that `jpntr(n+1)-1` is then the number of non-zero
                                      !! elements of the matrix `a`.
    integer,dimension(*)   :: Indcol  !! an integer output array which contains the
                                      !! column indices for the non-zeroes in the matrix `a`.
    integer,dimension(m+1) :: Ipntr   !! an integer output array of length `m + 1` which
                                      !! specifies the locations of the column indices in `indcol`.
                                      !! the column indices for row `i` are
                                      !! `indcol(k), k = ipntr(i),...,ipntr(i+1)-1`.
                                      !! **note** that `ipntr(1)` is set to 1 and that `ipntr(m+1)-1` is
                                      !! then the number of non-zero elements of the matrix `a`.
    integer,dimension(m)   :: Iwa     !! an integer work array of length `m`.

    integer :: ir , jcol , jp

    ! store in array iwa the counts of non-zeroes in the rows.

    do ir = 1 , m
        Iwa(ir) = 0
    enddo
    do jp = 1 , Jpntr(n+1) - 1
        Iwa(Indrow(jp)) = Iwa(Indrow(jp)) + 1
    enddo

    ! set pointers to the start of the rows in indcol.

    Ipntr(1) = 1
    do ir = 1 , m
        Ipntr(ir+1) = Ipntr(ir) + Iwa(ir)
        Iwa(ir) = Ipntr(ir)
    enddo

    ! fill indcol.

    do jcol = 1 , n
        do jp = Jpntr(jcol) , Jpntr(jcol+1) - 1
            ir = Indrow(jp)
            Indcol(Iwa(ir)) = jcol
            Iwa(ir) = Iwa(ir) + 1
        enddo
    enddo

    end subroutine setr