PDSYEVX(l)
๐ PDSYEVX ๐ โ LAPACK routine (version 1.5)
okay bestie, sit down, hydrate, because PDSYEVX(l) is a whole moment and we're doing this properly ๐ this is part one of three, so no skipping ahead, we have so much to get through together ๐ซถ
โจ NAME โจ
PDSYEVX โ she computes selected eigenvalues and, if you ask nicely, eigenvectors of a real symmetric matrix A by calling the recommended sequence of ScaLAPACK routines. iconic behavior, honestly ๐
๐ธ SYNOPSIS ๐ธ
SUBROUTINE PDSYEVX( JOBZ, RANGE, UPLO, N, A, IA, JA, DESCA, VL, VU, IL,
IU, ABSTOL, M, NZ, W, ORFAC, Z, IZ, JZ, DESCZ, WORK,
LWORK, IWORK, LIWORK, IFAIL, ICLUSTR, GAP, INFO )
CHARACTER JOBZ, RANGE, UPLO
INTEGER IA, IL, INFO, IU, IZ, JA, JZ, LIWORK, LWORK, M, N,
NZ
DOUBLE PRECISION ABSTOL, ORFAC, VL, VU
INTEGER DESCA( * ), DESCZ( * ), ICLUSTR( * ), IFAIL( * ),
IWORK( * )
DOUBLE PRECISION A( * ), GAP( * ), W( * ), WORK( * ), Z( *
)
INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_, MB_,
NB_, RSRC_, CSRC_, LLD_
PARAMETER ( BLOCK_CYCLIC_2D = 1, DLEN_ = 9, DTYPE_ = 1, CTXT_
= 2, M_ = 3, N_ = 4, MB_ = 5, NB_ = 6, RSRC_ = 7,
CSRC_ = 8, LLD_ = 9 )
DOUBLE PRECISION ZERO, ONE, TEN, FIVE
PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0, TEN = 10.0D+0, FIVE =
5.0D+0 )
INTEGER IERREIN, IERRCLS, IERRSPC, IERREBZ
PARAMETER ( IERREIN = 1, IERRCLS = 2, IERRSPC = 4, IERREBZ = 8
)
LOGICAL ALLEIG, INDEIG, LOWER, LQUERY, QUICKRETURN, VALEIG,
WANTZ
CHARACTER ORDER
INTEGER CSRC_A, I, IACOL, IAROW, ICOFFA, IINFO, INDD, INDD2,
INDE, INDE2, INDIBL, INDISP, INDTAU, INDWORK,
IROFFA, IROFFZ, ISCALE, ISIZESTEBZ, ISIZESTEIN,
IZROW, LALLWORK, LIWMIN, LLWORK, LWMIN, MAXEIGS,
MB_A, MB_Z, MQ0, MYCOL, MYROW, NB, NB_A, NB_Z, NEIG,
NN, NNP, NP0, NPCOL, NPROCS, NPROW, NSPLIT, NZZ,
OFFSET, RSRC_A, RSRC_Z, SIZEORMTR, SIZESTEIN,
SIZESYEVX
DOUBLE PRECISION ABSTLL, ANRM, BIGNUM, EPS, RMAX, RMIN,
SAFMIN, SIGMA, SMLNUM, VLL, VUU
INTEGER IDUM1( 4 ), IDUM2( 4 )
LOGICAL LSAME
INTEGER ICEIL, INDXG2P, NUMROC
DOUBLE PRECISION PDLAMCH, PDLANSY
EXTERNAL LSAME, ICEIL, INDXG2P, NUMROC, PDLAMCH, PDLANSY
EXTERNAL BLACS_GRIDINFO, CHK1MAT, DGEBR2D, DGEBS2D, DLASRT,
DSCAL, IGAMN2D, PCHK2MAT, PDELGET, PDLARED1D,
PDLASCL, PDORMTR, PDSTEBZ, PDSTEIN, PDSYTRD, PXERBLA
INTRINSIC ABS, DBLE, ICHAR, MAX, MIN, MOD, SQRT
like. look at her. that's a lot of arguments and she's carrying them all without breaking a sweat ๐
๐ PURPOSE ๐
So PDSYEVX computes selected eigenvalues and, optionally, eigenvectors of a real symmetric matrix A by calling the recommended sequence of ScaLAPACK routines. โจ
You can pick which ones you want either by specifying a range of values or by specifying a range of indices for the desired eigenvalues. choose your own adventure, but make it linear algebra ๐
๐ฆ NOTES ๐ฆ
๐ descriptors, babe
Every 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 the little ID card every distributed array carries around ๐ชช
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". iykyk ๐ซ
DTYPE_A(global) โ stored inDESCA( DTYPE_ )โ the descriptor type. In this case,DTYPE_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 arrayA.N_A(global) โ stored inDESCA( N_ )โ the number of columns in the global arrayA.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 arrayAis distributed.CSRC_A(global) โ stored inDESCA( CSRC_ )โ the process column over which the first column of the arrayAis distributed.LLD_A(local) โ stored inDESCA( LLD_ )โ the leading dimension of the local array.LLD_A >= MAX(1,LOCr(M_A)).
๐ the LOCr / LOCc lore
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
โ ๏ธ the IEEE 754 thing (important, no cap)
PDSYEVX assumes IEEE 754 standard compliant arithmetic. To port to a system which does not have IEEE 754 arithmetic, modify the appropriate SLmake.inc file to include the compiler switch -DNO_IEEE. This switch only affects the compilation of pdlaiect.c.
bestie that's a port, not a vibe. if you're not on IEEE 754, you have to actually go touch SLmake.inc. there's no way around it ๐
๐ ARGUMENTS ๐
okay this is the big one. deep breath. we're going through every single one ๐
NP = the number of rows local to a given process.
NQ = the number of columns local to a given process.
JOBZ(global input)CHARACTER*1โ specifies whether or not to compute the eigenvectors:= 'N': Compute eigenvalues only.= 'V': Compute eigenvalues and eigenvectors.
RANGE(global input)CHARACTER*1= 'A': all eigenvalues will be found.= 'V': all eigenvalues in the interval[VL,VU]will be found.= 'I': theIL-th throughIU-th eigenvalues will be found.
UPLO(global input)CHARACTER*1โ specifies whether the upper or lower triangular part of the symmetric matrixAis stored:= 'U': Upper triangular= 'L': Lower triangular
N(global input)INTEGERโ the number of rows and columns of the matrixA.N >= 0.A(local input/workspace) block cyclicDOUBLE PRECISIONarray, global dimension(N, N), local dimension( LLD_A, LOCc(JA+N-1) ).
On entry, the symmetric matrix A. If UPLO = 'U', only the upper triangular part of A is used to define the elements of the symmetric matrix. If UPLO = 'L', only the lower triangular part of A is used to define the elements of the symmetric matrix.
On exit, the lower triangle (if UPLO='L') or the upper triangle (if UPLO='U') of A, including the diagonal, is destroyed.
yeah she eats your matrix. that's the deal. ๐ copy it first if you're sentimental.
IA(global input)INTEGERโA's global row index, which points to the beginning of the submatrix which is to be operated on.JA(global input)INTEGERโA's global column index, which points to the beginning of the submatrix which is to be operated on.DESCA(global and local input)INTEGERarray of dimensionDLEN_. The array descriptor for the distributed matrixA. IfDESCA( CTXT_ )is incorrect,PDSYEVXcannot guarantee correct error reporting.VL(global input)DOUBLE PRECISIONโ ifRANGE='V', the lower bound of the interval to be searched for eigenvalues. Not referenced ifRANGE = 'A'or'I'.VU(global input)DOUBLE PRECISIONโ ifRANGE='V', the upper bound of the interval to be searched for eigenvalues. Not referenced ifRANGE = 'A'or'I'.IL(global input)INTEGERโ ifRANGE='I', the index (from smallest to largest) of the smallest eigenvalue to be returned.IL >= 1. Not referenced ifRANGE = 'A'or'V'.IU(global input)INTEGERโ ifRANGE='I', the index (from smallest to largest) of the largest eigenvalue to be returned.min(IL,N) <= IU <= N. Not referenced ifRANGE = 'A'or'V'.ABSTOL(global input)DOUBLE PRECISIONโ okay this one has layers, stay with me ๐
If JOBZ='V', setting ABSTOL to PDLAMCH( CONTEXT, 'U') yields the most orthogonal eigenvectors. (slay.)
This is the absolute error tolerance for the eigenvalues. An approximate eigenvalue is accepted as converged when it is determined to lie in an interval [a,b] of width less than or equal to
ABSTOL + EPS * max( |a|,|b| ) ,
where EPS is the machine precision. If ABSTOL is less than or equal to zero, then EPS*norm(T) will be used in its place, where norm(T) is the 1-norm of the tridiagonal matrix obtained by reducing A to tridiagonal form.
Eigenvalues will be computed most accurately when ABSTOL is set to twice the underflow threshold 2*PDLAMCH('S') not zero. If this routine returns with ((MOD(INFO,2).NE.0) .OR. (MOD(INFO/8,2).NE.0)), indicating that some eigenvalues or eigenvectors did not converge, try setting ABSTOL to 2*PDLAMCH('S').
not zero. she said what she said. 2*PDLAMCH('S'). not zero. ๐
See "Computing Small Singular Values of Bidiagonal Matrices with Guaranteed High Relative Accuracy," by Demmel and Kahan, LAPACK Working Note #3.
See "On the correctness of Parallel Bisection in Floating Point" by Demmel, Dhillon and Ren, LAPACK Working Note #70
M(global output)INTEGERโ total number of eigenvalues found.0 <= M <= N.
part 1 of 3 done, bestie โ keep scrolling, there's so much more ๐
NZ(global output) INTEGER โ bestie, this is the total number of eigenvectors that actually got computed. 0 <= NZ <= M. It's literally the number of columns ofZthat are filled in. IfJOBZ .NE. 'V', thenNZis not referenced at all (like, ignore it). IfJOBZ .EQ. 'V', thenNZ = Munless you gave insufficient space andPDSYEVXcouldn't detect that before starting the computation. To get all the eigenvectors you asked for, you gotta supply both sufficient space to hold the eigenvectors inZ(soM .LE. DESCZ(N_)) and sufficient workspace to compute them. (SeeLWORKbelow, okay?)PDSYEVXis always able to detect insufficient space without computation unlessRANGE .EQ. 'V'. ๐W(global output) DOUBLE PRECISION array, dimension (N) โ on a normal exit, the firstMentries contain the selected eigenvalues in ascending order. Slay. โจORFAC(global input) DOUBLE PRECISION โ this specifies which eigenvectors should be reorthogonalized. Eigenvectors that correspond to eigenvalues which are withintol=ORFAC*norm(A)of each other are to be reorthogonalized. However, if the workspace is insufficient (seeLWORK),tolmay be decreased until all eigenvectors to be reorthogonalized can be stored in one process. No reorthogonalization will be done ifORFACequals zero. A default value of10^-3is used ifORFACis negative.ORFACshould be identical on all processes. ๐Z(local output) DOUBLE PRECISION array, global dimension (N, N), local dimension ( LLD_Z, LOCc(JZ+N-1) ) โ ifJOBZ = 'V', then on normal exit the firstMcolumns ofZcontain the orthonormal eigenvectors of the matrix corresponding to the selected eigenvalues. If an eigenvector fails to converge, then that column ofZcontains the latest approximation to the eigenvector, and the index of the eigenvector is returned inIFAIL. IfJOBZ = 'N', thenZis not referenced. No cap. ๐ฆIZ(global input) INTEGER โZ's global row index, which points to the beginning of the submatrix which is to be operated on. ๐JZ(global input) INTEGER โZ's global column index, which points to the beginning of the submatrix which is to be operated on. ๐DESCZ(global and local input) INTEGER array of dimension DLEN_. โ the array descriptor for the distributed matrixZ.DESCZ( CTXT_ )must equalDESCA( CTXT_ ). Fr fr. ๐WORK(local workspace/output) DOUBLE PRECISION array, dimension (LWORK) โ on return,WROK(1)contains the optimal amount of workspace required for efficient execution. (Yes, the original saysWROK(1)โ we keep it exactly, bestie. ๐ญ)- if
JOBZ='N'WORK(1)= optimal amount of workspace required to compute eigenvalues efficiently - if
JOBZ='V'WORK(1)= optimal amount of workspace required to compute eigenvalues and eigenvectors efficiently with no guarantee on orthogonality. IfRANGE='V', it is assumed that all eigenvectors may be required.
- if
LWORK(local input) INTEGER โ size ofWORK. See below for definitions of variables used to defineLWORK.- If no eigenvectors are requested (
JOBZ = 'N') then
- If no eigenvectors are requested (
LWORK >= 5 * N + MAX( 5 * NN, NB * ( NP0 + 1 ) )
- If eigenvectors are requested (
JOBZ = 'V') then the amount of workspace required to guarantee that all eigenvectors are computed is:
LWORK >= 5*N + MAX( 5*NN, NP0 * MQ0 + 2 * NB * NB ) +
ICEIL( NEIG, NPROW*NPCOL)*NN
- The computed eigenvectors may not be orthogonal if the minimal workspace is supplied and
ORFACis too small. If you want to guarantee orthogonality (at the cost of potentially poor performance) you should add the following toLWORK:
(CLUSTERSIZE-1)*N
where CLUSTERSIZE is the number of eigenvalues in the largest cluster, where a cluster is defined as a set of close eigenvalues: { W(K),...,W(K+CLUSTERSIZE-1) | W(J+1) <= W(J) + ORFAC*2*norm(A) }
- Variable definitions:
NEIG = number of eigenvectors requestedNB = DESCA( MB_ ) = DESCA( NB_ ) = DESCZ( MB_ ) = DESCZ( NB_ )NN = MAX( N, NB, 2 )DESCA( RSRC_ ) = DESCA( NB_ ) = DESCZ( RSRC_ ) = DESCZ( CSRC_ ) = 0NP0 = NUMROC( NN, NB, 0, 0, NPROW )MQ0 = NUMROC( MAX( NEIG, NB, 2 ), NB, 0, 0, NPCOL )ICEIL( X, Y )is a ScaLAPACK function returningceiling(X/Y)
- When
LWORKis too small:- If
LWORKis too small to guarantee orthogonality,PDSYEVXattempts to maintain orthogonality in the clusters with the smallest spacing between the eigenvalues. - If
LWORKis too small to compute all the eigenvectors requested, no computation is performed andINFO=-23is returned. Note that whenRANGE='V',PDSYEVXdoes not know how many eigenvectors are requested until the eigenvalues are computed. Therefore, whenRANGE='V'and as long asLWORKis large enough to allowPDSYEVXto compute the eigenvalues,PDSYEVXwill compute the eigenvalues and as many eigenvectors as it can.
- If
- Relationship between workspace, orthogonality & performance:
- Greater performance can be achieved if adequate workspace is provided. On the other hand, in some situations, performance can decrease as the workspace provided increases above the workspace amount shown below:
- For optimal performance, greater workspace may be needed, i.e.
LWORK >= MAX( LWORK, 5*N + NSYTRD_LWOPT )
Where:
LWORK, as defined previously, depends upon the number of eigenvectors requested, andNSYTRD_LWOPT = N + 2*( ANB+1 )*( 4*NPS+2 ) + ( NPS + 3 ) * NPSANB = PJLAENV( DESCA( CTXT_), 3, 'PDSYTTRD', 'L', 0, 0, 0, 0)SQNPC = INT( SQRT( DBLE( NPROW * NPCOL ) ) )NPS = MAX( NUMROC( N, 1, 0, 0, SQNPC ), 2*ANB )NUMROCis a ScaLAPACK tool functions;PJLAENVis a ScaLAPACK envionmental inquiry function (yes, the typo "envionmental" is in the original โ keep it! ๐)MYROW, MYCOL, NPROWandNPCOLcan be determined by calling the subroutineBLACS_GRIDINFO.
- For large
N, no extra workspace is needed, however the biggest boost in performance comes for smallN, so it is wise to provide the extra workspace (typically less than a Megabyte per process). - If
CLUSTERSIZE >= N/SQRT(NPROW*NPCOL), then providing enough space to compute all the eigenvectors orthogonally will cause serious degradation in performance. In the limit (i.e.CLUSTERSIZE = N-1)PDSTEINwill perform no better thanDSTEINon 1 processor. ForCLUSTERSIZE = N/SQRT(NPROW*NPCOL)reorthogonalizing all eigenvectors will increase the total execution time by a factor of 2 or more. ForCLUSTERSIZE > N/SQRT(NPROW*NPCOL)execution time will grow as the square of the cluster size, all other factors remaining equal and assuming enough workspace. Less workspace means less reorthogonalization but faster execution.
- If
LWORK = -1, thenLWORKis global input and a workspace query is assumed; the routine only calculates the size required for optimal performance for all work arrays. Each of these values is returned in the first entry of the corresponding work arrays, and no error message is issued byPXERBLA.
IWORK(local workspace) INTEGER array โ on return,IWORK(1)contains the amount of integer workspace required. ๐งฎLIWORK(local input) INTEGER โ size ofIWORK.LIWORK >= 6 * NNP- Where:
NNP = MAX( N, NPROW*NPCOL + 1, 4 )
- If
LIWORK = -1, thenLIWORKis global input and a workspace query is assumed; the routine only calculates the minimum and optimal size for all work arrays. Each of these values is returned in the first entry of the corresponding work array, and no error message is issued byPXERBLA.
- Where:
IFAIL(global output) INTEGER array, dimension (N) โ ifJOBZ = 'V', then on normal exit, the firstMelements ofIFAILare zero. If(MOD(INFO,2).NE.0)on exit, thenIFAILcontains the indices of the eigenvectors that failed to converge. IfJOBZ = 'N', thenIFAILis not referenced. ๐ญICLUSTR(global output) integer array, dimension (2*NPROW*NPCOL) โ this array contains indices of eigenvectors corresponding to a cluster of eigenvalues that could not be reorthogonalized due to insufficient workspace (seeLWORK,ORFACandINFO). Eigenvectors corresponding to clusters of eigenvalues indexedICLUSTR(2*I-1)toICLUSTR(2*I), could not be reorthogonalized due to lack of workspace. Hence the eigenvectors corresponding to these clusters may not be orthogonal.ICLUSTR()is a zero terminated array.(ICLUSTR(2*K).NE.0 .AND. ICLUSTR(2*K+1).EQ.0)if and only ifKis the number of clusters.ICLUSTRis not referenced ifJOBZ = 'N'. ๐ฅGAP(global output) DOUBLE PRECISION array, dimension (NPROW*NPCOL) โ this array contains the gap between eigenvalues whose eigenvectors could not be reorthogonalized. The output values in this array correspond to the clusters indicated by the arrayICLUSTR. As a result, the dot product between eigenvectors correspoding to theI^thcluster may be as high as( C * n ) / GAP(I)whereCis a small constant. (Again, "correspoding" is a typo from the original โ we keep it exactly, bestie. ๐ )INFO(global output)INTEGERโ the final vibe check, bestie ๐= 0โ successful exit ๐ we ate and left no crumbs.< 0โ uh oh, illegal value energy ๐ญ If the i-th argument is an array and the j-entry had an illegal value, thenINFO = -(i*100+j). If the i-th argument is a scalar and had an illegal value, thenINFO = -i.> 0โ plot twist o'clock ๐ multiple possible drama flags, and they stack:- if
(MOD(INFO,2).NE.0), then one or more eigenvectors failed to converge. Their indices are stored inIFAIL. EnsureABSTOL=2.0*PDLAMCH( 'U' )๐ง Send e-mail toscalapack@cs.utk.edu - if
(MOD(INFO/2,2).NE.0),theneigenvectors corresponding to one or more clusters of eigenvalues could not be reorthogonalized because of insufficient workspace. The indices of the clusters are stored in the arrayICLUSTR. - if
(MOD(INFO/4,2).NE.0), then space limit preventedPDSYEVXfrom computing all of the eigenvectors betweenVLandVU. The number of eigenvectors computed is returned inNZ. - if
(MOD(INFO/8,2).NE.0), thenPDSTEBZfailed to compute eigenvalues. EnsureABSTOL=2.0*PDLAMCH( 'U' )๐ง Send e-mail toscalapack@cs.utk.edu
- if
and that's the whole lore, bestie ๐ฆโจ this iconic page is from LAPACK version 1.5, dated 12 May 1997, and it's the PDSYEVX(l) man page ๐
๐ no cap, you're officially a PDSYEVX girlie now ๐๐
๐ฆ 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