PCLARZC(l)

πŸ“¦ version 1.5, in ubuntu jammy

πŸ’– PCLARZC πŸ’–

okay so bestie, this is a LAPACK auxiliary routine from way back β€” version 1.5, the vintage drop β€” and her whole thing is applying a complex elementary reflector Q**H to a complex M-by-N distributed matrix. she's giving very much "linear algebra but make it a group project across your whole process grid" energy and honestly? obsessed. let's get into it πŸ¦‹


✨ NAME ✨

PCLARZC β€” she applies a complex elementary reflector Q**H to a complex M-by-N distributed matrix sub( C ) = C(IC:IC+M-1,JC:JC+N-1). no cap, that's the whole job description πŸ’…


🌸 SYNOPSIS 🌸

SUBROUTINE PCLARZC( SIDE, M, N, L, V, IV, JV, DESCV, INCV, TAU, C, IC,
                    JC, DESCC, WORK )

    CHARACTER       SIDE

    INTEGER         IC, INCV, IV, JC, JV, L, M, N

    INTEGER         DESCC( * ), DESCV( * )

    COMPLEX         C( * ), TAU( * ), V( * ), WORK( * )

πŸ‘‘ PURPOSE πŸ‘‘

PCLARZC applies a complex elementary reflector Q**H to a complex M-by-N distributed matrix sub( C ) = C(IC:IC+M-1,JC:JC+N-1), from either the left or the right. she does not care which side, she is versatile like that 🫢

Q is represented in the form

Q = I - tau * v * v'

where tau is a complex scalar and v is a complex vector.

If tau = 0, then Q is taken to be the unit matrix. (she said "no notes, I'm the identity now" ✨)

Q is a product of k elementary reflectors as returned by PCTZRZF.


πŸ“ Notes

each global data object is described by an associated description vector. this vector stores the information required to establish the mapping between an object element and its corresponding process and memory location. it's like a little passport for your data, iykyk πŸŽ€

let A be a generic term for any 2D block cyclicly distributed array. such a global array has an associated description vector DESCA. in the following comments, the character _ should be read as "of the global array".

  • DTYPE_A (global) β€” stored in DESCA( DTYPE_ ) β€” the descriptor type. in this case, DTYPE_A = 1.
  • CTXT_A (global) β€” stored in DESCA( CTXT_ ) β€” the BLACS context handle, indicating the BLACS process grid A is distributed over. the context itself is global, but the handle (the integer value) may vary.
  • M_A (global) β€” stored in DESCA( M_ ) β€” the number of rows in the global array A.
  • N_A (global) β€” stored in DESCA( N_ ) β€” the number of columns in the global array A.
  • MB_A (global) β€” stored in DESCA( MB_ ) β€” the blocking factor used to distribute the rows of the array.
  • NB_A (global) β€” stored in DESCA( NB_ ) β€” the blocking factor used to distribute the columns of the array.
  • RSRC_A (global) β€” stored in DESCA( RSRC_ ) β€” the process row over which the first row of the array A is distributed.
  • CSRC_A (global) β€” stored in DESCA( CSRC_ ) β€” the process column over which the first column of the array A is distributed.
  • LLD_A (local) β€” stored in DESCA( LLD_ ) β€” the leading dimension of the local array. LLD_A >= MAX(1,LOCr(M_A)).

let K be the number of rows or columns of a distributed matrix, and assume that its process grid has dimension p x q.

LOCr( K ) denotes the number of elements of K that a process would receive if K were distributed over the p processes of its process column.

similarly, LOCc( K ) denotes the number of elements of K that a process would receive if K were distributed over the q processes of its process row.

the values of LOCr() and LOCc() may be determined via a call to the ScaLAPACK tool function, NUMROC:

LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).

an upper bound for these quantities may be computed by:

LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A

because vectors may be viewed as a subclass of matrices, a distributed vector is considered to be a distributed matrix. periodt. πŸ’…


🚫 Restrictions

listen up bestie, these are not suggestions, these are the rules:

if SIDE = 'Left' and INCV = 1, then the row process having the first entry V(IV,JV) must also own C(IC+M-L,JC:JC+N-1). moreover, MOD(IV-1,MB_V) must be equal to MOD(IC+N-L-1,MB_C), if INCV=M_V, only the last equality must be satisfied.

if SIDE = 'Right' and INCV = M_V then the column process having the first entry V(IV,JV) must also own C(IC:IC+M-1,JC+N-L) and MOD(JV-1,NB_V) must be equal to MOD(JC+N-L-1,NB_C), if INCV = 1 only the last equality must be satisfied.

😭 yeah it's giving "who owns which block" homework but fr fr, if you get this wrong the whole thing falls apart. respect the alignment.

🌈 ARGUMENTS 🌈

  • SIDE β€” (global input) CHARACTER
    • = 'L': form Q**H * sub( C ),
    • = 'R': form sub( C ) * Q**H.
  • M β€” (global input) INTEGER. the number of rows to be operated on i.e the number of rows of the distributed submatrix sub( C ). M >= 0.
  • N β€” (global input) INTEGER. the number of columns to be operated on i.e the number of columns of the distributed submatrix sub( C ). N >= 0.
  • L β€” (global input) INTEGER. the columns of the distributed submatrix sub( A ) containing the meaningful part of the Householder reflectors. if SIDE = 'L', M >= L >= 0, if SIDE = 'R', N >= L >= 0.
  • V β€” (local input) COMPLEX pointer into the local memory to an array of dimension (LLD_V,*) containing the local pieces of the distributed vectors V representing the Householder transformation Q,
    • V(IV:IV+L-1,JV) if SIDE = 'L' and INCV = 1,
    • V(IV,JV:JV+L-1) if SIDE = 'L' and INCV = M_V,
    • V(IV:IV+L-1,JV) if SIDE = 'R' and INCV = 1,
    • V(IV,JV:JV+L-1) if SIDE = 'R' and INCV = M_V,

