PDRSCL(l)
π PDRSCL(l) β LAPACK auxiliary routine, but make it make sense π
okay so bestie, you've wandered into PDRSCL(l), which is a whole LAPACK auxiliary routine, and I am obsessed with explaining it to you. It's giving "tiny but mighty". It's giving "one job, done flawlessly". Let's go. π«Ά
β¨ NAME β¨
PDRSCL β multiplie an N-element real distributed vector sub( X ) by the real scalar 1/a π
(yes, "multiplie". we don't fix the ancestors' spelling, we <em>respect</em> it. periodt.)
β¨ SYNOPSIS β¨
SUBROUTINE PDRSCL( N, SA, SX, IX, JX, DESCX, INCX )
INTEGER IX, INCX, JX, N
DOUBLE PRECISION SA
INTEGER DESCX( * )
DOUBLE PRECISION SX( * )
β¨ PURPOSE β¨
So PDRSCL multiplies an N-element real distributed vector sub( X ) by the real scalar 1/a. π
And the iconic part? It does this without overflow or underflow β as long as the final result sub( X )/a doesn't overflow or underflow. Like, it's careful. It's thoughtful. It's the friend who double-checks the group chat plans. β¨
And here's what sub( X ) actually means, literally:
where sub( X ) denotes X(IX:IX+N-1,JX:JX), if INCX = 1,
X(IX:IX,JX:JX+N-1), if INCX = M_X.
πΈ Notes πΈ
Each global data object is described by an associated description vector. This vector stores the info you need to map an object element to its corresponding process and memory location. 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 comments below, read the character _ as "of the global array". π
DT_Aβ (global) β stored indescA[ DT_ ]β the descriptor type. In this case,DT_A = 1.CTXT_Aβ (global) β stored indescA[ 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 indescA[ M_ ]β the number of rows in the global array A.N_Aβ (global) β stored indescA[ N_ ]β the number of columns in the global array A.MB_Aβ (global) β stored indescA[ MB_ ]β the blocking factor used to distribute the rows of the array.NB_Aβ (global) β stored indescA[ NB_ ]β the blocking factor used to distribute the columns of the array.RSRC_Aβ (global) β stored indescA[ RSRC_ ]β the process row over which the first row of the array A is distributed.CSRC_Aβ (global) β stored indescA[ CSRC_ ]β the process column over which the first column of the array A is distributed.LLD_Aβ (local) β stored indescA[ 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 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 seen as particular matrices, a distributed vector is considered to be a distributed matrix. π
β¨ ARGUMENTS β¨
Nβ (global input) pointer toINTEGERβ the number of components of the distributed vectorsub( X ).N >= 0. βSAβ (global input)DOUBLE PRECISIONβ the scalarawhich is used to divide each component ofsub( X ).SAmust be>= 0, or the subroutine will divide by zero. π (not me warning you about a literal division-by-zero. it's real. be careful.)SXβ (local input/local output)DOUBLE PRECISIONarray β contains the local pieces of a distributed matrix of dimension of at least( (JX-1)*M_X + IX + ( N - 1 )*abs( INCX ) ). This array contains the entries of the distributed vectorsub( X ). πΈIXβ (global input) pointer toINTEGERβ the global row index of the submatrix of the distributed matrixXto operate on.JXβ (global input) pointer toINTEGERβ the global column index of the submatrix of the distributed matrixXto operate on.DESCXβ (global and local input)INTEGERarray of dimension 8 β the array descriptor of the distributed matrixX. πINCXβ (global input) pointer toINTEGERβ the global increment for the elements ofX. Only two values ofINCXare supported in this version, namely1andM_X. no cap, just those two. β¨
tl;dr: divide your distributed vector bya, don't letSAhit zero, and only ever passINCX = 1orINCX = M_X. slay responsibly. π
okay that's the whole thing, bestie, you ate it π β this was LAPACK version 1.5, dated 12 May 1997. go forth and divide with main character energy. πβ¨π
π¦ where this page comes from
- ubuntu jammy: scalapack-doc 1.5-11
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms