PZLASSQ(l)

πŸ“¦ version 1.5, in ubuntu jammy

✨ PZLASSQ ✨

okay bestie, gather round, because this is a LAPACK auxiliary routine and its whole entire job is to hand you back two little numbers and not make a big deal about it. it's giving quiet luxury. πŸ’…


πŸ’– NAME πŸ’–

PZLASSQ β€” returns the values scl and smsq such that

( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,

like, that's it. that's the whole vibe. 🌸


πŸŽ€ SYNOPSIS πŸŽ€

SUBROUTINE PZLASSQ( N, X, IX, JX, DESCX, INCX, SCALE, SUMSQ )

    INTEGER         IX, INCX, JX, N

    DOUBLE          PRECISION SCALE, SUMSQ

    INTEGER         DESCX( * )

    COMPLEX*16      X( * )

πŸ¦‹ PURPOSE πŸ¦‹

so PZLASSQ returns the values scl and smsq such that

( scl**2 )*smsq = x( 1 )**2 +...+ x( n )**2 + ( scale**2 )*sumsq,

where

x( i ) = sub( X ) = abs( X( IX+(JX-1)*DESCX(M_)+(i-1)*INCX ) ).

the value of sumsq is assumed to be at least unity, and the value of ssq will then satisfy

1.0 .le. ssq .le. ( sumsq + 2*n ).

scale is assumed to be non-negative, and scl returns the value

scl = max( scale, abs( real( x( i ) ) ), abs( aimag( x( i ) ) ) ),
       i

scale and sumsq must be supplied in SCALE and SUMSQ respectively. and then, plot twist, SCALE and SUMSQ get overwritten by scl and ssq respectively. so yeah, your inputs are gone, they're ✨transformed✨. glow up moment.

the routine makes only one pass through the vector sub( X ). one. pass. efficient queen. πŸ‘‘


πŸ“ Notes πŸ“

🧚 the descriptor lore (iykyk)

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.

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)).

🌈 LOCr and LOCc, the iconic duo

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

πŸ’œ vectors are just baby matrices

because vectors may be viewed as a subclass of matrices, a distributed vector is considered to be a distributed matrix. no cap. a vector is a matrix that said "i'm lowkey small" and we respect that. πŸ“

😭 the sad part (scope)

the results are only available in the scope of sub( X ), i.e. if sub( X ) is distributed along a process row, the correct results are only available in this process row of the grid. similarly, if sub( X ) is distributed along a process column, the correct results are only available in this process column of the grid.

so don't go looking for your answer outside the grid neighborhood. it does not commute. it does not travel. it stays home. πŸ’€

🌟 ARGUMENTS 🌟

  • N β€” (global input) INTEGER. the length of the distributed vector sub( X ). πŸ“
  • X β€” (input) COMPLEX*16. the vector for which a scaled sum of squares is computed.
x( i ) = X(IX+(JX-1)*M_X +(i-1)*INCX ), 1 <= i <= n.
  • IX β€” (global input) INTEGER. the row index in the global array X indicating the first row of sub( X ).
  • JX β€” (global input) INTEGER. the column index in the global array X indicating the first column of sub( X ).
  • DESCX β€” (global and local input) INTEGER array of dimension DLEN_. the array descriptor for the distributed matrix X.
  • INCX β€” (global input) INTEGER. the global increment for the elements of X. only two values of INCX are supported in this version, namely 1 and M_X. INCX must not be zero. ⚠️
  • SCALE β€” (local input/local output) DOUBLE PRECISION. on entry, the value scale in the equation above. on exit, SCALE is overwritten with scl, the scaling factor for the sum of squares. ✨
  • SUMSQ β€” (local input/local output) DOUBLE PRECISION. on entry, the value sumsq in the equation above. on exit, SUMSQ is overwritten with smsq, the basic sum of squares from which scl has been factored out.

and that's the whole page bestie, you understood it, i'm so proud of you, main character energy fr fr 🫢

this one came straight out of LAPACK version 1.5, dated 12 May 1997 β€” yeah it's vintage, it's archival, it's a classic, and it still slays. πŸ’– ✨

πŸ“¦ where this page comes from