the vector v in the representation of Q. V is not used if TAU = 0.

  • IV β€” (global input) INTEGER. the row index in the global array V indicating the first row of sub( V ).
  • JV β€” (global input) INTEGER. the column index in the global array V indicating the first column of sub( V ).
  • DESCV β€” (global and local input) INTEGER array of dimension DLEN_. the array descriptor for the distributed matrix V.
  • INCV β€” (global input) INTEGER. the global increment for the elements of V. only two values of INCV are supported in this version, namely 1 and M_V. INCV must not be zero.
  • TAU β€” (local input) COMPLEX, array, dimension LOCc(JV) if INCV = 1, and LOCr(IV) otherwise. this array contains the Householder scalars related to the Householder vectors. TAU is tied to the distributed matrix V.
  • C β€” (local input/local output) COMPLEX pointer into the local memory to an array of dimension (LLD_C, LOCc(JC+N-1) ), containing the local pieces of sub( C ). on exit, sub( C ) is overwritten by the Q**H * sub( C ) if SIDE = 'L', or sub( C ) * Q**H if SIDE = 'R'. πŸ’₯
  • IC β€” (global input) INTEGER. the row index in the global array C indicating the first row of sub( C ).
  • JC β€” (global input) INTEGER. the column index in the global array C indicating the first column of sub( C ).
  • DESCC β€” (global and local input) INTEGER array of dimension DLEN_. the array descriptor for the distributed matrix C.
  • WORK β€” (local workspace) COMPLEX array, dimension (LWORK)

here comes the iconic nested-if situation, bestie. hold on tight:

If INCV = 1,
   if SIDE = 'L',
      if IVCOL = ICCOL,
         LWORK >= NqC0
      else
         LWORK >= MpC0 + MAX( 1, NqC0 )
      end if
   else if SIDE = 'R',
      LWORK >= NqC0 + MAX( MAX( 1, MpC0 ), NUMROC( NUMROC(
               N+ICOFFC,NB_V,0,0,NPCOL ),NB_V,0,0,LCMQ ) )
   end if
else if INCV = M_V,
   if SIDE = 'L',
      LWORK >= MpC0 + MAX( MAX( 1, NqC0 ), NUMROC( NUMROC(
               M+IROFFC,MB_V,0,0,NPROW ),MB_V,0,0,LCMP ) )
   else if SIDE = 'R',
      if IVROW = ICROW,
         LWORK >= MpC0
      else
         LWORK >= NqC0 + MAX( 1, MpC0 )
      end if
   end if
end if

where LCM is the least common multiple of NPROW and NPCOL and

LCM = ILCM( NPROW, NPCOL ), LCMP = LCM / NPROW, LCMQ = LCM / NPCOL,
IROFFC = MOD( IC-1, MB_C ), ICOFFC = MOD( JC-1, NB_C ),
ICROW = INDXG2P( IC, MB_C, MYROW, RSRC_C, NPROW ),
ICCOL = INDXG2P( JC, NB_C, MYCOL, CSRC_C, NPCOL ),
MpC0 = NUMROC( M+IROFFC, MB_C, MYROW, ICROW, NPROW ),
NqC0 = NUMROC( N+ICOFFC, NB_C, MYCOL, ICCOL, NPCOL ),

ILCM, INDXG2P and NUMROC are ScaLAPACK tool functions; MYROW, MYCOL, NPROW and NPCOL can be determined by calling the subroutine BLACS_GRIDINFO.


🧚 Alignment requirements

the distributed submatrices V(IV:*, JV:*) and C(IC:IC+M-1,JC:JC+N-1) must verify some alignment properties, namely the following expressions should be true:

MB_V = NB_V,
If INCV = 1,
   If SIDE = 'Left',
      ( MB_V.EQ.MB_C .AND. IROFFV.EQ.IROFFC .AND. IVROW.EQ.ICROW )
   If SIDE = 'Right',
      ( MB_V.EQ.NB_A .AND. MB_V.EQ.NB_C .AND. IROFFV.EQ.ICOFFC )
else if INCV = M_V,
   If SIDE = 'Left',
      ( MB_V.EQ.NB_V .AND. MB_V.EQ.MB_C .AND. ICOFFV.EQ.IROFFC )
   If SIDE = 'Right',
      ( NB_V.EQ.NB_C .AND. ICOFFV.EQ.ICOFFC .AND. IVCOL.EQ.ICCOL )
end if

πŸŽ€ and that's the whole page, bestie. go forth, distribute your matrices, and slay responsibly ✨

this has been PCLARZC(l) from LAPACK version 1.5, dated 12 May 1997 β€” a true vintage icon, no cap. πŸ’–πŸ‘‘πŸ’…

πŸ“¦ where this page comes from