# p?lapiv

Applies a permutation matrix to a general distributed matrix, resulting in row or column pivoting.

## Syntax

call pslapiv(direc, rowcol, pivroc, m, n, a, ia, ja, desca, ipiv, ip, jp, descip, iwork)

call pdlapiv(direc, rowcol, pivroc, m, n, a, ia, ja, desca, ipiv, ip, jp, descip, iwork)

call pclapiv(direc, rowcol, pivroc, m, n, a, ia, ja, desca, ipiv, ip, jp, descip, iwork)

call pzlapiv(direc, rowcol, pivroc, m, n, a, ia, ja, desca, ipiv, ip, jp, descip, iwork)

## Description

This routine applies either P (permutation matrix indicated by ipiv) or inv(P) to a general m-by-n distributed matrix sub`(A) = A(ia:ia+m-1`, `ja:ja+n-1)`, resulting in row or column pivoting. The pivot vector may be distributed across a process row or a column. The pivot vector should be aligned with the distributed matrix A. This routine will transpose the pivot vector, if necessary.

For example, if the row pivots should be applied to the columns of sub(A), pass `rowcol='C' and `pivroc='C'``.

## Input Parameters

direc

  (global) CHARACTER*1.

  Specifies in which order the permutation is applied:

  = 'F' (Forward). Applies pivots forward from top of matrix. Computes `P*sub(A)`.

  = 'B' (Backward). Applies pivots backward from bottom of matrix. Computes `inv(P)*sub(A)`.

rowcol

  (global) CHARACTER*1.

  Specifies if the rows or columns are to be permuted:

  = 'R' Rows will be permuted,

  = 'C' Columns will be permuted.

pivroc

  (global) CHARACTER*1.

  Specifies whether ipiv is distributed over a process row or column:

  = 'R'ipiv is distributed over a process row,

  = 'C'ipiv is distributed over a process column.

m

  (global) INTEGER.

  The number of rows to be operated on, that is, the number of rows of the distributed submatrix sub(A). When `m = 0`, p?lapiv is set to zero. `m ≥ 0`.

n

  (global) INTEGER.

  The number of columns to be operated on, that is, the number of columns of the distributed submatrix sub(A). When `n = 0`, p?lapiv is set to zero. n ≥ 0.

a

  (local).

  Real for pslapiv

  DOUBLE PRECISION for pdlapiv

  COMPLEX for pclapiv

  COMPLEX*16 for pzlapiv.

  Pointer into the local memory to an array of DIMENSION`(lld_a, LOCc(ja+n-1))` containing the local pieces of the distributed matrix sub(A).

ia, ja

  (global) INTEGER.

  The row and column indices in the global array A indicating the first row and the first column of the submatrix sub(A), respectively.

desca

  (global and local) INTEGER array, DIMENSION (dlen_). The array descriptor for the distributed matrix A.

ipiv

  (local). INTEGER.

  Array, DIMENSION (lipiv) ;

  when `rowcol='R'` or 'r':

  `lipiv≥LOCr(ia+m-1) + mb_a` if `pivroc='C'` or 'c',

  `lipiv≥LOCc(m + mod(jp-1, nb_p))` if `pivroc='R'` or 'r', and,

  when `rowcol='C'` or 'c':

  `lipiv≥LOCr(n + mod(ip-1, mb_p))` if `pivroc='C'` or 'c',

  `lipiv≥LOCc(ja+n-1) + nb_a` if `pivroc='R'` or 'r'.

  This array contains the pivoting information. `ipiv(i)` is the global row (column), local row (column) i was swapped with. When `rowcol='R'` or 'r' and `pivroc='C'` or 'c', or `rowcol='C'` or 'c' and `pivroc='R'` or 'r', the last piece of this array of size mb_a (resp. nb_a) is used as workspace. In those cases, this array is tied to the distributed matrix A.

ip, jp

  (global) INTEGER. The row and column indices in the global array P indicating the first row and the first column of the submatrix sub(P), respectively.

descip

  (global and local) INTEGER array, DIMENSION (dlen_). The array descriptor for the distributed vector ipiv.

iwork

  (local). INTEGER.

  Array, DIMENSION (ldw), where ldw is equal to the workspace necessary for transposition, and the storage of the tranposed ipiv :

  Let lcm be the least common multiple of nprow and npcol.
  `If( rowcol.eq.'r' .and. pivroc. eq.'r') then`
  `If( nprow.eq. npcol) then`
  `ldw = LOCr( n_p + mod(jp-1, nb_p) ) + nb_p`
  `else`
  `ldw = LOCr( n_p + mod(jp-1, nb_p) )+`
  `nb_p * ceil( ceil(LOCc(n_p)/nb_p) / (lcm/npcol) )`
  `end if`
  `else if( rowcol.eq.'c' .and. pivroc.eq.'c') then`
  `if( nprow.eq.`
  `npcol ) then`
  `ldw = LOCc( m_p + mod(ip-1, mb_p) ) + mb_p`
  `else`
  `ldw = LOCc( m_p + mod(ip-1, mb_p) ) +`
  `mb_p *ceil(ceil(LOCr(m_p)/mb_p) / (lcm/nprow) )`
  `end if`
  `else`
  `iwork is not referenced.`
  `end if.`

## Output Parameters

a

  (local).

  On exit, the local pieces of the permuted distributed submatrix.

Parent topic: Auxiliary Routines