Pittsburgh Supercomputing Center (PSC)BAKVEC
SUBROUTINE BAKVEC(NM,N,T,E,M,Z,IERR) This subroutine forms the eigenvectors of a NONSYMMETRIC TRIDIAGONAL matrix by back transforming those of the corresponding symmetric matrix determined by FIGI. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. T contains the nonsymmetric matrix. Its subdiagonal is stored in the last N-1 positions of the first column, its diagonal in the N positions of the second column, and its superdiagonal in the first N-1 positions of the third column. T(1,1) and T(N,3) are arbitrary. E contains the subdiagonal elements of the symmetric matrix in its last N-1 positions. E(1) is arbitrary. M is the number of eigenvectors to be back transformed. Z contains the eigenvectors to be back transformed in its first M columns. On OUTPUT T is unaltered. E is Destroyed. Z contains the transformed eigenvectors in its first M columns. IERR is set to Zero for normal return, 2*N+I if E(I) is zero with T(I,1) or T(I-1,3) non-zero. In this case, the symmetric matrix is not similar to the original matrix, and the eigenvectors cannot be found by this program. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
BALANC
SUBROUTINE BALANC(NM,N,A,LOW,IGH,SCALE) This subroutine is a translation of the ALGOL procedure BALANCE, NUM. MATH. 13, 293-304(1969) by Parlett and Reinsch. HANDBOOk FOR AUTO. COMP., Vol.II-LINEAR ALGEBRA, 315-326(1971). This subroutine balances a REAL matrix and isolates eigenvalues whenever possible. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains the input matrix to be balanced. On OUTPUT A contains the balanced matrix. LOW and IGH are two integers such that A(I,J) is equal to zero if (1) I is greater than J and (2) J=1,...,LOW-1 or I=IGH+1,...,N. SCALE contains information determining the permutations and scaling factors used. Suppose that the principal submatrix in rows LOW through IGH has been balanced, that P(J) denotes the index interchanged with J during the permutation step, and that the elements of the diagonal matrix used are denoted by D(I,J). Then SCALE(J) = P(J), for J = 1,...,LOW-1 = D(J,J), J = LOW,...,IGH = P(J) J = IGH+1,...,N. The order in which the interchanges are made is N to IGH+1, then 1 TO LOW-1. Note that 1 is returned for IGH if IGH is zero formally. The ALGOL procedure EXC contained in BALANCE appears in BALANC in line. (Note that the ALGOL roles of identifiers K,L have been reversed.) Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BALBAK
SUBROUTINE BALBAK(NM,N,LOW,IGH,SCALE,M,Z) This subroutine is a translation of the ALGOL procedure BALBAK, NUM. MATH. 13, 293-304(1969) by Parlett and Reinsch. HANDBOOK FOR AUTO. COMP., Vol.II-LINEAR ALGEBRA, 315-326(1971). This subroutine forms the eigenvectors of a REAL GENERAL matrix by back transforming those of the corresponding balanced matrix determined by BALANC. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by BALANC. SCALE contains information determining the permutations and scaling factors used by BALANC. M is the number of columns of Z to be back transformed. Z contains the real and imaginary parts of the eigen- vectors to be back transformed in its first M columns. On OUTPUT Z contains the real and imaginary parts of the transformed eigenvectors in its first M columns. Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BANDR
SUBROUTINE BANDR(NM,N,MB,A,D,E,E2,MATZ,Z) This subroutine is a translation of the ALGOL procedure BANDRD, NUM. MATH. 12, 231-241(1968) by Schwarz. HANDBOOK FOR AUTO. COMP., VOL.II-lINEAR ALGEBRA, 273-283(1971). This subroutine reduces a REAL SYMMETRIC BAND matrix to a symmetric tridiagonal matrix using and optionally accumulating orthogonal similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. MB is the (half) band width of the matrix, defined as the number of adjacent diagonals, including the principal diagonal, required to specify the non-zero portion of the lower triangle of the matrix. A contains the lower triangle of the symmetric band input matrix stored as an N by MB array. Its lowest subdiagonal is stored in the last N+1-MB positions of the first column, its next subdiagonal in the last N+2-MB positions of the second column, further subdiagonals similarly, and finally its principal diagonal in the N positions of the last column. Contents of storages not part of the matrix are arbitrary. MATZ should be set to .TRUE. if the transformation matrix is to be accumulated, and to .FALSE. otherwise. On OUTPUT A has been destroyed, except for its last two columns which contain a copy of the tridiagonal matrix. D contains the diagonal elements of the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. Z contains the orthogonal transformation matrix produced in the reduction if MATZ has been set to .TRUE. Otherwise, Z is not referenced. Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BANDV
SUBROUTINE BANDV(NM,N,MBW,A,E21,M,W,Z,IERR,NV,RV,RV6) This subroutine finds those eigenvectors of a REAL SYMMETRIC BAND matrix corresponding to specified eigenvalues, using inverse iteration. The subroutine may also be used to solve systems of linear equations with a symmetric or non-symmetric band coefficient matrix. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. MBW is the number of columns of the array A used to store the band matrix. If the matrix is symmetric, MBW is its (half) band width, denoted MB and defined as the number of adjacent diagonals, including the principal diagonal, required to specify the non-zero portion of the lower triangle of the matrix. If the subroutine is being used to solve systems of linear equations and the coefficient matrix is not symmetric, it must however have the same number of adjacent diagonals above the main diagonal as below, and in this case, MBW=2*MB-1. A contains the lower triangle of the symmetric band input matrix stored as an N by MB array. Its lowest subdiagonal is stored in the last N+1-MB positions of the first column, its next subdiagonal in the last N+2-MB positions of the second column, further subdiagonals similarly, and finally its principal diagonal in the N positions of column MB. If the subroutine is being used to solve systems of linear equations and the coefficient matrix is not symmetric, A is N by 2*MB-1 instead with lower triangle as above and with its first superdiagonal stored in the first N-1 positions of column MB+1, its second superdiagonal in the first N-2 positions of column MB+2, further superdiagonals similarly, and finally its highest superdiagonal in the first N+1-MB positions of the last column. Contents of storages not part of the matrix are arbitrary. E21 specifies the ordering of the eigenvalues and contains 0.0E0 if the eigenvalues are in ascending order, or 2.0E0 if the eigenvalues are in descending order. If the subroutine is being used to solve systems of linear equations, E21 should be set to 1.0E0 if the coefficient matrix is symmetric and to -1.0E0 if not. M is the number of specified eigenvalues or the number of systems of linear equations. W contains the M eigenvalues in ascending or descending order. If the subroutine is being used to solve systems of linear equations (A-W(R)*I)*X(R)=B(R), where I is the identity matrix, W(R) should be set accordingly, for R=1,2,...,M. Z contains the constant matrix columns (B(R),R=1,2,...,M), if the subroutine is used to solve systems of linear equations. NV must be set to the dimension of the array parameter RV as declared in the calling program dimension statement. On OUTPUT A and W are unaltered. Z contains the associated set of orthogonal eigenvectors. Any vector which fails to converge is set to zero. If the subroutine is used to solve systems of linear equations, Z contains the solution matrix columns (X(R),R=1,2,...,M). IERR is set to Zero for normal return, -R if the eigenvector corresponding to the R-th eigenvalue fails to converge, or if the R-th system of linear equations is nearly singular. RV and RV6 are temporary storage arrays. Note that RV is of dimension at least N*(2*MB-1). If the subroutine is being used to solve systems of linear equations, the determinant (up to sign) of A-W(M)*I is available, upon return, as the product of the first N elements of RV. Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BCRH
FUNCTION BCRH(XLL,XRR,IZ,C,A,BH,F,SGN)
BDIFF
SUBROUTINE BDIFF(L,V) BDIFF computes the sum of B(L,K)*V(K)*(-1)**K where B(L,K) are the binomial coefficients. Truncated sums are computed by setting last part of the V vector to zero. On return, the binomial sum is in V(L).
BISECT
SUBROUTINE BISECT(N,EPS1,D,E,E2,LB,UB,MM,M,W,IND,IERR,RV4,RV5) This subroutine is a translation of the bisection technique in the ALGOL procedure TRISTURM by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 418-439(1971). This subroutine finds those eigenvalues of a TRIDIAGONAL SYMMETRIC matrix which lie in a specified interval, using bisection. On INPUT N is the order of the matrix. EPS1 is an absolute error tolerance for the computed eigenvalues. If the input EPS1 is non-positive, it is reset for each submatrix to a default value, namely, minus the product of the relative machine precision and the 1-norm of the submatrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E. E2(1) is arbitrary. LB and UB define the interval to be searched for eigenvalues. If LB is not less than UB, no eigenvalues will be found. MM should be set to an upper bound for the number of eigenvalues in the interval. WARNING. If more than MM eigenvalues are determined to lie in the interval, an error return is made with no eigenvalues found. On OUTPUT EPS1 is unaltered unless it has been reset to its (last) default value. D and E are unaltered. Elements of E2, corresponding to elements of E regarded as negligible, have been replaced by zero causing the matrix to split into a direct sum of submatrices. E2(1) is also set to zero. M is the number of eigenvalues determined to lie in (LB,UB). W contains the M eigenvalues in ascending order. IND contains in its first M positions the submatrix indices associated with the corresponding eigenvalues in W -- 1 for eigenvalues belonging to the first submatrix from the top, 2 for those belonging to the second submatrix, etc. IERR is set to Zero for normal return, 3*N+1 if M exceeds MM. RV4 and RV5 are temporary storage arrays. The ALGOL procedure STURMCNT contained in TRISTURM appears in BISECT in-line. Note that subroutine TQL1 or IMTQL1 is generally faster than BISECT, if more than N/4 eigenvalues are to be found. Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BKIAS
SUBROUTINE BKIAS(X,N,KTRMS,T,ANS,IND,MS,GMRN,H,IERR) BKIAS computes repeated integrals of the K0 Bessel function by the asymptotic expansion
BKISR
SUBROUTINE BKISR(X,N,SUM,IERR) BKISR computes repeated integrals of the K0 Bessel function by the series for N=0,1, and 2.
BKSOL
SUBROUTINE BKSOL(N,A,X)
BLKTR1
SUBROUTINE BLKTR1(N,AN,BN,CN,M,AM,BM,CM,IDIMY,Y,B,W1,W2,W3,WD,WW,
BNDACC
SUBROUTINE BNDACC(G,MDG,NB,IP,IR,MT,JT) These subroutines solve the least squares problem Ax = b for banded matrices A using sequential accumulation of rows of the data matrix. Exactly one right-hand side vector is permitted. These subroutines are intended for the type of least squares systems that arise in applications such as curve or surface fitting of data. The least squares equations are accumulated and processed using only part of the data. This requires a certain user interaction during the solution of Ax = b. Specifically, suppose the data matrix (A B) is row partitioned into Q submatrices. Let (E F) be the T-th one of these submatrices where E = (0 C 0). Here the dimension of E is MT by N and the dimension of C is MT by NB. The value of NB is the bandwidth of A. The dimensions of the leading block of zeros in E are MT by JT-1. The user of the subroutine BNDACC provides MT,JT,C and F for T=1,...,Q. Not all of this data must be supplied at once. Following the processing of the various blocks (E F), the matrix (A B) has been transformed to the form (R D) where R is upper triangular and banded with bandwidth NB. The least squares system Rx = d is then easily solved using back substitution by executing the statement CALL BNDSOL(1,...). The sequence of values for JT must be nondecreasing. This may require some preliminary interchanges of rows and columns of the matrix A. The primary reason for these subroutines is that the total processing can take place in a working array of dimension MU by NB+1. An acceptable value for MU is MU = MAX(MT + N + 1), where N is the number of unknowns. Here the maximum is taken over all values of MT for T=1,...,Q. Notice that MT can be taken to be a small as one, showing that MU can be as small as N+2. The subprogram BNDACC processes the rows more efficiently if MU is large enough so that each new block (C F) has a distinct value of JT. The four principle parts of these algorithms are obtained by the following call statements CALL BNDACC(...) Introduce new blocks of data. CALL BNDSOL(1,...)Compute solution vector and length of residual vector. CALL BNDSOL(2,...)Given any row vector H solve YR = H for the row vector Y. CALL BNDSOL(3,...)Given any column vector W solve RZ = W for the column vector Z. The dots in the above call statements indicate additional arguments that will be specified in the following paragraphs. The user must dimension the array appearing in the call list.. G(MDG,NB+1) Description of calling sequence for BNDACC.. The entire set of parameters for BNDACC are Input.. G(*,*) The working array into which the user will place the MT by NB+1 block (C F) in rows IR through IR+MT-1, columns 1 through NB+1. See descriptions of IR and MT below. MDG The number of rows in the working array G(*,*). The value of MDG should be .GE. MU. The value of MU is defined in the abstract of these subprograms. NB The bandwidth of the data matrix A. IP Set by the user to the value 1 before the first call to BNDACC. Its subsequent value is controlled by BNDACC to set up for the next call to BNDACC. IR Index of the row of G(*,*) where the user is to place the new block of data (C F). Set by the user to the value 1 before the first call to BNDACC. Its subsequent value is controlled by BNDACC. A value of IR .GT. MDG is considered an error. MT,JT Set by the user to indicate respectively the number of new rows of data in the block and the index of the first nonzero column in that set of rows (E F) = (0 C 0 F) being processed. Output.. G(*,*) The working array which will contain the processed rows of that part of the data matrix which has been passed to BNDACC. IP,IR The values of these arguments are advanced by BNDACC to be ready for storing and processing a new block of data in G(*,*). Description of calling sequence for BNDSOL.. The user must dimension the arrays appearing in the call list.. G(MDG,NB+1), X(N) The entire set of parameters for BNDSOL are Input.. MODE Set by the user to one of the values 1, 2, or 3. These values respectively indicate that the solution of AX = B, YR = H or RZ = W is required. G(*,*),MDG, These arguments all have the same meaning and NB,IP,IR contents as following the last call to BNDACC. X(*) With mode=2 or 3 this array contains, respectively, the right-side vectors H or W of the systems YR = H or RZ = W. N The number of variables in the solution vector. If any of the N diagonal terms are zero the subroutine BNDSOL prints an appropriate message. This condition is considered an error. Output.. X(*) This array contains the solution vectors X, Y or Z of the systems AX = B, YR = H or RZ = W depending on the value of MODE=1, 2 or 3. RNORM If MODE=1 RNORM is the Euclidean length of the residual vector AX-B. When MODE=2 or 3 RNORM is set to zero. Remarks.. To obtain the upper triangular matrix and transformed right-hand side vector D so that the super diagonals of R form the columns of G(*,*), execute the following Fortran statements. NBP1=NB+1 DO 10 J=1, NBP1 10 G(IR,J) = 0.E0 MT=1 JT=N+1 CALL BNDACC(G,MDG,NB,IP,IR,MT,JT)
BNDSOL
SUBROUTINE BNDSOL(MODE,G,MDG,NB,IP,IR,X,N,RNORM) These subroutines solve the least squares problem Ax = b for banded matrices A using sequential accumulation of rows of the data matrix. Exactly one right-hand side vector is permitted. These subroutines are intended for the type of least squares systems that arise in applications such as curve or surface fitting of data. The least squares equations are accumulated and processed using only part of the data. This requires a certain user interaction during the solution of Ax = b. Specifically, suppose the data matrix (A B) is row partitioned into Q submatrices. Let (E F) be the T-th one of these submatrices where E = (0 C 0). Here the dimension of E is MT by N and the dimension of C is MT by NB. The value of NB is the bandwidth of A. The dimensions of the leading block of zeros in E are MT by JT-1. The user of the subroutine BNDACC provides MT,JT,C and F for T=1,...,Q. Not all of this data must be supplied at once. Following the processing of the various blocks (E F), the matrix (A B) has been transformed to the form (R D) where R is upper triangular and banded with bandwidth NB. The least squares system Rx = d is then easily solved using back substitution by executing the statement CALL BNDSOL(1,...). The sequence of values for JT must be nondecreasing. This may require some preliminary interchanges of rows and columns of the matrix A. The primary reason for these subroutines is that the total processing can take place in a working array of dimension MU by NB+1. An acceptable value for MU is MU = MAX(MT + N + 1), where N is the number of unknowns. Here the maximum is taken over all values of MT for T=1,...,Q. Notice that MT can be taken to be a small as one, showing that MU can be as small as N+2. The subprogram BNDACC processes the rows more efficiently if MU is large enough so that each new block (C F) has a distinct value of JT. The four principle parts of these algorithms are obtained by the following call statements CALL BNDACC(...) Introduce new blocks of data. CALL BNDSOL(1,...)Compute solution vector and length of residual vector. CALL BNDSOL(2,...)Given any row vector H solve YR = H for the row vector Y. CALL BNDSOL(3,...)Given any column vector W solve RZ = W for the column vector Z. The dots in the above call statements indicate additional arguments that will be specified in the following paragraphs. The user must dimension the array appearing in the call list.. G(MDG,NB+1) Description of calling sequence for BNDACC.. The entire set of parameters for BNDACC are Input.. G(*,*) The working array into which the user will place the MT by NB+1 block (C F) in rows IR through IR+MT-1, columns 1 through NB+1. See descriptions of IR and MT below. MDG The number of rows in the working array G(*,*). The value of MDG should be .GE. MU. The value of MU is defined in the abstract of these subprograms. NB The bandwidth of the data matrix A. IP Set by the user to the value 1 before the first call to BNDACC. Its subsequent value is controlled by BNDACC to set up for the next call to BNDACC. IR Index of the row of G(*,*) where the user is the user to the value 1 before the first call to BNDACC. Its subsequent value is controlled by BNDACC. A value of IR .GT. MDG is considered an error. MT,JT Set by the user to indicate respectively the number of new rows of data in the block and the index of the first nonzero column in that set of rows (E F) = (0 C 0 F) being processed. Output.. G(*,*) The working array which will contain the processed rows of that part of the data matrix which has been passed to BNDACC. IP,IR The values of these arguments are advanced by BNDACC to be ready for storing and processing a new block of data in G(*,*). Description of calling sequence for BNDSOL.. The user must dimension the arrays appearing in the call list.. G(MDG,NB+1), X(N) The entire set of parameters for BNDSOL are Input.. MODE Set by the user to one of the values 1, 2, or 3. These values respectively indicate that the solution of AX = B, YR = H or RZ = W is required. G(*,*),MDG, These arguments all have the same meaning and NB,IP,IR contents as following the last call to BNDACC. X(*) With mode=2 or 3 this array contains, respectively, the right-side vectors H or W of the systems YR = H or RZ = W. N The number of variables in the solution vector. If any of the N diagonal terms are zero the subroutine BNDSOL prints an appropriate message. This condition is considered an error. Output.. X(*) This array contains the solution vectors X, Y or Z of the systems AX = B, YR = H or RZ = W depending on the value of MODE=1, 2 or 3. RNORM If MODE=1 RNORM is the Euclidean length of the residual vector AX-B. When MODE=2 or 3 RNORM is set to zero. Remarks.. To obtain the upper triangular matrix and transformed right-hand side vector D so that the super diagonals of R form the columns of G(*,*), execute the following Fortran statements. NBP1=NB+1 DO 10 J=1, NBP1 10 G(IR,J) = 0.E0 MT=1 JT=N+1 CALL BNDACC(G,MDG,NB,IP,IR,MT,JT)
BNFAC
SUBROUTINE BNFAC(W,NROWW,NROW,NBANDL,NBANDU,IFLAG)
BNSLV
SUBROUTINE BNSLV(W,NROWW,NROW,NBANDL,NBANDU,B)
BQR
SUBROUTINE BQR(NM,N,MB,A,T,R,IERR,NV,RV) This subroutine is a translation of the ALGOL procedure BQR, NUM. MATH. 16, 85-92(1970) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL II-LINEAR ALGEBRA, 266-272(1971). This subroutine finds the eigenvalue of smallest (usually) magnitude of a REAL SYMMETRIC BAND matrix using the QR algorithm with shifts of origin. Consecutive calls can be made to find further eigenvalues. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. MB is the (half) band width of the matrix, defined as the number of adjacent diagonals, including the principal diagonal, required to specify the non-zero portion of the lower triangle of the matrix. A contains the lower triangle of the symmetric band input matrix stored as an N by MB array. Its lowest subdiagonal is stored in the last N+1-MB positions of the first column, its next subdiagonal in the last N+2-MB positions of the second column, further subdiagonals similarly, and finally its principal diagonal in the N positions of the last column. Contents of storages not part of the matrix are arbitrary. On a subsequent call, its output contents from the previous call should be passed. T specifies the shift (of eigenvalues) applied to the diagonal of A in forming the input matrix. What is actually determined is the eigenvalue of A+TI (I is the identity matrix) nearest to T. On a subsequent call, the output value of T from the previous call should be passed if the next nearest eigenvalue is sought. R should be specified as zero on the first call, and as its output value from the previous call on a subsequent call. It is used to determine when the last row and column of the transformed band matrix can be regarded as negligible. NV must be set to the dimension of the array parameter RV as declared in the calling program dimension statement. On OUTPUT A contains the transformed band matrix. The matrix A+TI derived from the output parameters is similar to the input A+TI to within rounding errors. Its last row and column are null (if IERR is zero). T contains the computed eigenvalue of A+TI (if IERR is zero). R contains the maximum of its input value and the norm of the last column of the input matrix A. IERR is set to Zero for normal return, N if the eigenvalue has not been determined after 30 iterations. RV is a temporary storage array of dimension at least (2*MB**2+4*MB-3). The first (3*MB-2) locations correspond to the ALGOL array B, the next (2*MB-1) locations correspond to the ALGOL array H, and the final (2*MB**2-MB) locations correspond to the MB by (2*MB-1) ALGOL array U. NOTE. For a subsequent call, N should be replaced by N-1, but MB should not be altered even when it exceeds the current N. Calls PYTHAG(A,B) for SQRT(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, Applied Mathematics Division, ARGONNE NATIONAL LABORATORY
BSGQ8
SUBROUTINE BSGQ8(FUN,XT,BC,N,KK,ID,A,B,INBV,ERR,ANS,IERR,WORK)
CAXPY
SUBROUTINE CAXPY(N,CA,CX,INCX,CY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CA complex scalar multiplier CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --Output-- CY complex result (unchanged if N .LE. 0) Overwrite complex CY with complex CA*CX + CY. For I = 0 to N-1, replace CY(LY+I*INCY) with CA*CX(LX+I*INCX) + CY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N and LY is defined in a similar way using INCY.
CBABK2
SUBROUTINE CBABK2(NM,N,LOW,IGH,SCALE,M,ZR,ZI) This subroutine is a translation of the ALGOL procedure CBABK2, which is a complex version of BALBAK, NUM. MATH. 13, 293-304(1969) by Parlett and Reinsch. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971). This subroutine forms the eigenvectors of a COMPLEX GENERAL matrix by back transforming those of the corresponding balanced matrix determined by CBAL. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by CBAL. SCALE contains information determining the permutations and scaling factors used by CBAL. M is the number of eigenvectors to be back transformed. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors to be back transformed in their first M columns. On OUTPUT ZR and ZI contain the real and imaginary parts, respectively, of the transformed eigenvectors in their first M columns. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CBAL
SUBROUTINE CBAL(NM,N,AR,AI,LOW,IGH,SCALE) This subroutine is a translation of the ALGOL procedure CBALANCE, which is a complex version of BALANCE, NUM. MATH. 13, 293-304(1969) by Parlett and Reinsch. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 315-326(1971). This subroutine balances a COMPLEX matrix and isolates eigenvalues whenever possible. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. AR and AI contain the real and imaginary parts, respectively, of the complex matrix to be balanced. On OUTPUT AR and AI contain the real and imaginary parts, respectively, of the balanced matrix. LOW and IGH are two integers such that AR(I,J) and AI(I,J) are equal to zero if (1) I is greater than J and (2) J=1,...,LOW-1 or I=IGH+1,...,N. SCALE contains information determining the permutations and scaling factors used. Suppose that the principal submatrix in rows LOW through IGH has been balanced, that P(J) denotes the index interchanged with J during the permutation step, and that the elements of the diagonal matrix used are denoted by D(I,J). Then SCALE(J) = P(J), for J = 1,...,LOW-1 = D(J,J) J = LOW,...,IGH = P(J) J = IGH+1,...,N. The order in which the interchanges are made is N to IGH+1, then 1 to LOW-1. Note that 1 is returned for IGH if IGH is zero formally. The ALGOL procedure EXC contained in CBALANCE appears in CBAL in line. (Note that the ALGOL roles of identifiers K,L have been reversed.) Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CCHDC
SUBROUTINE CCHDC(A,LDA,P,WORK,JPVT,JOB,INFO) CCHDC computes the Cholesky decomposition of a positive definite matrix. A pivoting option allows the user to estimate the condition of a positive definite matrix or determine the rank of a positive semidefinite matrix. On Entry A COMPLEX(LDA,P). A contains the matrix whose decomposition is to be computed. Only the upper half of A need be stored. The lower part of The array A is not referenced. LDA INTEGER. LDA is the leading dimension of the array A. P INTEGER. P is the order of the matrix. WORK COMPLEX. WORK is a work array. JPVT INTEGER(P). JPVT contains integers that control the selection of the pivot elements, if pivoting has been requested. Each diagonal element A(K,K) is placed in one of three classes according to the value of JPVT(K)). If JPVT(K)) .GT. 0, then X(K) is an initial element. If JPVT(K)) .EQ. 0, then X(K) is a free element. If JPVT(K)) .LT. 0, then X(K) is a final element. Before the decomposition is computed, initial elements are moved by symmetric row and column interchanges to the beginning of the array A and final elements to the end. Both initial and final elements are frozen in place during the computation and only free elements are moved. At the K-th stage of the reduction, if A(K,K) is occupied by a free element it is interchanged with the largest free element A(L,L) with L .GE. K. JPVT is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. IF JOB .EQ. 0, no pivoting is done. IF JOB .NE. 0, pivoting is done. On Return A A contains in its upper half the Cholesky factor of the matrix A as it has been permuted by pivoting. JPVT JPVT(J) contains the index of the diagonal element of A that was moved into the J-th position, provided pivoting was requested. INFO contains the index of the last positive diagonal element of the Cholesky factor. For positive definite matrices INFO = P is the normal return. For pivoting with positive semidefinite matrices INFO will in general be less than P. However, INFO may be greater than the rank of A, since rounding error can cause an otherwise zero element to be positive. Indefinite systems will always cause INFO to be less than P. LINPACK. This version dated 03/19/79 . J. J. Dongarra and G. W. Stewart, Argonne National Laboratory and University of Maryland. BLAS CAXPY,CSWAP Fortran SQRT,REAL,CONJG
CCHDD
SUBROUTINE CCHDD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S,INFO) CCHDD downdates an augmented Cholesky decomposition or the triangular factor of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, CCHDD determines a unitary matrix U and a scalar ZETA such that (R Z ) (RR ZZ) U * ( ) = ( ) , (0 ZETA) ( X Y) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) removed. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the downdated problem is SQRT(RHO**2 - ZETA**2). CCHDD will simultaneously downdate several triplets (Z,Y,RHO) along with R. For a less terse description of what CCHDD does and how it may be applied, see the LINPACK Guide. The matrix U is determined as the product U(1)*...*U(P) where U(I) is a rotation in the (P+1,I)-plane of the form ( C(I) -CONJG(S(I)) ) ( ) . ( S(I) C(I) ) the rotations are chosen so that C(I) is real. The user is warned that a given downdating problem may be impossible to accomplish or may produce inaccurate results. For example, this can happen if X is near a vector whose removal will reduce the rank of R. Beware. On Entry R COMPLEX(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be downdated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. p INTEGER. P is the order of the matrix R. X COMPLEX(P). X contains the row vector that is to be removed from R. X is not altered by CCHDD. Z COMPLEX(LDZ,NZ), where LDZ .GE. P. Z is an array of NZ P-vectors which are to be downdated along with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be downdated NZ may be zero, in which case Z, Y, and RHO are not referenced. Y COMPLEX(NZ). Y contains the scalars for the downdating of the vectors Z. Y is not altered bY CCHDD. RHO REAL(NZ). RHO contains the norms of the residual vectors that are to be downdated. On Return R Z contain the downdated quantities. RHO C REAL(P). C contains the cosines of the transforming rotations. S COMPLEX(P). S contains the sines of the transforming rotations. INFO INTEGER. INFO is set as follows. INFO = 0 if the entire downdating was successful. INFO =-1 if R could not be downdated. in this case, all quantities are left unaltered. INFO = 1 if some RHO could not be downdated. The offending RHO's are set to -1. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. CCHDD uses the following functions and subprograms. Fortran AIMAG,CABS,CONJG BLAS CDOTC, SCNRM2
CCHEX
SUBROUTINE CCHEX(R,LDR,P,K,L,Z,LDZ,NZ,C,S,JOB) CCHEX updates the Cholesky factorization A = CTRANS(R)*R of a positive definite matrix A of order P under diagonal permutations of the form TRANS(E)*A*E where E is a permutation matrix. Specifically, given an upper triangular matrix R and a permutation matrix E (which is specified by K, L, and JOB), CCHEX determines a unitary matrix U such that U*R*E = RR, where RR is upper triangular. At the users option, the transformation U will be multiplied into the array Z. If A = CTRANS(X)*X, so that R is the triangular part of the QR factorization of X, then RR is the triangular part of the QR factorization of X*E, i.e. X with its columns permuted. For a less terse description of what CCHEX does and how it may be applied, see the LINPACK Guide. The matrix Q is determined as the product U(L-K)*...*U(1) of plane rotations of the form ( C(I) S(I) ) ( ) , ( -CONJG(S(I)) C(I) ) where C(I) is real. The rows these rotations operate on are described below. There are two types of permutations, which are determined by the value of JOB. 1. Right circular shift (JOB = 1). The columns are rearranged in the following order. 1,...,K-1,L,K,K+1,...,L-1,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (L-I,L-I+1)-plane. 2. Left circular shift (JOB = 2). The columns are rearranged in the following order 1,...,K-1,K+1,K+2,...,L,K,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (K+I-1,K+I)-plane. On Entry R COMPLEX(LDR,P), where LDR .GE. P. R contains the upper triangular factor that is to be updated. Elements of R below the diagonal are not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. K INTEGER. K is the first column to be permuted. L INTEGER. L is the last column to be permuted. L must be strictly greater than K. Z COMPLEX(LDZ,NZ), where LDZ .GE. P. Z is an array of NZ P-vectors into which the transformation U is multiplied. Z is not referenced if NZ = 0. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of columns of the matrix Z. JOB INTEGER. JOB determines the type of permutation. JOB = 1 right circular shift. JOB = 2 left circular shift. On Return R contains the updated factor. Z contains the updated matrix Z. C REAL(P). C contains the cosines of the transforming rotations. S COMPLEX(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. CCHEX uses the following functions and subroutines. Extended BLAS CROTG Fortran MIN0
CCHUD
SUBROUTINE CCHUD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S) CCHUD updates an augmented Cholesky decomposition of the triangular part of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, CCHUD determines a unitary matrix U and a scalar ZETA such that (R Z) (RR ZZ ) U * ( ) = ( ) , (X Y) ( 0 ZETA) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) appended. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the updated problem is SQRT(RHO**2 + ZETA**2). CCHUD will simultaneously update several triplets (Z,Y,RHO). For a less terse description of what CCHUD does and how it may be applied see the LINPACK Guide. The matrix U is determined as the product U(P)*...*U(1), where U(I) is a rotation in the (I,P+1) plane of the form ( (CI) S(I) ) ( ) . ( -CONJG(S(I)) (CI) ) The rotations are chosen so that C(I) is real. On Entry R COMPLEX(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be updated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. X COMPLEX(P). X contains the row to be added to R. X is not altered by CCHUD. Z COMPLEX(LDZ,NZ), where LDZ .GE. P. Z is an array containing NZ P-vectors to be updated with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be updated NZ may be zero, in which case Z, Y, and RHO are not referenced. Y COMPLEX(NZ). Y contains the scalars for updating the vectors Z. Y is not altered bY CCHUD. RHO REAL(NZ). RHO contains the norms of the residual vectors that are to be updated. If RHO(J) is negative, it is left unaltered. On Return RC RHO contain the updated quantities. Z C REAL(P). C contains the cosines of the transforming rotations. S COMPLEX(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. CCHUD uses the following functions and subroutines. Extended BLAS CROTG Fortran CONJG,SQRT
CCMPB
SUBROUTINE CCMPB(N,IERROR,AN,BN,CN,B,AH,BH)
CCOPY
SUBROUTINE CCOPY(N,CX,INCX,CY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --Output-- CY copy of vector CX (unchanged if N .LE. 0) Copy complex CX to complex CY. For I = 0 to N-1, copy CX(LX+I*INCX) to CY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
CDCDOT
COMPLEX FUNCTION CDCDOT(N,CB,CX,INCX,CY,INCY) B L A S Subprogram Description of Parameters --INPUT-- N number of elements in input vector(s) CB complex scalar to be added to inner product CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --OUTPUT-- CDCDOT complex dot product (zero if N .LE. 0) Returns result with dot product accumulated in D.P. CDCDOT = CB + sum for I = 0 to N-1 of CX(LX+I*INCY)*CY(LY+I*INCY) where LX + 1 if INCX .GE. 0, else LX =(-INCX)*N, AND LY IS defined in a similar way using INCY.
CDIV
SUBROUTINE CDIV(AR,AI,BR,BI,CR,CI)
CDOTC
COMPLEX FUNCTION CDOTC(N,CX,INCX,CY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --Output-- CDOTC complex result (zero if N .LE. 0) Returns the dot product for complex CX and CY, uses CONJUGATE(CX) CDOTC = SUM for I = 0 to N-1 of CONJ(CX(LX+I*INCX))*CY(LY+I*INCY) where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
CDOTU
COMPLEX FUNCTION CDOTU(N,CX,INCX,CY,INCY) B L A S Subprogram Description of parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --Output-- CDOTU complex result (zero if N .LE. 0) Returns the dot product for complex CX and CY, no conjugation CDOTU = SUM for I = 0 to N-1 of CX(LX+I*INCX) * CY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
CG
SUBROUTINE CG(NM,N,AR,AI,WR,WI,MATZ,ZR,ZI,FV1,FV2,FV3,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a COMPLEX GENERAL matrix. On INPUT NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A=(AR,AI). AR and AI contain the real and imaginary parts, respectively, of the complex general matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On OUTPUT WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1, FV2, and FV3 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CGBCO
SUBROUTINE CGBCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) CGBCO factors a complex band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, CGBFA is slightly faster. To solve A*X = B , follow CGBCO by CGBSL. To compute INVERSE(A)*C , follow CGBCO by CGBSL. To compute DETERMINANT(A) , follow CGBCO by CGBDI. On Entry ABD COMPLEX(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A And B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage if A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) M = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(N, J+Ml) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABD should contain * * * + + + , * = not used * * 13 24 35 46 , + = used for pivoting * 12 23 34 45 56 11 22 33 44 55 66 21 32 43 54 65 * LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CGBFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,MAX0,MIN0,REAL
CGBDI
SUBROUTINE CGBDI(ABD,LDA,N,ML,MU,IPVT,DET) CGBDI computes the determinant of a band matrix using the factors computed by CGBCO or CGBFA. If the inverse is needed, use CGBSL N times. On Entry ABD COMPLEX(LDA, N) the output from CGBCo or CGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from CGBCO or CGBFA. On Return DET COMPLEX(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. CABS1(DET(1)) .LT. 10.0 or DET(1) = 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions Fortran ABS,AIMAG,CMPLX,REAL
CGBFA
SUBROUTINE CGBFA(ABD,LDA,N,ML,MU,IPVT,INFO) CGBFA factors a complex band matrix by elimination. CGBFA is usually called by CGBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD COMPLEX(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that CGBSL will divide by zero if called. Use RCOND in CGBCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) m = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(n, J+ML) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL,ICAMAX Fortran ABS,AIMAG,MAX0,MIN0,REAL
CGBSL
SUBROUTINE CGBSL(ABD,LDA,N,ML,MU,IPVT,B,JOB) CGBSL solves the complex band system A * X = B or CTRANS(A) * X = B using the factors computed by CGBCO or CGBFA. On Entry ABD COMPLEX(LDA, N) the output from CGBCo or CGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from CGBCO or CGBFA. B COMPLEX(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve CTRANS(A)*X = B , where CTRANS(A) is the conjugate transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if CGBCO has set RCOND .GT. 0.0 or CGBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CGBCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL CGBSL(ABD,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran CONJG,MIN0
CGECO
SUBROUTINE CGECO(A,LDA,N,IPVT,RCOND,Z) CGECO factors a complex matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, CGEFA is slightly faster. To solve A*X = B , follow CGECO By CGESL. To Compute INVERSE(A)*C , follow CGECO by CGESL. To compute DETERMINANT(A) , follow CGECO by CGEDI. To compute INVERSE(A) , follow CGECO by CGEDI. On Entry A COMPLEX(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CGEFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL
CGEDI
SUBROUTINE CGEDI(A,LDA,N,IPVT,DET,WORK,JOB) CGEDI computes the determinant and inverse of a matrix using the factors computed by CGECO or CGEFA. On Entry A COMPLEX(LDA, N) the output from CGECO or CGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from CGECO or CGEFA. WORK COMPLEX(N) work vector. Contents destroyed. JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A inverse of original matrix if requested. Otherwise unchanged. DET COMPLEX(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. CABS1(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if CGECO has set RCOND .GT. 0.0 or CGEFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL,CSWAP Fortran ABS,AIMAG,CMPLX,MOD,REAL
CGEEV
SUBROUTINE CGEEV(A,LDA,N,E,V,LDV,WORK,JOB,INFO) LICEPACK. This version dated 08/08/80. David Kahner, Cleve Moler, G. W. Stewart N.B.S. U.N.M. N.B.S./U.MD. Abstract CGEEV computes the eigenvalues and, optionally, the eigenvectors of a general complex matrix. Call Sequence Parameters- (The values of parameters marked with * (star) will be changed by CGEEV.) A* COMPLEX(LDA,N) complex nonsymmetric input matrix. LDA INTEGER set by the user to the leading dimension of the complex array A. N INTEGER set by the user to the order of the matrices A and V, and the number of elements in E. E* COMPLEX(N) on return from CGEEV E contains the eigenvalues of A. See also INFO below. V* COMPLEX(LDV,N) on return from CGEEV if the user has set JOB = 0 V is not referenced. = nonzero the N eigenvectors of A are stored in the first N columns of V. See also INFO below. (If the input matrix A is nearly degenerate, V will be badly conditioned, i.e. have nearly dependent columns.) LDV INTEGER set by the user to the leading dimension of the array V if JOB is also set nonzero. In that case N must be .LE. LDV. If JOB is set to zero LDV is not referenced. WORK* REAL(3N) temporary storage vector. Contents changed by CGEEV. JOB INTEGER set by the user to = 0 eigenvalues only to be calculated by CGEEV. neither V nor LDV are referenced. = nonzero eigenvalues and vectors to be calculated. In this case A & V must be distinct arrays. Also, if LDA > LDV, CGEEV changes all the elements of A thru column N. If LDA < LDV, CGEEV changes all the elements of V through column N. If LDA = LDV only A(I,J) and V(I, J) for I,J = 1,...,N are changed by CGEEV. INFO* INTEGER on return from CGEEV the value of INFO is = 0 normal return, calculation successful. = K if the eigenvalue iteration fails to converge, eigenvalues K+1 through N are correct, but no eigenvectors were computed even if they were requested (JOB nonzero). Error Messages No. 1 recoverable N is greater than LDA No. 2 recoverable N is less than one. No. 3 recoverable JOB is nonzero and N is greater than LDV No. 4 warning LDA > LDV, elements of A other than the N by N input elements have been changed No. 5 warning LDA < LDV, elements of V other than the N by N output elements have been changed Subroutines Used EISPACK- CBABK2, CBAL, COMQR, COMQR2, CORTH BLAS- SCOPY SLATEC- XERROR
CGEFA
SUBROUTINE CGEFA(A,LDA,N,IPVT,INFO) CGEFA factors a complex matrix by Gaussian elimination. CGEFA is usually called by CGECO, but it can be called directly with a saving in time if RCOND is not needed. (Time for CGECO) = (1 + 9/N)*(Time for CGEFA) . On Entry A COMPLEX(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that CGESL or CGEDI will divide by zero if called. Use RCOND in CGECO for a reliable indication of singularity. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL,ICAMAX Fortran ABS,AIMAG,REAL
CGEFS
SUBROUTINE CGEFS(A,LDA,N,V,ITASK,IND,WORK,IWORK) Subroutine CGEFS solves A general NxN system of complex linear equations using LINPACK subroutines CGECO and CGESL. That is, if A is an NxN complex matrix and if X and B are complex N-vectors, then CGEFS solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeedIng solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by CGEFS in this case. Argument Description *** A COMPLEX(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. on return, an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (Terminal error message IND=-1) N INTEGER the order of the matrix A. The first N elements of the array A are the elements of the first column of the matrix A. N must be greater than or equal to 1. (Terminal error message IND=-2) V COMPLEX(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK=1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. if ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT.0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT.0 see error message corresponding to IND below. WORK COMPLEX(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. NOTE- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CGEIR
SUBROUTINE CGEIR(A,LDA,N,V,ITASK,IND,WORK,IWORK) Subroutine CGEIR solves a general NxN system of complex linear equations using LINPACK subroutines CGEFA and CGESL. One pass of iterative refinement is used only to obtain an estimate of the accuracy. That is, if A is an NxN complex matrix and if X and B are complex N-vectors, then CGEIR solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to calculate the solution, X. Then the residual vector is found and used to calculate an estimate of the relative error, IND. IND estimates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeedIng solutions. In this case, the contents of A, LDA, N, WORK, and IWORK must not have been altered by the user following factorization (ITASK=1). IND will not be changed by CGEIR in this case. Argument Description *** A COMPLEX(LDA,N) the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. A is not altered by the routine. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (Terminal error message IND=-1) N INTEGER the order of the matrix A. The first N elements of the array A are the elements of the first column of matrix A. N must be greater than or equal to 1. (Terminal error message IND=-2) V COMPLEX(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK=1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A (stored in work). if ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT.0 IND is a rough estimate of the number of digits of accuracy in the solution, X. IND=75 means that the solution vector X is zero. LT.0 see error message corresponding to IND below. WORK COMPLEX(N*(N+1)) a singly subscripted array of dimension at least N*(N+1). IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than one. IND=-3 terminal ITASK is less than one. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. NOTE- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CGESL
SUBROUTINE CGESL(A,LDA,N,IPVT,B,JOB) CGESL solves the complex system A * X = B or CTRANS(A) * X = B using the factors computed by CGECO or CGEFA. On Entry A COMPLEX(LDA, N) the output from CGECO or CGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from CGECO or CGEFA. B COMPLEX(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve CTRANS(A)*X = B where CTRANS(A) is the conjugate transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if CGECO has set RCOND .GT. 0.0 or CGEFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CGECO(A,LDA,N,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL CGESL(A,LDA,N,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran CONJG
CGTSL
SUBROUTINE CGTSL(N,C,D,E,B,INFO) CGTSL given a general tridiagonal matrix and a right hand side will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. C COMPLEX(N) is the subdiagonal of the tridiagonal matrix. C(2) through C(N) should contain the subdiagonal. On output C is destroyed. D COMPLEX(N) is the diagonal of the tridiagonal matrix. On output D is destroyed. E COMPLEX(N) is the superdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the superdiagonal. On output E is destroyed. B COMPLEX(N) is the right hand side vector. On Return B is the solution vector. INFO INTEGER = 0 normal value. = K if the K-th element of the diagonal becomes exactly zero. The subroutine returns when this is detected. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No Externals Fortran ABS,AIMAG,REAL
CH
SUBROUTINE CH(NM,N,AR,AI,W,MATZ,ZR,ZI,FV1,FV2,FM1,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a COMPLEX HERMITIAN matrix. On INPUT NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A=(AR,AI). AR and AI contain the real and imaginary parts, respectively, of the complex hermitian matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On OUTPUT W contains the eigenvalues in ascending order. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1, FV2, and FM1 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CHICO
SUBROUTINE CHICO(A,LDA,N,KPVT,RCOND,Z) CHICO factors a complex Hermitian matrix by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, CHIFA is slightly faster. To solve A*X = B , follow CHICO by CHISL. To compute INVERSE(A)*C , follow CHICO by CHISL. To compute INVERSE(A) , follow CHICO by CHIDI. To compute DETERMINANT(A) , follow CHICO by CHIDI. To compute INERTIA(A), follow CHICO by CHIDI. On Entry A COMPLEX(LDA, N) the Hermitian matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . Output A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*CTRANS(U) where U is a product of permutation and unit upper triangular matrices , CTRANS(U) is the conjugate transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CHIFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,IABS,REAL
CHIDI
SUBROUTINE CHIDI(A,LDA,N,KPVT,DET,INERT,WORK,JOB) CHIDI computes the determinant, inertia and inverse of a complex Hermitian matrix using the factors from CHIFA. On Entry A COMPLEX(LDA,N) the output from CHIFA. LDA INTEGER the leading dimension of the array A. N INTEGER the order of the matrix A. KVPT INTEGER(N) the pivot vector from CHIFA. WORK COMPLEX(N) work vector. Contents destroyed. JOB INTEGER JOB has the decimal expansion ABC where if C .NE. 0, the inverse is computed, if B .NE. 0, the determinant is computed, if A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. A contains the upper triangle of the inverse of the original matrix. The strict lower triangle is never referenced. DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero may occur if the inverse is requested and CHICO has set RCOND .EQ. 0.0 or CHIFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CCOPY,CDOTC,CSWAP Fortran ABS,CABS,CMPLX,CONJG,IABS,MOD,REAL
CHIEV
SUBROUTINE CHIEV(A,LDA,N,E,V,LDV,WORK,JOB,INFO) David Kahaner, Cleve Moler, G. W. Stewart, N.B.S. U.N.M. N.B.S./U.MD. Abstract CHIEV computes the eigenvalues and, optionally, the eigenvectors of a complex Hermitian matrix. Call Sequence Parameters- (the values of parameters marked with * (star) will be changed by CHIEV.) A* COMPLEX(LDA,N) complex Hermitian input matrix. Only the upper triangle of A need be filled in. Elements on diagonal must be real. LDA INTEGER set by the user to the leading dimension of the complex array A. N INTEGER set by the user to the order of the matrices A and V, and the number of elements in E. E* REAL(N) on return from CHIEV E contains the eigenvalues of A. See also INFO below. V* COMPLEX(LDV,N) on return from CHIEV if the user has set JOB = 0 V is not referenced. = nonzero the N eigenvectors of A are stored in the first N columns of V. See also INFO below. LDV INTEGER set by the user to the leading dimension of the array V if JOB is also set nonzero. In that case N must be .LE. LDV. If JOB is set to zero LDV is not referenced. WORK* REAL(4N) temporary storage vector. Contents changed by CHIEV. JOB INTEGER set by the user to = 0 eigenvalues only to be calculated by CHIEV. Neither V nor LDV are referenced. = nonzero eigenvalues and vectors to be calculated. In this case A and V must be distinct arrays also if LDA .GT. LDV CHIEV changes all the elements of A thru column N. If LDA < LDV CHIEV changes all the elements of V through column N. If LDA = LDV only A(I,J) and V(I, J) for I,J = 1,...,N are changed by CHIEV. INFO* INTEGER on return from CHIEV the value of INFO is = 0 normal return, calculation successful. = K if the eigenvalue iteration fails to converge, eigenvalues (and eigenvectors if requested) 1 through K-1 are correct. Error Messages No. 1 recoverable N is greater than LDA No. 2 recoverable N is less than one. No. 3 recoverable JOB is nonzero and N is greater than LDV No. 4 warning LDA > LDV, elements of A other than the N by N input elements have been changed No. 5 warning LDA < LDV, elements of V other than the N by N output elements have been changed No. 6 recoverable nonreal element on diagonal of A. Subroutines Used EISPACK- HTRIBK, HTRIDI, IMTQL2, TQLRAT BLAS- SCOPY, SCOPYM SLATEC- XERROR
CHIFA
SUBROUTINE CHIFA(A,LDA,N,KPVT,INFO) CHIFA factors a complex Hermitian matrix by elimination with symmetric pivoting. To solve A*X = B , follow CHIFA by CHISL. To compute INVERSE(A)*C , follow CHIFA by CHISL. To compute DETERMINANT(A) , follow CHIFA by CHIDI. To compute INERTIA(A) , follow CHIFA by CHIDI. To compute INVERSE(A) , follow CHIFA by CHIDI. On Entry A COMPLEX(LDA,N) the Hermitian matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*CTRANS(U) where U is a product of permutation and unit upper triangular matrices , CTRANS(U) is the conjugate transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that CHISL or CHIDI may divide by zero if called. LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CSWAP,ICAMAX Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL,SQRT
CHISL
SUBROUTINE CHISL(A,LDA,N,KPVT,B) CHISL solves the complex Hermitian system A * X = B using the factors computed by CHIFA. On Entry A COMPLEX(LDA,N) the output from CHIFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CHIFA. B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if CHICO has set RCOND .EQ. 0.0 or CHIFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CHIFA(A,LDA,N,KVPT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, p CALL CHISL(A,LDA,N,KVPT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran CONJG,IABS
CHPCO
SUBROUTINE CHPCO(AP,N,KPVT,RCOND,Z) CHPCO factors a complex Hermitian matrix stored in packed form by elimination with symmetric pivoting and estimates the condition of the matrix. if RCOND is not needed, CHPFA is slightly faster. To solve A*X = B , follow CHPCO by CHPSL. To compute INVERSE(A)*C , follow CHPCO by CHPSL. To compute INVERSE(A) , follow CHPCO by CHPDI. To compute DETERMINANT(A) , follow CHPCO by CHPDI. To compute INERTIA(A), follow CHPCO by CHPDI. On Entry AP COMPLEX (N*(N+1)/2) the packed form of a Hermitian matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*CTRANS(U) where U is a product of permutation and unit upper triangular matrices , CTRANS(U) is the conjugate transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Packed Storage The following program segment will pack the upper triangle of a Hermitian matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CHPFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,IABS,REAL
CHPDI
SUBROUTINE CHPDI(AP,N,KPVT,DET,INERT,WORK,JOB) CHPDI computes the determinant, inertia and inverse of a complex Hermitian matrix using the factors from CHPFA, where the matrix is stored in packed form. On Entry AP COMPLEX (N*(N+1)/2) the output from CHPFA. N INTEGER the order of the matrix A. KVPT INTEGER(N) the pivot vector from CHPFA. WORK COMPLEX(N) work vector. Contents ignored. JOB INTEGER JOB has the decimal expansion ABC where if C .NE. 0, the inverse is computed, if B .NE. 0, the determinant is computed, if A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. AP contains the upper triangle of the inverse of the original matrix, stored in packed form. The columns of the upper triangle are stored sequentially in a one-dimensional array. DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero will occur if the inverse is requested and CHPCO has set RCOND .EQ. 0.0 or CHPFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CCOPY,CDOTC,CSWAP Fortran ABS,CABS,CMPLX,CONJG,IABS,MOD,REAL
CHPFA
SUBROUTINE CHPFA(AP,N,KPVT,INFO) CHPFA factors a complex Hermitian matrix stored in packed form by elimination with symmetric pivoting. To solve A*X = B , follow CHPFA by CHPSL. To compute INVERSE(A)*C , follow CHPFA by CHPSL. To compute DETERMINANT(A) , follow CHPFA by CHPDI. To compute INERTIA(A) , follow CHPFA by CHPDI. To compute INVERSE(A) , follow CHPFA by CHPDI. On Entry AP COMPLEX (N*(N+1)/2) the packed form of a Hermitian matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP A block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*CTRANS(U) where U is a product of permutation and unit upper triangular matrices , CTRANS(U) is the conjugate transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that CHPSL or CHPDI may divide by zero if called. Packed Storage The following program segment will pack the upper triangle of a Hermitian matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CSWAP,ICAMAX Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL,SQRT
CHPSL
SUBROUTINE CHPSL(AP,N,KPVT,B) CHISL solves the complex Hermitian system A * X = B using the factors computed by CHPFA. On Entry AP COMPLEX(N*(N+1)/2) the output from CHPFA. N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CHPFA. B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if CHPCO has set RCOND .EQ. 0.0 or CHPFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CHPFA(AP,N,KVPT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CHPSL(AP,N,KVPT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran CONJG,IABS
CINVIT
SUBROUTINE CINVIT(NM,N,AR,AI,WR,WI,SELECT,MM,M,ZR,ZI,IERR,RM1, This subroutine is a translation of the ALGOL procedure CXINVIT by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP. VOL.II-LINEAR ALGEBRA, 418-439(1971). This subroutine finds those eigenvectors of A COMPLEX UPPER Hessenberg matrix corresponding to specified eigenvalues, using inverse iteration. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. AR and AI contain the real and imaginary parts, respectively, of the Hessenberg matrix. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues of the matrix. The eigenvalues must be stored in a manner identical to that of subroutine COMLR, which recognizes possible splitting of the matrix. SELECT specifies the eigenvectors to be found. The eigenvector corresponding to the J-th eigenvalue is specified by setting SELECT(J) to .TRUE. MM should be set to an upper bound for the number of eigenvectors to be found. On OUTPUT AR, AI, WI, and SELECT are unaltered. WR may have been altered since close eigenvalues are perturbed slightly in searching for independent eigenvectors. M is the number of eigenvectors actually found. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors. The eigenvectors are normalized so that the component of largest magnitude is 1. Any vector which fails the acceptance test is set to zero. IERR is set to Zero for normal return, -(2*N+1) if more than MM eigenvectors have been specified, -K if the iteration corresponding to the K-th value fails, -(N+K) if both error situations occur. RM1, RM2, RV1, and RV2 are temporary storage arrays. The ALGOL procedure GUESSVEC appears in CINVIT in line. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CNBCO
SUBROUTINE CNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) CNBCO factors a complex band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, CNBFA is slightly faster. To solve A*X = B , follow CNBCO by CNBSL. To compute INVERSE(A)*C , follow CNBCO by CNBSL. To compute DETERMINANT(A) , follow CNBCO by CNBDI. On Entry ABE COMPLEX(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 07/30/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions SLATEC CNBFA CDOTC,CAXPY,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,MAX0,MIN0,SIGN
CNBDI
SUBROUTINE CNBDI(ABE,LDA,N,ML,MU,IPVT,DET) CNBDI computes the determinant of a band matrix using the factors computed by CNBCO or CNBFA. If the inverse is needed, use CNBSL N times. On Entry ABE COMPLEX(LDA, NC) the output from CNBCO or CNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from CNBCO or CNBFA. On Return DET COMPLEX(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. CABS1(DET(1)) .LT. 10.0 or DET(1) = 0.0 . SLATEC. This version dated 07/30/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions Fortran ABS,AIMAG,CMPLX,REAL
CNBFA
SUBROUTINE CNBFA(ABE,LDA,N,ML,MU,IPVT,INFO) CNBFA factors a complex band matrix by elimination. CNBFA is usually called by CNBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABE COMPLEX(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. the factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER =0 normal value =K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that CNBSL will divide by zero if called. Use RCOND in CNBCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 07/30/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions BLAS ICAMAX,CAXPY,CSCAL,CSWAP Fortran ABS,AIMAG,MIN0,REAL
CNBFS
SUBROUTINE CNBFS(ABE,LDA,N,ML,MU,V,ITASK,IND,WORK,IWORK) Subroutine CNBFS solves a general nonsymmetric banded NxN system of single precision complex linear equations using SLATEC subroutines CNBCO and CNBSL. These are adaptations of the LINPACK subroutines CGBCO and CGBSL which require a different format for storing the matrix elements. If A is an NxN complex matrix and if X and B are complex N-vectors, then CNBFS solves the equation A*X=B. A band matrix is a matrix whose nonzero elements are all fairly near the main diagonal, specifically A(I,J) = 0 if I-J is greater than ML or J-I is greater than MU . The integers ML and MU are called the lower and upper band widths and M = ML+MU+1 is the total band width. CNBFS uses less time and storage than the corresponding program for general matrices (CGEFS) if 2*ML+MU .LT. N . The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by CNBFS in this case. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + Argument Description *** ABE COMPLEX(LDA,NC) on entry, contains the matrix in band storage as described above. NC must not be less than 2*ML+MU+1 . The user is cautioned to specify NC with care since it is not an argument and cannot be checked by CNBFS. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE . on return, contains an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of array ABE. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1 . (terminal error message IND=-2) ML INTEGER the number of diagonals below the main diagonal. ML must not be less than zero nor greater than or equal to N . (terminal error message IND=-5) MU INTEGER the number of diagonals above the main diagonal. MU must not be less than zero nor greater than or equal to N . (terminal error message IND=-6) V COMPLEX(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK = 1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. if ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 see error message corresponding to IND below. WORK COMPLEX(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-5 terminal ML is less than zero or is greater than or equal to N . IND=-6 terminal MU is less than zero or is greater than or equal to N . IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. NOTE- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CNBIR
SUBROUTINE CNBIR(ABE,LDA,N,ML,MU,V,ITASK,IND,WORK,IWORK) Subroutine CNBIR solves a general nonsymmetric banded NxN system of single precision complex linear equations using SLATEC subroutines CNBFA and CNBSL. These are adaptations of the LINPACK subroutines CGBFA and CGBSL which require a different format for storing the matrix elements. One pass of iterative refinement is used only to obtain an estimate of the accuracy. If A is an NxN complex banded matrix and if X and B are complex N-vectors, then CNBIR solves the equation A*X=B. A band matrix is a matrix whose nonzero elements are all fairly near the main diagonal, specifically A(I,J) = 0 if I-J is greater than ML or J-I is greater than MU . The integers ML and MU are called the lower and upper band widths and M = ML+MU+1 is the total band width. CNBIR uses less time and storage than the corresponding program for general matrices (CGEIR) if 2*ML+MU .LT. N . The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X . Then the residual vector is found and used to calculate an estimate of the relative error, IND . IND esti- mates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N, WORK and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by CNBIR in this case. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 , * = not used 21 22 23 24 32 33 34 35 43 44 45 46 54 55 56 * 65 66 * * Argument Description *** ABE COMPLEX(LDA,MM) on entry, contains the matrix in band storage as described above. MM must not be less than M = ML+MU+1 . The user is cautioned to dimension ABE with care since MM is not an argument and cannot be checked by CNBIR. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE . ABE is not altered by the program. LDA INTEGER the leading dimension of array ABE. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1 . (terminal error message IND=-2) ML INTEGER the number of diagonals below the main diagonal. ML must not be less than zero nor greater than or equal to N . (terminal error message IND=-5) MU INTEGER the number of diagonals above the main diagonal. MU must not be less than zero nor greater than or equal to N . (terminal error message IND=-6) V COMPLEX(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK=1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. if ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X . IND=75 means that the solution vector X is zero. LT. 0 see error message corresponding to IND below. WORK COMPLEX(N*(NC+1)) a singly subscripted array of dimension at least N*(NC+1) where NC = 2*ML+MU+1 . IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-5 terminal ML is less than zero or is greater than or equal to N . IND=-6 terminal MU is less than zero or is greater than or equal to N . IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. NOTE- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CNBSL
SUBROUTINE CNBSL(ABE,LDA,N,ML,MU,IPVT,B,JOB) CNBSL solves the complex band system A * X = B or CTRANS(A) * X = B using the factors computed by CNBCO or CNBFA. On Entry ABE COMPLEX(LDA, NC) the output from CNBCO or CNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from CNBCO or CNBFA. B COMPLEX(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B . = nonzero to solve CTRANS(A)*X = B , where CTRANS(A) is the conjugate transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA. It will not occur if the subroutines are called correctly and if CNBCO has set RCOND .GT. 0.0 or CNBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL CNBSL(ABE,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE SLATEC. This version dated 07/30/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions BLAS CAXPY,CDOTC Fortran CONJG,MIN0
COMBAK
SUBROUTINE COMBAK(NM,LOW,IGH,AR,AI,INT,M,ZR,ZI) This subroutine is a translation of the ALGOL procedure COMBAK, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). This subroutine forms the eigenvectors of a COMPLEX GENERAL matrix by back transforming those of the corresponding upper Hessenberg matrix determined by COMHES. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1 and IGH equal to the order of the matrix. AR and AI contain the multipliers which were used in the reduction by COMHES in their lower triangles below the subdiagonal. INT contains information on the rows and columns interchanged in the reduction by COMHES. Only elements LOW through IGH are used. M is the number of eigenvectors to be back transformed. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors to be back transformed in their first M columns. On OUTPUT ZR and ZI contain the real and imaginary parts, respectively, of the transformed eigenvectors in their first M columns. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
COMHES
SUBROUTINE COMHES(NM,N,LOW,IGH,AR,AI,INT) This subroutine is a translation of the ALGOL procedure COMHES, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). Given a COMPLEX GENERAL matrix, this subroutine reduces a submatrix situated in rows and columns LOW through IGH to upper Hessenberg form by stabilized elementary similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH ARE integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. AR and AI contain the real and imaginary parts, respectively, of the complex input matrix. On OUTPUT AR and AI contain the real and imaginary parts, respectively, of the Hessenberg matrix. The multipliers which were used in the reduction are stored in the remaining triangles under the Hessenberg matrix. INT contains information on the rows and columns interchanged in the reduction. Only elements LOW through IGH are used. Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
COMLR
SUBROUTINE COMLR(NM,N,LOW,IGH,HR,HI,WR,WI,IERR) This subroutine is a translation of the ALGOL procedure COMLR, NUM. MATH. 12, 369-376(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 396-403(1971). This subroutine finds the eigenvalues of a COMPLEX UPPER Hessenberg matrix by the modified LR method. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. HR and HI contain the real and imaginary parts, respectively, of the complex upper Hessenberg matrix. Their lower triangles below the subdiagonal contain the multipliers which were used in the reduction by COMHES, if performed. On OUTPUT The upper Hessenberg portions of HR and HI have been destroyed. Therefore, they must be saved before calling COMLR if subsequent calculation of eigenvectors is to be performed. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Calls CSROOT for complex square root. Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
COMLR2
SUBROUTINE COMLR2(NM,N,LOW,IGH,INT,HR,HI,WR,WI,ZR,ZI,IERR) This subroutine is a translation of the ALGOL procedure COMLR2, NUM. MATH. 16, 181-204(1970) by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971). This subroutine finds the eigenvalues and eigenvectors of a COMPLEX UPPER Hessenberg matrix by the modified LR method. The eigenvectors of a COMPLEX GENERAL matrix can also be found if COMHES has been used to reduce this general matrix to Hessenberg form. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. INT contains information on the rows and columns interchanged in the reduction by COMHES, if performed. Only elements LOW through IGH are used. If the eigenvectors of the HESSEN- BERG matrix are desired, set INT(J)=J for these elements. HR and HI contain the real and imaginary parts, respectively, of the complex upper Hessenberg matrix. Their lower triangles below the subdiagonal contain the multipliers which were used in the reduction by COMHES, if performed. If the eigenvectors of the Hessenberg matrix are desired, these elements must be set to zero. On OUTPUT The upper Hessenberg portions of HR and HI have been destroyed, but the location HR(1,1) contains the norm of the triangularized matrix. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors. The eigenvectors are unnormalized. If an error exit is made, none of the eigenvectors has been found. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Calls CSROOT for complex square root. Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
COMPB
SUBROUTINE COMPB(N,IERROR,AN,BN,CN,B,AH,BH)
COMQR
SUBROUTINE COMQR(NM,N,LOW,IGH,HR,HI,WR,WI,IERR) This subroutine is a translation of a unitary analogue of the ALGOL procedure COMLR, NUM. MATH. 12, 369-376(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 396-403(1971). The unitary analogue substitutes the QR algorithm of Francis (COMP. JOUR. 4, 332-345(1962)) for the LR algorithm. This subroutine finds the eigenvalues of a COMPLEX upper Hessenberg matrix by the QR method. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. HR and HI contain the real and imaginary parts, respectively, of the complex upper Hessenberg matrix. Their lower triangles below the subdiagonal contain information about the unitary transformations used in the reduction by CORTH, if performed. On OUTPUT The upper Hessenberg portions of HR and HI have been destroyed. Therefore, they must be saved before calling COMQR if subsequent calculation of eigenvectors is to be performed. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. IERR is set to ZERO for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Calls CSROOT for complex square root. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
COMQR2
SUBROUTINE COMQR2(NM,N,LOW,IGH,ORTR,ORTI,HR,HI,WR,WI,ZR,ZI,IERR) This subroutine is a translation of a unitary analogue of the ALGOL procedure COMLR2, NUM. MATH. 16, 181-204(1970) by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971). The unitary analogue substitutes the QR algorithm of Francis (COMP. JOUR. 4, 332-345(1962)) for the LR algorithm. This subroutine finds the eigenvalues and eigenvectors of a COMPLEX UPPER Hessenberg matrix by the QR method. The eigenvectors of a COMPLEX GENERAL matrix can also be found if CORTH has been used to reduce this general matrix to Hessenberg form. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. ORTR and ORTI contain information about the unitary trans- formations used in the reduction by CORTH, if performed. Only elements LOW through IGH are used. If the eigenvectors of the Hessenberg matrix are desired, set ORTR(J) and ORTI(J) to 0.0E0 for these elements. HR and HI contain the real and imaginary parts, respectively, of the complex upper Hessenberg matrix. Their lower triangles below the subdiagonal contain further information about the transformations which were used in the reduction by CORTH, if performed. If the eigenvectors of the Hessenberg matrix are desired, these elements may be arbitrary. On OUTPUT ORTR, ORTI, and the upper Hessenberg portions of HR and HI have been destroyed. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors. The eigenvectors are unnormalized. If an error exit is made, none of the eigenvectors has been found. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Calls CSROOT for complex square root. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CORTB
SUBROUTINE CORTB(NM,LOW,IGH,AR,AI,ORTR,ORTI,M,ZR,ZI) This subroutine is a translation of a complex analogue of the ALGOL procedure ORTBAK, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). This subroutine forms the eigenvectors of a COMPLEX GENERAL matrix by back transforming those of the corresponding upper Hessenberg matrix determined by CORTH. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1 and IGH equal to the order of the matrix. AR and AI contain information about the unitary transformations used in the reduction by CORTH in their strict lower triangles. ORTR and ORTI contain further information about the transformations used in the reduction by CORTH. Only elements LOW through IGH are used. M is the number of columns of ZR and ZI to be back transformed. ZR and ZI contain the real and imaginary parts, respectively, of the eigenvectors to be back transformed in their first M columns. On OUTPUT ZR and ZI contain the real and imaginary parts, respectively, of the transformed eigenvectors in their first M columns. ORTR and ORTI have been altered. Note that CORTB preserves vector Euclidean norms. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CORTH
SUBROUTINE CORTH(NM,N,LOW,IGH,AR,AI,ORTR,ORTI) This subroutine is a translation of a complex analogue of the ALGOL procedure ORTHES, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). Given a COMPLEX GENERAL matrix, this subroutine reduces a submatrix situated in rows and columns LOW through IGH to upper Hessenberg form by unitary similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine CBAL. If CBAL has not been used, set LOW=1, IGH=N. AR and AI contain the real and imaginary parts, respectively, of the complex input matrix. On OUTPUT AR and AI contain the real and imaginary parts, respectively, of the Hessenberg matrix. Information about the unitary transformations used in the reduction is stored in the remaining triangles under the Hessenberg matrix. ORTR and ORTI contain further information about the transformations. Only elements LOW through IGH are used. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
CPBCO
SUBROUTINE CPBCO(ABD,LDA,N,M,RCOND,Z,INFO) CPBCO factors a complex Hermitian positive definite matrix stored in band form and estimates the condition of the matrix. If RCOND is not needed, CPBFA is slightly faster. To solve A*X = B , follow CPBCO by CPBSL. To compute INVERSE(A)*C , follow CPBCO by CPBSL. To compute DETERMINANT(A) , follow CPBCO by CPBDI. On Entry ABD COMPLEX(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = CTRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Band Storage If A is a Hermitian positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses M + 1 rows of A , except for the M by M upper left triangle, which is ignored. Example: If the original matrix is 11 12 13 0 0 0 12 22 23 24 0 0 13 23 33 34 35 0 0 24 34 44 45 46 0 0 35 45 55 56 0 0 0 46 56 66 then N = 6 , M = 2 and ABD should contain * * 13 24 35 46 * 12 23 34 45 56 11 22 33 44 55 66 LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CPBFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,MAX0,MIN0,REAL
CPBDI
SUBROUTINE CPBDI(ABD,LDA,N,M,DET) CPBDI computes the determinant of a complex Hermitian positive definite band matrix using the factors computed by CPBCO or CPBFA. If the inverse is needed, use CPBSL N times. On Entry ABD COMPLEX(LDA, N) the output from CPBCO or CPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. On Return DET REAL(2) determinant of original matrix in the form determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions Fortran REAL
CPBFA
SUBROUTINE CPBFA(ABD,LDA,N,M,INFO) CPBFA factors a complex Hermitian positive definite matrix stored in band form. CPBFA is usually called by CPBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD COMPLEX(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = CTRANS(R)*R . INFO INTEGER = 0 for normal return. = K if the leading minor of order K is not positive definite. Band Storage If A is a Hermitian positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CDOTC Fortran AIMAG,CMPLX,CONJG,MAX0,REAL,SQRT
CPBSL
SUBROUTINE CPBSL(ABD,LDA,N,M,B) CPBSL solves the complex Hermitian positive definite band system A*X = B using the factors computed by CPBCO or CPBFA. On Entry ABD COMPLEX(LDA, N) the output from CPBCO or CPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CPBCO(ABD,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CPBSL(ABD,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran MIN0
CPEVL
SUBROUTINE CPEVL(N,M,A,Z,C,B,KBD)
CPEVLR
SUBROUTINE CPEVLR(N,M,A,X,C)
CPOCO
SUBROUTINE CPOCO(A,LDA,N,RCOND,Z,INFO) CPOCO factors a complex Hermitian positive definite matrix and estimates the condition of the matrix. If RCOND is not needed, CPOFA is slightly faster. To solve A*X = B , follow CPOCO by CPOSL. To compute INVERSE(A)*C , follow CPOCO by CPOSL. To compute DETERMINANT(A) , follow CPOCO by CPODI. To compute INVERSE(A) , follow CPOCO by CPODI. On Entry A COMPLEX(LDA, N) the Hermitian matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = CTRANS(R)*R where CTRANS(R) is the conjugate transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CPOFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL
CPODI
SUBROUTINE CPODI(A,LDA,N,DET,JOB) CPODI computes the determinant and inverse of a certain complex Hermitian positive definite matrix (see below) using the factors computed by CPOCO, CPOFA or CQRDC. On Entry A COMPLEX(LDA, N) the output A from CPOCO or CPOFA or the output X from CQRDC. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A If CPOCO or CPOFA was used to factor A then CPODI produces the upper half of INVERSE(A) . If CQRDC was used to decompose X then CPODI produces the upper half of INVERSE(CTRANS(X)*X) where CTRANS(X) is the conjugate transpose. Elements of A below the diagonal are unchanged. If the units digit of JOB is zero, A is unchanged. DET REAL(2) determinant of A or of CTRANS(X)*X if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition a division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if CPOCO or CPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL Fortran CONJG,MOD,REAL
CPOFA
SUBROUTINE CPOFA(A,LDA,N,INFO) CPOFA factors a complex Hermitian positive definite matrix. CPOFA is usually called by CPOCO, but it can be called directly with a saving in time if RCOND is not needed. (Time for CPOCO) = (1 + 18/N)*(Time for CPOFA) . On Entry A COMPLEX(LDA, N) the Hermitian matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = CTRANS(R)*R where CTRANS(R) is the conjugate transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CDOTC Fortran AIMAG,CMPLX,CONJG,REAL,SQRT
CPOFS
SUBROUTINE CPOFS(A,LDA,N,V,ITASK,IND,WORK) Subroutine CPOFS solves a positive definite symmetric NxN system of complex linear equations using LINPACK subroutines CPOCO and CPOSL. That is, if A is an NxN complex positive definite symmetric matrix and if X and B are complex N-vectors, then CPOFS solves the equation A*X=B. Care should be taken not to use CPOFS with a non-Hermitian matrix. The matrix A is first factored into upper and lower tri- angular matrices R and R-TRANSPOSE. These factors are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of a does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeedIng solutions. In this case, the contents of A, LDA, and N must not have been altered by the user following factorization (ITASK=1). IND will not be changed by CPOFS in this case. Argument Description *** A COMPLEX(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. Only the upper triangle, including the diagonal, of the coefficient matrix need be entered and will subse- quently be referenced and changed by the routine. on return, contains in its upper triangle an upper triangular matrix R such that A = (R-TRANSPOSE) * R . LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1. (terminal error message IND=-2) V COMPLEX(N) on entry the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK = 1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A. if ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 see error message corresponding to IND below. WORK COMPLEX(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular or is not positive definite. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. NOTE- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CPOIR
SUBROUTINE CPOIR(A,LDA,N,V,ITASK,IND,WORK) Subroutine CPOIR solves a complex positive definite Hermitian NxN system of single precision linear equations using LINPACK subroutines CPOFA and CPOSL. One pass of iterative refine- ment is used only to obtain an estimate of the accuracy. That is, if A is an NxN complex positive definite Hermitian matrix and if X and B are complex N-vectors, then CPOIR solves the equation A*X=B. Care should be taken not to use CPOIR with a non-Hermitian matrix. The matrix A is first factored into upper and lower triangular matrices R and R-TRANSPOSE. These factors are used to calculate the solution, X. Then the residual vector is found and used to calculate an estimate of the relative error, IND. IND estimates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N, and WORK must not have been altered by the user following factorization (ITASK=1). IND will not be changed by CPOIR in this case. Argument Description *** A COMPLEX(LDA,N) the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. Only the upper triangle, including the diagonal, of the coefficient matrix need be entered. A is not altered by the routine. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to one. (terminal error message IND=-2) V COMPLEX(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER if ITASK = 1, the matrix A is factored and then the linear equation is solved. if ITASK .GT. 1, the equation is solved using the existing factored matrix A (stored in WORK). if ITASK .LT. 1, then terminal terminal error IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. IND=75 means that the solution vector X is zero. LT. 0 see error message corresponding to IND below. WORK COMPLEX(N*(N+1)) a singly subscripted array of dimension at least N*(N+1). Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than one. IND=-3 terminal ITASK is less than one. IND=-4 terminal The matrix A is computationally singular or is not positive definite. A solution has not been computed. IND=-10 warning The solution has no apparent significance. the solution may be inaccurate or the matrix a may be poorly scaled. NOTE- the above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
CPOSL
SUBROUTINE CPOSL(A,LDA,N,B) CPOSL solves the COMPLEX Hermitian positive definite system A * X = B using the factors computed by CPOCO or CPOFA. On Entry A COMPLEX(LDA, N) the output from CPOCO or CPOFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CPOCO(A,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CPOSL(A,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC
CPPCO
SUBROUTINE CPPCO(AP,N,RCOND,Z,INFO) CPPCO factors a complex Hermitian positive definite matrix stored in packed form and estimates the condition of the matrix. If RCOND is not needed, CPPFA is slightly faster. To solve A*X = B , follow CPPCO by CPPSL. To compute INVERSE(A)*C , follow CPPCO by CPPSL. To compute DETERMINANT(A) , follow CPPCO by CPPDI. To compute INVERSE(A) , follow CPPCO by CPPDI. On Entry AP COMPLEX (N*(N+1)/2) the packed form of a Hermitian matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = CTRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a Hermitian matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CPPFA BLAS CAXPY,CDOTC,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL
CPPDI
SUBROUTINE CPPDI(AP,N,DET,JOB) CPPDI computes the determinant and inverse of a complex Hermitian positive definite matrix using the factors computed by CPPCO or CPPFA . On Entry AP COMPLEX (N*(N+1)/2) the output from CPPCO or CPPFA. N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return AP the upper triangular half of the inverse . The strict lower triangle is unaltered. DET REAL(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if CPOCO or CPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL Fortran CONJG,MOD,REAL
CPPFA
SUBROUTINE CPPFA(AP,N,INFO) CPPFA factors a complex Hermitian positive definite matrix stored in packed form. CPPFA is usually called by CPPCO, but it can be called directly with a saving in time if RCOND is not needed. (Time for CPPCO) = (1 + 18/N)*(Time for CPPFA) . On Entry AP COMPLEX (N*(N+1)/2) the packed form of a Hermitian matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = CTRANS(R)*R . INFO INTEGER = 0 for normal return. = K If the leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a Hermitian matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CDOTC Fortran AIMAG,CMPLX,CONJG,REAL,SQRT
CPPSL
SUBROUTINE CPPSL(AP,N,B) CPPSL solves the complex Hermitian positive definite system A * X = B using the factors computed by CPPCO or CPPFA. On Entry AP COMPLEX (N*(N+1)/2) the output from CPPCO or CPPFA. N INTEGER the order of the matrix A . B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CPPCO(AP,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CPPSL(AP,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC
CPTSL
SUBROUTINE CPTSL(N,D,E,B) CPTSL given a positive definite tridiagonal matrix and a right hand side will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. D COMPLEX(N) is the diagonal of the tridiagonal matrix. On output D is destroyed. E COMPLEX(N) is the offdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the offdiagonal. B COMPLEX(N) is the right hand side vector. On Return B contains the solution. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No externals Fortran CONJG,MOD
CQRDC
SUBROUTINE CQRDC(X,LDX,N,P,QRAUX,JPVT,WORK,JOB) CQRDC uses Householder transformations to compute the QR factorization of an N by P matrix X. Column pivoting based on the 2-norms of the reduced columns may be performed at the users option. On Entry X COMPLEX(LDX,P), where LDX .GE. N. X contains the matrix whose decomposition is to be computed. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of rows of the matrix X. P INTEGER. P is the number of columns of the matrix X. JVPT INTEGER(P). JVPT contains integers that control the selection of the pivot columns. The K-th column X(K) of X is placed in one of three classes according to the value of JVPT(K). If JVPT(K) .GT. 0, then X(K) is an initial column. If JVPT(K) .EQ. 0, then X(K) is a free column. If JVPT(K) .LT. 0, then X(K) is a final column. Before the decomposition is computed, initial columns are moved to the beginning of the array X and final columns to the end. Both initial and final columns are frozen in place during the computation and only free columns are moved. At the K-th stage of the reduction, if X(K) is occupied by a free column it is interchanged with the free column of largest reduced norm. JVPT is not referenced if JOB .EQ. 0. WORK COMPLEX(P). WORK is a work array. WORK is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. If JOB .EQ. 0, no pivoting is done. If JOB .NE. 0, pivoting is done. On Return X X contains in its upper triangle the upper triangular matrix R of the QR factorization. Below its diagonal X contains information from which the unitary part of the decomposition can be recovered. Note that if pivoting has been requested, the decomposition is not that of the original matrix X but that of X with its columns permuted as described by JVPT. QRAUX COMPLEX(P). QRAUX contains further information required to recover the unitary part of the decomposition. JVPT JVPT(K) contains the index of the column of the original matrix that has been interchanged into the K-th column, if pivoting was requested. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. CQRDC uses the following functions and subprograms. BLAS CAXPY,CDOTC,CSCAL,CSWAP,SCNRM2 Fortran ABS,AIMAG,AMAX1,CABS,CMPLX,CSQRT,MIN0,REAL
CQRSL
SUBROUTINE CQRSL(X,LDX,N,K,QRAUX,Y,QY,QTY,B,RSD,XB,JOB,INFO) CQRSL applies the output of CQRDC to compute coordinate transformations, projections, and least squares solutions. For K .LE. MIN(N,P), let XK be the matrix XK = (X(JVPT(1)),X(JVPT(2)), ... ,X(JVPT(K))) formed from columnns JVPT(1), ... ,JVPT(K) of the original N x P matrix X that was input to CQRDC (if no pivoting was done, XK consists of the first K columns of X in their original order). CQRDC produces a factored unitary matrix Q and an upper triangular matrix R such that XK = Q * (R) (0) This information is contained in coded form in the arrays X and QRAUX. On Entry X COMPLEX(LDX,P). X contains the output of CQRDC. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of rows of the matrix XK. It must have the same value as N in CQRDC. K INTEGER. K is the number of columns of the matrix XK. K must not be greater than (N,P), where P is the same as in the calling sequence to CQRDC. QRAUX COMPLEX(P). QRAUX contains the auxiliary output from CQRDC. Y COMPLEX(N) Y contains an N-vector that is to be manipulated by CQRSL. JOB INTEGER. JOB specifies what is to be computed. JOB has the decimal expansion ABCDE, with the following meaning. If A .NE. 0, compute QY. If B,C,D, or E .NE. 0, compute QTY. If C .NE. 0, compute B. If D .NE. 0, compute RSD . If E .NE. 0, compute XB. Note that a request to compute B, RSD, or XB automatically triggers the computation of QTY, for which an array must be provided in the calling sequence. On Return QY COMPLEX(N). QY contains Q*Y, if its computation has been requested. QTY COMPLEX(N). QTY contains CTRANS(Q)*Y, if its computation has been requested. Here CTRANS(Q) is the conjugate transpose of the matrix Q. B COMPLEX(K) B contains the solution of the least squares problem minimize NORM2(Y - XK*B), if its computation has been requested. (Note that if pivoting was requested in CQRDC, the J-th component of B will be associated with column JVPT(J) of the original matrix X that was input into CQRDC.) RSD COMPLEX(N). RSD contains the least squares residual Y - XK*B, if its computation has been requested. RSD is also the orthogonal projection of Y onto the orthogonal complement of the column space of XK. XB COMPLEX(N). XB contains the least squares approximation XK*B, if its computation has been requested. XB is also the orthogonal projection of Y onto the column space of X. INFO INTEGER. INFO is zero unless the computation of B has been requested and R is exactly singular. In this case, INFO is the index of the first zero diagonal element of R and B is left unaltered. The parameters QY, QTY, B, RSD, and XB are not referenced if their computation is not requested and in this case can be replaced by dummy variables in the calling program. To save storage, the user may in some cases use the same array for different parameters in the calling sequence. A frequently occuring example is when one wishes to compute any of B, RSD, or XB and does not need Y or QTY. In this case one may identify Y, QTY, and one of B, RSD, or XB, while providing separate arrays for anything else that is to be computed. Thus the calling sequence CALL CQRSL(X,LDX,N,K,QRAUX,Y,DUM,Y,B,Y,DUM,110,INFO) will result in the computation of B and RSD, with RSD overwriting Y. More generally, each item in the following list contains groups of permissible identifications for a single callinng sequence. 1. (Y,QTY,B) (RSD) (XB) (QY) 2. (Y,QTY,RSD) (B) (XB) (QY) 3. (Y,QTY,XB) (B) (RSD) (QY) 4. (Y,QY) (QTY,B) (RSD) (XB) 5. (Y,QY) (QTY,RSD) (B) (XB) 6. (Y,QY) (QTY,XB) (B) (RSD) In any group the value returned in the array allocated to the group corresponds to the last member of the group. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. CQRSL uses the following functions and subprograms. BLAS CAXPY,CCOPY,CDOTC Fortran ABS,AIMAG,MIN0,MOD,REAL
CROTG
SUBROUTINE CROTG(CA,CB,C,S) Complex Givens transformation Construct the Givens transformation (C S) G = ( ), C**2 + CABS(S)**2 =1, (-S C) which zeros the second entry of the complex 2-vector (CA,CB)**T The quantity CA/CABS(CA)*NORM(CA,CB) overwrites CA in storage. INPUT: CA (Complex) CB (Complex) Output: CA (Complex) CA/CABS(CA)*NORM(CA,CB) C (Real) S (Complex)
CSCAL
SUBROUTINE CSCAL(N,CA,CX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CA complex scale factor CX complex vector with N elements INCX storage spacing between elements of CX --Output-- CSCAL complex result (unchanged if N .LE. 0) replace complex CX by complex CA*CX. For I = 0 to N-1, replace CX(1+I*INCX) with CA * CX(1+I*INCX)
CSCALE
SUBROUTINE CSCALE(A,NRDA,NROW,NCOL,COLS,COLSAV,ROWS,ROWSAV,ANORM,
CSICO
SUBROUTINE CSICO(A,LDA,N,KPVT,RCOND,Z) CSICO factors a complex symmetric matrix by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, CSIFA is slightly faster. To solve A*X = B , follow CSICO by CSISL. To compute INVERSE(A)*C , follow CSICO by CSISL. To compute INVERSE(A) , follow CSICO by CSIDI. To compute DETERMINANT(A) , follow CSICO by CSIDI. On Entry A COMPLEX(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CSIFA BLAS CAXPY,CDOTU,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,IABS,REAL
CSIDI
SUBROUTINE CSIDI(A,LDA,N,KPVT,DET,WORK,JOB) CSIDI computes the determinant and inverse of a complex symmetric matrix using the factors from CSIFA. On Entry A COMPLEX(LDA,N) the output from CSIFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CSIFA. WORK COMPLEX(N) work vector. Contents destroyed. JOB INTEGER JOB has the decimal expansion AB where If B .NE. 0, the inverse is computed, If A .NE. 0, the determinant is computed, For example, JOB = 11 gives both. On Return Variables not requested by JOB are not used. A contains the upper triangle of the inverse of the original matrix. The strict lower triangle is never referenced. DET COMPLEX(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. Error Condition A division by zero may occur if the inverse is requested and CSICO has set RCOND .EQ. 0.0 or CSIFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CCOPY,CDOTU,CSWAP Fortran ABS,CMPLX,IABS,MOD,REAL
CSIFA
SUBROUTINE CSIFA(A,LDA,N,KPVT,INFO) CSIFA factors a complex symmetric matrix by elimination with symmetric pivoting. To solve A*X = B , follow CSIFA by CSISL. To compute INVERSE(A)*C , follow CSIFA by CSISL. To compute DETERMINANT(A) , follow CSIFA by CSIDI. To compute INVERSE(A) , follow CSIFA by CSIDI. On Entry A COMPLEX(LDA,N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that CSISL or CSIDI may divide by zero if called. LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CSWAP,ICAMAX Fortran ABS,AIMAG,AMAX1,REAL,SQRT
CSISL
SUBROUTINE CSISL(A,LDA,N,KPVT,B) CSISL solves the complex symmetric system A * X = B using the factors computed by CSIFA. On Entry A COMPLEX(LDA,N) the output from CSIFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CSIFA. B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if CSICO has set RCOND .EQ. 0.0 or CSIFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CSIFA(A,LDA,N,KVPT,INFO) If (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CSISL(A,LDA,N,KVPT,C(1,j)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CDOTU Fortran IABS
CSPCO
SUBROUTINE CSPCO(AP,N,KPVT,RCOND,Z) CSPCO factors a complex symmetric matrix stored in packed form by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, CSPFA is slightly faster. To solve A*X = B , follow CSPCO by CSPSL. To compute INVERSE(A)*C , follow CSPCO by CSPSL. To compute INVERSE(A) , follow CSPCO by CSPDI. To compute DETERMINANT(A) , follow CSPCO by CSPDI. On Entry AP COMPLEX (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK CSPFA BLAS CAXPY,CDOTU,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,IABS,REAL
CSPDI
SUBROUTINE CSPDI(AP,N,KPVT,DET,WORK,JOB) CSPDI computes the determinant and inverse of a complex symmetric matrix using the factors from CSPFA, where the matrix is stored in packed form. On Entry AP COMPLEX (N*(N+1)/2) the output from CSPFA. N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CSPFA. WORK COMPLEX(N) work vector. Contents ignored. JOB INTEGER JOB has the decimal expansion AB where if B .NE. 0, the inverse is computed, if A .NE. 0, the determinant is computed. For example, JOB = 11 gives both. On Return Variables not requested by JOB are not used. AP contains the upper triangle of the inverse of the original matrix, stored in packed form. The columns of the upper triangle are stored sequentially in a one-dimensional array. DET COMPLEX(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. Error Condition A division by zero will occur if the inverse is requested and CSPCO has set RCOND .EQ. 0.0 or CSPFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CCOPY,CDOTU,CSWAP Fortran ABS,CMPLX,IABS,MOD,REAL
CSPFA
SUBROUTINE CSPFA(AP,N,KPVT,INFO) CSPFA factors a complex symmetric matrix stored in packed form by elimination with symmetric pivoting. To solve A*X = B , follow CSPFA by CSPSL. To compute INVERSE(A)*C , follow CSPFA by CSPSL. To compute DETERMINANT(A) , follow CSPFA by CSPDI. To compute INVERSE(A) , follow CSPFA by CSPDI. On Entry AP COMPLEX (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KVPT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that CSPSL or CSPDI may divide by zero if called. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CSWAP,ICAMAX Fortran ABS,AIMAG,AMAX1,REAL,SQRT
CSPSL
SUBROUTINE CSPSL(AP,N,KPVT,B) CSISL solves the complex symmetric system A * X = B using the factors computed by CSPFA. On Entry AP COMPLEX(N*(N+1)/2) the output from CSPFA. N INTEGER the order of the matrix A . KVPT INTEGER(N) the pivot vector from CSPFA. B COMPLEX(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if CSPCO has set RCOND .EQ. 0.0 or CSPFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL CSPFA(AP,N,KVPT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL CSPSL(AP,N,KVPT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS CAXPY,CDOTU Fortran IABS
CSROOT
SUBROUTINE CSROOT(XR,XI,YR,YI)
CSROT
SUBROUTINE CSROT(N,CX,INCX,CY,INCY,C,S) CSROT applies the complex Givens rotation (X) ( C S)(X) (Y) = (-S C)(Y) N times where for I = 0,...,N-1 X = CX(1+I*INCX) Y = CY(1+I*INCY) Argument Description N (integer) number of elements in each vector CX (complex array) beginning of one vector INCX (integer) memory spacing of successive elements of vector CX CY (complex array) beginning of the other vector INCY (integer) memory spacing of successive elements of vector CY C (real) cosine term of the rotation S (real) sine term of the rotation.
CSSCAL
SUBROUTINE CSSCAL(N,SA,CX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SA single precision scale factor CX complex vector with N elements INCX storage spacing between elements of CX --Output-- CX scaled result (unchanged if N .LE. 0) Replace complex CX by (single precision SA) * (complex CX) For I = 0 to N-1, replace CX(1+I*INCX) with SA * CX(1+I*INCX)
CSVDC
SUBROUTINE CSVDC(X,LDX,N,P,S,E,U,LDU,V,LDV,WORK,JOB,INFO) CSVDC is a subroutine to reduce a complex NxP matrix X by unitary transformations U and V to diagonal form. The diagonal elements S(I) are the singular values of X. The columns of U are the corresponding left singular vectors, and the columns of V the right singular vectors. On Entry X COMPLEX(LDX,P), where LDX .GE. N. X contains the matrix whose singular value decomposition is to be computed. X is destroyed by CSVDC. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of columns of the matrix X. P INTEGER. P is the number of rows of the matrix X. LDU INTEGER. LDU is the leading dimension of the array U (see below). LDV INTEGER. LDV is the leading dimension of the array V (see below). WORK COMPLEX(N). WORK is a scratch array. JOB INTEGER. JOB controls the computation of the singular vectors. It has the decimal expansion AB with the following meaning A .EQ. 0 Do not compute the left singular vectors. A .EQ. 1 Return the N left singular vectors in U. A .GE. 2 Return the first MIN(N,P) left singular vectors in U. B .EQ. 0 Do not compute the right singular vectors. B .EQ. 1 Return the right singular vectors in V. On Return S COMPLEX(MM), where MM = MIN(N+1,P). The first MIN(N,P) entries of S contain the singular values of X arranged in descending order of magnitude. E COMPLEX(P). E ordinarily contains zeros. However see the discussion of INFO for exceptions. U COMPLEX(LDU,K), where LDU .GE. N. If JOBA .EQ. 1 then K .EQ. N. If JOBA .GE. 2 then K .EQ. MIN(N,P). U contains the matrix of right singular vectors. U is not referenced if JOBA .EQ. 0. If N .LE. P or if JOBA .GT. 2, then U may be identified with X in the subroutine call. V COMPLEX(LDV,P), where LDV .GE. P. V contains the matrix of right singular vectors. V is not referenced if JOB .EQ. 0. If P .LE. N, then V may be identified with X in the subroutine call. INFO INTEGER. The singular values (and their corresponding singular vectors) S(INFO+1),S(INFO+2),...,S(M) are correct (here M=MIN(N,P)). Thus if INFO.EQ. 0, all the singular values and their vectors are correct. In any event, the matrix B = CTRANS(U)*X*V is the bidiagonal matrix with the elements of S on its diagonal and the elements of E on its super-diagonal (CTRANS(U) is the conjugate-transpose of U). Thus the singular values of X and B are the same. LINPACK. This version dated 03/19/79 . Stewart, G. W., University of Maryland, Argonne National Lab. CSVDC uses the following functions and subprograms. External CSROT BLAS CAXPY,CDOTC,CSCAL,CSWAP,SCNRM2,SROTG Fortran ABS,AIMAG,AMAX1,CABS,CMPLX Fortran CONJG,MAX0,MIN0,MOD,REAL,SQRT
CSWAP
SUBROUTINE CSWAP(N,CX,INCX,CY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX CY complex vector with N elements INCY storage spacing between elements of CY --Output-- CX input vector CY (unchanged if N .LE. 0) CY input vector CX (unchanged if N .LE. 0) Interchange complex CX and complex CY For I = 0 to N-1, interchange CX(LX+I*INCX) and CY(LY+I*INCY), where LX = 1 if INCX .GT. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
CTRCO
SUBROUTINE CTRCO(T,LDT,N,RCOND,Z,JOB) CTRCO estimates the condition of a complex triangular matrix. On Entry T COMPLEX(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 0 T is lower triangular. = nonzero T is upper triangular. On Return RCOND REAL an estimate of the reciprocal condition of T . For the system T*X = B , relative perturbations in T and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then T may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z COMPLEX(N) a work vector whose contents are usually unimportant. If T is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSSCAL,SCASUM Fortran ABS,AIMAG,AMAX1,CMPLX,CONJG,REAL
CTRDI
SUBROUTINE CTRDI(T,LDT,N,DET,JOB,INFO) CTRDI computes the determinant and inverse of a complex triangular matrix. On Entry T COMPLEX(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 010 no det, inverse of lower triangular. = 011 no det, inverse of upper triangular. = 100 det, no inverse. = 110 det, inverse of lower triangular. = 111 det, inverse of upper triangular. On Return T inverse of original matrix if requested. Otherwise unchanged. DET COMPLEX(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. CABS1(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . INFO INTEGER INFO contains zero if the system is nonsingular and the inverse is requested. Otherwise INFO contains the index of a zero diagonal element of T. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CSCAL Fortran ABS,AIMAG,CMPLX,MOD,REAL
CTRSL
SUBROUTINE CTRSL(T,LDT,N,B,JOB,INFO) CTRSL solves systems of the form T * X = B or CTRANS(T) * X = B where T is a triangular matrix of order N. Here CTRANS(T) denotes the conjugate transpose of the matrix T. On Entry T COMPLEX(LDT,N) T contains the matrix of the system. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. B COMPLEX(N). B contains the right hand side of the system. JOB INTEGER JOB specifies what kind of system is to be solved. If JOB is 00 solve T*X = B, T lower triangular, 01 solve T*X = B, T upper triangular, 10 solve CTRANS(T)*X = B, T lower triangular, 11 solve CTRANS(T)*X = B, T upper triangular. On Return B B contains the solution, if INFO .EQ. 0. Otherwise B is unaltered. INFO INTEGER INFO contains zero if the system is nonsingular. Otherwise INFO contains the index of the first zero diagonal element of T. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. Subroutines and Functions BLAS CAXPY,CDOTC Fortran ABS,AIMAG,CONJG,MOD,REAL
DASUM
DOUBLE PRECISION FUNCTION DASUM(N,DX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX --Output-- DASUM double precision result (zero if N .LE. 0) Returns sum of magnitudes of double precision DX. DASUM = sum from 0 to N-1 of DABS(DX(1+I*INCX))
DASYIK
SUBROUTINE DASYIK(X,FNU,KODE,FLGIK,RA,ARG,IN,Y)
DASYJY
SUBROUTINE DASYJY(FUNJY,X,FNU,FLGJY,IN,Y,WK,IFLW) DASYJY computes Bessel functions J and Y for arguments X.GT.0.0 and orders FNU .GE. 35.0 on FLGJY = 1 and FLGJY = -1 respectively INPUT FUNJY - External function JAIRY or YAIRY X - Argument, X.GT.0.0D0 FNU - Order of the first Bessel function FLGJY - Selection flag FLGJY = 1.0D0 gives the J function FLGJY = -1.0D0 gives the Y function IN - Number of functions desired, IN = 1 or 2 OUTPUT Y - A vector whose first IN components contain the sequence IFLW - A flag indicating underflow or overflow return variables for BESJ only WK(1) = 1 - (X/FNU)**2 = W**2 WK(2) = DSQRT(DABS(WK(1))) WK(3) = DABS(WK(2) - DATAN(WK(2))) or DABS(LN((1 + WK(2))/(X/FNU)) - WK(2)) = DABS((2/3)*ZETA**(3/2)) WK(4) = FNU*WK(3) WK(5) = (1.5*WK(3)*FNU)**(1/3) = DSQRT(ZETA)*FNU**(1/3) WK(6) = DSIGN(1.,W**2)*WK(5)**2 = DSIGN(1.,W**2)*ZETA*FNU**(2/3) WK(7) = FNU**(1/3) Written by D. E. Amos Abstract **** A Double Precision Routine **** DASYJY implements the uniform asymptotic expansion of the J and Y Bessel functions for FNU.GE.35 and real X.GT.0.0D0. The forms are identical except for a change in sign of some of the terms. This change in sign is accomplished by means of the flag FLGJY = 1 or -1. On FLGJY = 1 the Airy functions AI(X) and DAI(X) are supplied by the external function JAIRY, and on FLGJY = -1 the Airy functions BI(X) and DBI(X) are supplied by the external funtion YAIRY.
DAXPY
SUBROUTINE DAXPY(N,DA,DX,INCX,DY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DA double precision scalar multiplier DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DY double precision result (unchanged if N .LE. 0) Overwrite double precision DY with double precision DA*DX + DY. For I = 0 to N-1, replace DY(LY+I*INCY) with DA*DX(LX+I*INCX) + DY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N and LY is defined in a similar way using INCY.
DBDIFF
SUBROUTINE DBDIFF(L,V) DBDIFF computes the sum of B(L,K)*V(K)*(-1)**K where B(L,K) are the binomial coefficients. Truncated sums are computed by setting last part of the V vector to zero. On return, the binomial sum is in V(L).
DBNDAC
SUBROUTINE DBNDAC(G,MDG,NB,IP,IR,MT,JT) **** Double Precision version of BNDACC **** These subroutines solve the least squares problem Ax = b for banded matrices A using sequential accumulation of rows of the data matrix. Exactly one right-hand side vector is permitted. These subroutines are intended for the type of least squares systems that arise in applications such as curve or surface fitting of data. The least squares equations are accumulated and processed using only part of the data. This requires a certain user interaction during the solution of Ax = b. Specifically, suppose the data matrix (A B) is row partitioned into Q submatrices. Let (E F) be the T-th one of these submatrices where E = (0 C 0). Here the dimension of E is MT by N and the dimension of C is MT by NB. The value of NB is the bandwidth of A. The dimensions of the leading block of zeros in E are MT by JT-1. The user of the subroutine DBNDAC provides MT,JT,C and F for T=1,...,Q. Not all of this data must be supplied at once. Following the processing of the various blocks (E F), the matrix (A B) has been transformed to the form (R D) where R is upper triangular and banded with bandwidth NB. The least squares system Rx = d is then easily solved using back substitution by executing the statement CALL DBNDSL(1,...). The sequence of values for JT must be nondecreasing. This may require some preliminary interchanges of rows and columns of the matrix A. The primary reason for these subroutines is that the total processing can take place in a working array of dimension MU by NB+1. An acceptable value for MU is MU = MAX(MT + N + 1), where N is the number of unknowns. Here the maximum is taken over all values of MT for T=1,...,Q. Notice that MT can be taken to be a small as one, showing that MU can be as small as N+2. The subprogram DBNDAC processes the rows more efficiently if MU is large enough so that each new block (C F) has a distinct value of JT. The four principle parts of these algorithms are obtained by the following call statements CALL DBNDAC(...) Introduce new blocks of data. CALL DBNDSL(1,...)Compute solution vector and length of residual vector. CALL DBNDSL(2,...)Given any row vector H solve YR = H for the row vector Y. CALL DBNDSL(3,...)Given any column vector W solve RZ = W for the column vector Z. The dots in the above call statements indicate additional arguments that will be specified in the following paragraphs. The user must dimension the array appearing in the call list.. G(MDG,NB+1) Description of calling sequence for DBNDAC.. The entire set of parameters for DBNDAC are Input.. All Type REAL variables are DOUBLE PRECISION G(*,*) The working array into which the user will place the MT by NB+1 block (C F) in rows IR through IR+MT-1, columns 1 through NB+1. See descriptions of IR and MT below. MDG The number of rows in the working array G(*,*). The value of MDG should be .GE. MU. The value of MU is defined in the abstract of these subprograms. NB The bandwidth of the data matrix A. IP Set by the user to the value 1 before the first call to DBNDAC. Its subsequent value is controlled by DBNDAC to set up for the next call to DBNDAC. IR Index of the row of G(*,*) where the user is to place the new block of data (C F). Set by the user to the value 1 before the first call to DBNDAC. Its subsequent value is controlled by DBNDAC. A value of IR .GT. MDG is considered an error. MT,JT Set by the user to indicate respectively the number of new rows of data in the block and the index of the first nonzero column in that set of rows (E F) = (0 C 0 F) being processed. Output.. All Type REAL variables are DOUBLE PRECISION G(*,*) The working array which will contain the processed rows of that part of the data matrix which has been passed to DBNDAC. IP,IR The values of these arguments are advanced by DBNDAC to be ready for storing and processing a new block of data in G(*,*). Description of calling sequence for DBNDSL.. The user must dimension the arrays appearing in the call list.. G(MDG,NB+1), X(N) The entire set of parameters for DBNDSL are Input.. All Type REAL variables are DOUBLE PRECISION MODE Set by the user to one of the values 1, 2, or 3. These values respectively indicate that the solution of AX = B, YR = H or RZ = W is required. G(*,*),MDG, These arguments all have the same meaning and NB,IP,IR contents as following the last call to DBNDAC. X(*) With mode=2 or 3 this array contains, respectively, the right-side vectors H or W of the systems YR = H or RZ = W. N The number of variables in the solution vector. If any of the N diagonal terms are zero the subroutine DBNDSL prints an appropriate message. This condition is considered an error. Output.. All Type REAL variables are DOUBLE PRECISION X(*) This array contains the solution vectors X, Y or Z of the systems AX = B, YR = H or RZ = W depending on the value of MODE=1, 2 or 3. RNORM If MODE=1 RNORM is the Euclidean length of the residual vector AX-B. When MODE=2 or 3 RNORM is set to zero. Remarks.. To obtain the upper triangular matrix and transformed right-hand side vector D so that the super diagonals of R form the columns of G(*,*), execute the following Fortran statements. NBP1=NB+1 DO 10 J=1, NBP1 10 G(IR,J) = 0.E0 MT=1 JT=N+1 CALL DBNDAC(G,MDG,NB,IP,IR,MT,JT)
DBNDSL
SUBROUTINE DBNDSL(MODE,G,MDG,NB,IP,IR,X,N,RNORM) **** Double Precision version of BNDSOL **** These subroutines solve the least squares problem Ax = b for banded matrices A using sequential accumulation of rows of the data matrix. Exactly one right-hand side vector is permitted. These subroutines are intended for the type of least squares systems that arise in applications such as curve or surface fitting of data. The least squares equations are accumulated and processed using only part of the data. This requires a certain user interaction during the solution of Ax = b. Specifically, suppose the data matrix (A B) is row partitioned into Q submatrices. Let (E F) be the T-th one of these submatrices where E = (0 C 0). Here the dimension of E is MT by N and the dimension of C is MT by NB. The value of NB is the bandwidth of A. The dimensions of the leading block of zeros in E are MT by JT-1. The user of the subroutine DBNDAC provides MT,JT,C and F for T=1,...,Q. Not all of this data must be supplied at once. Following the processing of the various blocks (E F), the matrix (A B) has been transformed to the form (R D) where R is upper triangular and banded with bandwidth NB. The least squares system Rx = d is then easily solved using back substitution by executing the statement CALL DBNDSL(1,...). The sequence of values for JT must be nondecreasing. This may require some preliminary interchanges of rows and columns of the matrix A. The primary reason for these subroutines is that the total processing can take place in a working array of dimension MU by NB+1. An acceptable value for MU is MU = MAX(MT + N + 1), where N is the number of unknowns. Here the maximum is taken over all values of MT for T=1,...,Q. Notice that MT can be taken to be a small as one, showing that MU can be as small as N+2. The subprogram DBNDAC processes the rows more efficiently if MU is large enough so that each new block (C F) has a distinct value of JT. The four principle parts of these algorithms are obtained by the following call statements CALL DBNDAC(...) Introduce new blocks of data. CALL DBNDSL(1,...)Compute solution vector and length of residual vector. CALL DBNDSL(2,...)Given any row vector H solve YR = H for the row vector Y. CALL DBNDSL(3,...)Given any column vector W solve RZ = W for the column vector Z. The dots in the above call statements indicate additional arguments that will be specified in the following paragraphs. The user must dimension the array appearing in the call list.. G(MDG,NB+1) Description of calling sequence for DBNDAC.. The entire set of parameters for DBNDAC are Input.. All Type REAL variables are DOUBLE PRECISION G(*,*) The working array into which the user will place the MT by NB+1 block (C F) in rows IR through IR+MT-1, columns 1 through NB+1. See descriptions of IR and MT below. MDG The number of rows in the working array G(*,*). The value of MDG should be .GE. MU. The value of MU is defined in the abstract of these subprograms. NB The bandwidth of the data matrix A. IP Set by the user to the value 1 before the first call to DBNDAC. Its subsequent value is controlled by DBNDAC to set up for the next call to DBNDAC. IR Index of the row of G(*,*) where the user is the user to the value 1 before the first call to DBNDAC. Its subsequent value is controlled by DBNDAC. A value of IR .GT. MDG is considered an error. MT,JT Set by the user to indicate respectively the number of new rows of data in the block and the index of the first nonzero column in that set of rows (E F) = (0 C 0 F) being processed. Output.. All Type REAL variables are DOUBLE PRECISION G(*,*) The working array which will contain the processed rows of that part of the data matrix which has been passed to DBNDAC. IP,IR The values of these arguments are advanced by DBNDAC to be ready for storing and processing a new block of data in G(*,*). Description of calling sequence for DBNDSL.. The user must dimension the arrays appearing in the call list.. G(MDG,NB+1), X(N) The entire set of parameters for DBNDSL are Input.. MODE Set by the user to one of the values 1, 2, or 3. These values respectively indicate that the solution of AX = B, YR = H or RZ = W is required. G(*,*),MDG, These arguments all have the same meaning and NB,IP,IR contents as following the last call to DBNDAC. X(*) With mode=2 or 3 this array contains, respectively, the right-side vectors H or W of the systems YR = H or RZ = W. N The number of variables in the solution vector. If any of the N diagonal terms are zero the subroutine DBNDSL prints an appropriate message. This condition is considered an error. Output.. X(*) This array contains the solution vectors X, Y or Z of the systems AX = B, YR = H or RZ = W depending on the value of MODE=1, 2 or 3. RNORM If MODE=1 RNORM is the Euclidean length of the residual vector AX-B. When MODE=2 or 3 RNORM is set to zero. Remarks.. To obtain the upper triangular matrix and transformed right-hand side vector D so that the super diagonals of R form the columns of G(*,*), execute the following Fortran statements. NBP1=NB+1 DO 10 J=1, NBP1 10 G(IR,J) = 0.E0 MT=1 JT=N+1 CALL DBNDAC(G,MDG,NB,IP,IR,MT,JT)
DBNFAC
SUBROUTINE DBNFAC(W,NROWW,NROW,NBANDL,NBANDU,IFLAG)
DBNSLV
SUBROUTINE DBNSLV(W,NROWW,NROW,NBANDL,NBANDU,B)
DCDOT
SUBROUTINE DCDOT(N,FM,CX,INCX,CY,INCY,DCR,DCI) Computes the dot product of 2 complex vectors, CX and CY, e.g. CX DOT CY, or, CXconjugate DOT CY. The real and imaginary parts of CX and CY are converted to double precision, the dot product accumulation is done in double precision and the output is given as 2 double precision numbers, corresponding to the real and imaginary part of the result. Input N: Number of complex components of CX and CY. FM: =+1.0 compute CX DOT CY. =-1.0 compute CXconjugate DOT CY. CX(N): CY(N): Complex arrays of length N. INCX:(Integer) Spacing of elements of CX to use INCY:(Integer) Spacing of elements of CY to use. Output DCR:(Double Precision) Real part of dot product. DCI:(Double Precision) Imaginary part of dot product.
DCFOD
SUBROUTINE DCFOD(METH,ELCO,TESCO)
DCHDC
SUBROUTINE DCHDC(A,LDA,P,WORK,JPVT,JOB,INFO) DCHDC computes the Cholesky decomposition of a positive definite matrix. A pivoting option allows the user to estimate the condition of a positive definite matrix or determine the rank of a positive semidefinite matrix. On Entry A DOUBLE PRECISION(LDA,P). A contains the matrix whose decomposition is to be computed. Only the upper half of A need be stored. The lower part of the array A is not referenced. LDA INTEGER. LDA is the leading dimension of the array A. P INTEGER. P is the order of the matrix. WORK DOUBLE PRECISION. WORK is a work array. JPVT INTEGER(P). JPVT contains integers that control the selection of the pivot elements, if pivoting has been requested. Each diagonal element A(K,K) is placed in one of three classes according to the value of JPVT(K). If JPVT(K) .GT. 0, then X(K) is an initial element. If JPVT(K) .EQ. 0, then X(K) is a free element. If JPVT(K) .LT. 0, then X(K) is a final element. Before the decomposition is computed, initial elements are moved by symmetric row and column interchanges to the beginning of the array A and final elements to the end. Both initial and final elements are frozen in place during the computation and only free elements are moved. At the K-th stage of the reduction, if A(K,K) is occupied by a free element it is interchanged with the largest free element A(L,L) with L .GE. K. JPVT is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. If JOB .EQ. 0, no pivoting is done. If JOB .NE. 0, pivoting is done. On Return A A contains in its upper half the Cholesky factor of the matrix A as it has been permuted by pivoting. JPVT JPVT(J) contains the index of the diagonal element of a that was moved into the J-th position, provided pivoting was requested. INFO contains the index of the last positive diagonal element of the Cholesky factor. For positive definite matrices INFO = P is the normal return. For pivoting with positive semidefinite matrices INFO will in general be less than P. However, INFO may be greater than the rank of A, since rounding error can cause an otherwise zero element to be positive. Indefinite systems will always cause INFO to be less than P. LINPACK. This version dated 03/19/79 . J.Dongarra J. and Stewart G. W., Argonne National Laboratory and University of Maryland. BLAS DAXPY,DSWAP Fortran DSQRT
DCHDD
SUBROUTINE DCHDD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S,INFO) DCHDD downdates an augmented Cholesky decomposition or the triangular factor of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, DCHDD determines an orthogonal matrix U and a scalar ZETA such that (R Z ) (RR ZZ) U * ( ) = ( ) , (0 ZETA) ( X Y) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) removed. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the downdated problem is DSQRT(RHO**2 - ZETA**2). DCHDD will simultaneously downdate several triplets (Z,Y,RHO) along with R. For a less terse description of what DCHDD does and how it may be applied, see the LINPACK guide. The matrix U is determined as the product U(1)*...*U(P) where U(I) is a rotation in the (P+1,I)-plane of the form ( C(I) -S(I) ) ( ) . ( S(I) C(I) ) The rotations are chosen so that C(I) is double precision. The user is warned that a given downdating problem may be impossible to accomplish or may produce inaccurate results. For example, this can happen if X is near a vector whose removal will reduce the rank of R. Beware. On Entry R DOUBLE PRECISION(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be downdated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. X DOUBLE PRECISION(P). X contains the row vector that is to be removed from R. X is not altered by DCHDD. Z DOUBLE PRECISION(LDZ,N)Z), where LDZ .GE. P. Z is an array of NZ P-vectors which are to be downdated along with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be downdated NZ may be zero, in which case Z, Y, and RHO are not referenced. Y DOUBLE PRECISION(NZ). Y contains the scalars for the downdating of the vectors Z. Y is not altered by DCHDD. RHO DOUBLE PRECISION(NZ). RHO contains the norms of the residual vectors that are to be downdated. On Return R Z contain the downdated quantities. RHO C DOUBLE PRECISION(P). C contains the cosines of the transforming rotations. S DOUBLE PRECISION(P). S contains the sines of the transforming rotations. INFO INTEGER. INFO is set as follows. INFO = 0 if the entire downdating was successful. INFO =-1 if R could not be downdated. in this case, all quantities are left unaltered. INFO = 1 if some RHO could not be downdated. The offending RHO's are set to -1. LINPACK. This version dated 08/14/78 . Stewart, G. W., University of Maryland, Argonne National Lab. DCHDD uses the following functions and subprograms. Fortran DABS BLAS DDOT, DNRM2
DCHEX
SUBROUTINE DCHEX(R,LDR,P,K,L,Z,LDZ,NZ,C,S,JOB) DCHEX updates the Cholesky factorization A = TRANS(R)*R of a positive definite matrix A of order P under diagonal permutations of the form TRANS(E)*A*E where E is a permutation matrix. Specifically, given an upper triangular matrix R and a permutation matrix E (which is specified by K, L, and JOB), DCHEX determines an orthogonal matrix U such that U*R*E = RR, where RR is upper triangular. At the users option, the transformation U will be multiplied into the array Z. If A = TRANS(X)*X, so that R is the triangular part of the QR factorization of X, then RR is the triangular part of the QR factorization of X*E, i.e. X with its columns permuted. For a less terse description of what DCHEX does and how it may be applied, see the LINPACK guide. The matrix Q is determined as the product U(L-K)*...*U(1) of plane rotations of the form ( C(I) S(I) ) ( ) , ( -S(I) C(I) ) where C(I) is double precision. The rows these rotations operate on are described below. There are two types of permutations, which are determined by the value of JOB. 1. Right circular shift (JOB = 1). The columns are rearranged in the following order. 1,...,K-1,L,K,K+1,...,L-1,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (L-I,L-I+1)-plane. 2. Left circular shift (JOB = 2). The columns are rearranged in the following order 1,...,K-1,K+1,K+2,...,L,K,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (K+I-1,K+I)-plane. On Entry R DOUBLE PRECISION(LDR,P), where LDR .GE. P. R contains the upper triangular factor that is to be updated. Elements of R below the diagonal are not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. K INTEGER. K is the first column to be permuted. L INTEGER. L is the last column to be permuted. L must be strictly greater than K. Z DOUBLE PRECISION(LDZ,N)Z), where LDZ .GE. P. Z is an array of NZ P-vectors into which the transformation U is multiplied. Z is not referenced if NZ = 0. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of columns of the matrix Z. JOB INTEGER. JOB determines the type of permutation. JOB = 1 right circular shift. JOB = 2 left circular shift. On Return R contains the updated factor. Z contains the updated matrix Z. C DOUBLE PRECISION(P). C contains the cosines of the transforming rotations. S DOUBLE PRECISION(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. DCHEX uses the following functions and subroutines. BLAS DROTG Fortran MIN0
DCHUD
SUBROUTINE DCHUD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S) DCHUD updates an augmented Cholesky decomposition of the triangular part of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, DCHUD determines a untiary matrix U and a scalar ZETA such that (R Z) (RR ZZ ) U * ( ) = ( ) , (X Y) ( 0 ZETA) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) appended. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the updated problem is DSQRT(RHO**2 + ZETA**2). DCHUD will simultaneously update several triplets (Z,Y,RHO). For a less terse description of what DCHUD does and how it may be applied, see the LINPACK guide. The matrix U is determined as the product U(P)*...*U(1), where U(I) is a rotation in the (I,P+1) plane of the form ( C(I) S(I) ) ( ) . ( -S(I) C(I) ) The rotations are chosen so that C(I) is double precision. On Entry R DOUBLE PRECISION(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be updated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. X DOUBLE PRECISION(P). X contains the row to be added to R. X is not altered by DCHUD. Z DOUBLE PRECISION(LDZ,N)Z), where LDZ .GE. P. Z is an array containing NZ P-vectors to be updated with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be updated NZ may be zero, in which case Z, Y, and RHO are not referenced. Y DOUBLE PRECISION(NZ). Y contains the scalars for updating the vectors Z. Y is not altered by DCHUD. RHO DOUBLE PRECISION(NZ). RHO contains the norms of the residual vectors that are to be updated. If RHO(J) is negative, it is left unaltered. On Return RC RHO contain the updated quantities. Z C DOUBLE PRECISION(P). C contains the cosines of the transforming rotations. S DOUBLE PRECISION(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. DCHUD uses the following functions and subroutines. Extended BLAS DROTG Fortran DSQRT
DCOPY
SUBROUTINE DCOPY(N,DX,INCX,DY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DY copy of vector DX (unchanged if N .LE. 0) Copy double precision DX to double precision DY. For I = 0 to N-1, copy DX(LX+I*INCX) to DY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
DCOPYM
SUBROUTINE DCOPYM(N,DX,INCX,DY,INCY) Description of Parameters The * Flags Output Variables N Number of elements in vector(s) DX Double precision vector with N elements INCX Storage spacing between elements of DX DY* Double precision negative copy of DX INCY Storage spacing between elements of DY *** Note that DY = -DX *** Copy negative of d.p. DX to d.p. DY. For I=0 to N-1, copy -DX(LX+I*INCX) to DY(LY+I*INCY), where LX=1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
DDOT
DOUBLE PRECISION FUNCTION DDOT(N,DX,INCX,DY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DDOT double precision dot product (zero if N .LE. 0) Returns the dot product of double precision DX and DY. DDOT = sum for I = 0 to N-1 of DX(LX+I*INCX) * DY(LY+I*INCY) where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
DGBCO
SUBROUTINE DGBCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) DGBCO factors a double precision band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, DGBFA is slightly faster. To solve A*X = B , follow DGBCO by DGBSL. To compute INVERSE(A)*C , follow DGBCO by DGBSL. To compute DETERMINANT(A) , follow DGBCO by DGBDI. On Entry ABD DOUBLE PRECISION(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) M = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(N, J+ML) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABD should contain * * * + + + , * = not used * * 13 24 35 46 , + = used for pivoting * 12 23 34 45 56 11 22 33 44 55 66 21 32 43 54 65 * LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and functions used: LINPACK DGBFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,MAX0,MIN0,DSIGN
DGBDI
SUBROUTINE DGBDI(ABD,LDA,N,ML,MU,IPVT,DET) DGBDI computes the determinant of a band matrix using the factors computed by DGBCO or DGBFA. If the inverse is needed, use DGBSL N times. On Entry ABD DOUBLE PRECISION(LDA, N) the output from DGBCO or DGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from DGBCO or DGBFA. On Return DET DOUBLE PRECISION(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) = 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions Fortran DABS
DGBFA
SUBROUTINE DGBFA(ABD,LDA,N,ML,MU,IPVT,INFO) DGBFA factors a double precision band matrix by elimination. DGBFA is usually called by DGBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD DOUBLE PRECISION(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that DGBSL will divide by zero if called. Use RCOND in DGBCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) M = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(N, J+ML) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL,IDAMAX Fortran MAX0,MIN0
DGBSL
SUBROUTINE DGBSL(ABD,LDA,N,ML,MU,IPVT,B,JOB) DGBSL solves the double precision band system A * X = B or TRANS(A) * X = B using the factors computed by DGBCO or DGBFA. On Entry ABD DOUBLE PRECISION(LDA, N) the output from DGBCO or DGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from DGBCO or DGBFA. B DOUBLE PRECISION(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve TRANS(A)*X = B , where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if DGBCO has set RCOND .GT. 0.0 or DGBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DGBCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL DGBSL(ABD,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT Fortran MIN0
DGECO
SUBROUTINE DGECO(A,LDA,N,IPVT,RCOND,Z) DGECO factors a double precision matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, DGEFA is slightly faster. To solve A*X = B , follow DGECO by DGESL. To compute INVERSE(A)*C , follow DGECO by DGESL. To compute DETERMINANT(A) , follow DGECO by DGEDI. To compute INVERSE(A) , follow DGECO by DGEDI. On Entry A DOUBLE PRECISION(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an INTEGER vector of pivot indices. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DGEFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,DSIGN
DGEDI
SUBROUTINE DGEDI(A,LDA,N,IPVT,DET,WORK,JOB) DGEDI computes the determinant and inverse of a matrix using the factors computed by DGECO or DGEFA. On Entry A DOUBLE PRECISION(LDA, N) the output from DGECO or DGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from DGECO or DGEFA. WORK DOUBLE PRECISION(N) work vector. Contents destroyed. JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A inverse of original matrix if requested. Otherwise unchanged. DET DOUBLE PRECISION(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if DGECO has set RCOND .GT. 0.0 or DGEFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL,DSWAP Fortran DABS,MOD
DGEFA
SUBROUTINE DGEFA(A,LDA,N,IPVT,INFO) DGEFA factors a double precision matrix by Gaussian elimination. DGEFA is usually called by DGECO, but it can be called directly with a saving in time if RCOND is not needed. (Time for DGECO) = (1 + 9/N)*(Time for DGEFA) . On Entry A DOUBLE PRECISION(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that DGESL or DGEDI will divide by zero if called. Use RCOND in DGECO for a reliable indication of singularity. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL,IDAMAX
DGEFS
SUBROUTINE DGEFS(A,LDA,N,V,ITASK,IND,WORK,IWORK) Subroutine DGEFS solves a general NxN system of double precision linear equations using LINPACK subroutines DGECO and DGESL. That is, if A is an NxN double precision matrix and if X and B are double precision N-vectors, then DGEFS solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK.GT.1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by DGEFS in this case. Argument Description *** A DOUBLE PRECISION(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. on return, an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. The first N elements of the array A are the elements of the first column of the matrix A. N must be greater than or equal to 1. (terminal error message IND=-2) V DOUBLE PRECISION(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 see error message corresponding to IND below. WORK DOUBLE PRECISION(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
DGESL
SUBROUTINE DGESL(A,LDA,N,IPVT,B,JOB) DGESL solves the double precision system A * X = B or TRANS(A) * X = B using the factors computed by DGECO or DGEFA. On Entry A DOUBLE PRECISION(LDA, N) the output from DGECO or DGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from DGECO or DGEFA. B DOUBLE PRECISION(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve TRANS(A)*X = B where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if DGECO has set RCOND .GT. 0.0 or DGEFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DGECO(A,LDA,N,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL DGESL(A,LDA,N,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT
DGLSS
SUBROUTINE DGLSS(A,MDA,M,N,B,MDB,NB,RNORM,WORK,LW,IWORK,LIW,INFO) **** Double Precision version of SGLSS **** DGLSS solves both underdetermined and overdetermined LINEAR systems AX = B, where A is an M by N matrix and B is an M by NB matrix of right hand sides. If M.GE.N, the least squares solution is computed by decomposing the matrix A into the product of an orthogonal matrix Q and an upper triangular matrix R (QR factorization). If M.LT.N, the minimal length solution is computed by factoring the matrix A into the product of a lower triangular matrix L and an orthogonal matrix Q (LQ factor- ization). If the matrix A is determined to be rank deficient, that is the rank of A is less than MIN(M,N), then the minimal length least squares solution is computed. DGLSS assumes full machine precision in the data. If more control over the uncertainty in the data is desired, the codes DLLSIA and DULSIA are recommended. DGLSS requires MDA*N + (MDB + 1)*NB + 5*MIN(M,N) dimensioned real space and M+N dimensioned integer space. ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** SUBROUTINE DGLSS(A,MDA,M,N,B,MDB,NB,RNORM,WORK,LW,IWORK,LIW,INFO) Input..All TYPE REAL variables are DOUBLE PRECISION A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Must have MDB.GE.MAX(M,N). If NB = 0, B is never accessed. RNORM() Vector of length at least NB. On input the contents of RNORM are unused. WORK() A real work array dimensioned 5*MIN(M,N). LW Actual dimension of WORK. IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO A flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, INFO, LW, IWORK, LIW, and the first 2*MIN(M,N) locations of WORK as output by the original call to DGLSS. Output..All TYPE REAL variables are DOUBLE PRECISION A(,) Contains the triangular part of the reduced matrix and the transformation information. It together with the first 2*MIN(M,N) elements of WORK (see below) completely specify the factorization of A. B(,) Contains the N by NB solution matrix X. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. WORK() The first 2*MIN(M,N) locations of WORK contain value necessary to reproduce the factorization of A. IWORK() The first M+N locations contain the order in which the rows and columns of A were used. If M.GE.N columns then rows. If M.LT.N rows then columns. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Full rank N.GT.0 - Reduced rank rank=MIN(M,N)-INFO
DGTSL
SUBROUTINE DGTSL(N,C,D,E,B,INFO) DGTSL given a general tridiagonal matrix and a right hand side will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. C DOUBLE PRECISION(N) is the subdiagonal of the tridiagonal matrix. C(2) through C(N) should contain the subdiagonal. On output C is destroyed. D DOUBLE PRECISION(N) is the diagonal of the tridiagonal matrix. On output D is destroyed. E DOUBLE PRECISION(N) is the superdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the superdiagonal. On output E is destroyed. B DOUBLE PRECISION(N) is the right hand side vector. On Return B is the solution vector. INFO INTEGER = 0 normal value. = K if the K-th element of the diagonal becomes exactly zero. The subroutine returns when this is detected. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No externals Fortran DABS
DH12
SUBROUTINE DH12(MODE,LPIVOT,L1,M,U,IUE,UP,C,ICE,ICV,NCV) *** DOUBLE PRECISION VERSION OF H12 ****** SUBROUTINE DH12 (MODE,LPIVOT,L1,M,U,IUE,UP,C,ICE,ICV,NCV) C.L.Lawson and R.J.Hanson, Jet Propulsion Laboratory, 1973 Jun 12 to appear in 'Solving Least Squares Problems', Prentice-Hall, 1974 Modified at SANDIA LABS, May 1977, to -- 1) Remove double precision accumulation, and 2) Include usage of the Basic Linear Algebra Package for vectors longer than a particular threshold. Construction and/or application of a single Householder transformation.. Q = I + U*(U**T)/B MODE = 1 or 2 to select algorithm H1 or H2 . LPIVOT is the index of the pivot element. L1,M If L1 .LE. M the transformation will be constructed to zero elements indexed from L1 through M. If L1 GT. M THE SUBROUTINE DOES AN IDENTITY TRANSFORMATION. U(),IUE,UP On entry to H1 U() contains the pivot vector. IUE is the storage increment between elements. On exit from H1 U() and UP contain quantities defining the vector U of the Householder transformation. On entry to H2 U() and UP should contain quantities previously computed by H1. These will not be modified by H2. C() On entry to H1 or H2 C() contains a matrix which will be regarded as a set of vectors to which the Householder transformation is to be applied. On exit C() contains the set of transformed vectors. ICE Storage increment between elements of vectors in C(). ICV Storage increment between vectors in C(). NCV Number of vectors in C() to be transformed. If NCV .LE. 0 no operations will be done on C().
DHFTI
SUBROUTINE DHFTI(A,MDA,M,N,B,MDB,NB,TAU,KRANK,RNORM,H,G,IP) ***** Double Precision version of HFTI ***** DIMENSION A(MDA,N),(B(MDB,NB) or B(M)),RNORM(NB),H(N),G(N),IP(N) This subroutine solves a linear least squares problem or a set of linear least squares problems having the same matrix but different right-side vectors. The problem data consists of an M by N matrix A, an M by NB matrix B, and an absolute tolerance parameter TAU whose usage is described below. The NB column vectors of B represent right-side vectors for NB distinct linear least squares problems. This set of problems can also be written as the matrix least squares problem AX = B, where X is the N by NB solution matrix. Note that if B is the M by M identity matrix, then X will be the pseudo-inverse of A. This subroutine first transforms the augmented matrix (A B) to a matrix (R C) using premultiplying Householder transformations with column interchanges. All subdiagonal elements in the matrix R are zero and its diagonal elements satisfy DABS(R(I,I)).GE.DABS(R(I+1,I+1)), I = 1,...,L-1, where L = MIN(M,N). The subroutine will compute an integer, KRANK, equal to the number of diagonal terms of R that exceed TAU in magnitude. Then a solution of minimum Euclidean length is computed using the first KRANK rows of (R C). To be specific we suggest that the user consider an easily computable matrix norm, such as, the maximum of all column sums of magnitudes. Now if the relative uncertainty of B is EPS, (norm of uncertainty/ norm of B), it is suggested that TAU be set approximately equal to EPS*(norm of A). The user must dimension all arrays appearing in the call list.. A(MDA,N),(B(MDB,NB) or B(M)),RNORM(NB),H(N),G(N),IP(N). This permits the solution of a range of problems in the same array space. The entire set of parameters for DHFTI are INPUT.. All TYPE REAL variables are DOUBLE PRECISION A(*,*),MDA,M,N The array A(*,*) initially contains the M by N matrix A of the least squares problem AX = B. The first dimensioning parameter of the array A(*,*) is MDA, which must satisfy MDA.GE.M Either M.GE.N or M.LT.N is permitted. There is no restriction on the rank of A. The condition MDA.LT.M is considered an error. B(*),MDB,NB If NB = 0 the subroutine will perform the orthogonal decomposition but will make no references to the array B(*). If NB.GT.0 the array B(*) must initially contain the M by NB matrix B of the least squares problem AX = B. If NB.GE.2 the array B(*) must be doubly subscripted with first dimensioning parameter MDB.GE.MAX(M,N). If NB = 1 the array B(*) may be either doubly or singly subscripted. In the latter case the value of MDB is arbitrary but it should be set to some valid integer value such as MDB = M. The condition of NB.GT.1.AND.MDB.LT. MAX(M,N) is considered an error. TAU Absolute tolerance parameter provided by user for pseudorank determination. H(*),G(*),IP(*) Arrays of working space used by DHFTI. OUTPUT.. All TYPE REAL variables are DOUBLE PRECISION A(*,*) The contents of the array A(*,*) will be modified by the subroutine. These contents are not generally required by the user. B(*) On return the array B(*) will contain the N by NB solution matrix X. KRANK Set by the subroutine to indicate the pseudorank of A. RNORM(*) On return, RNORM(J) will contain the Euclidean norm of the residual vector for the problem defined by the J-th column vector of the array B(*,*) for J = 1,...,NB. H(*),G(*) On return these arrays respectively contain elements of the pre- and post-multiplying Householder transformations used to compute the minimum Euclidean length solution. IP(*) Array in which the subroutine records indices describing the permutation of column vectors. The contents of arrays H(*),G(*) and IP(*) are not generally required by the user.
DHKSEQ
SUBROUTINE DHKSEQ(X,M,H,IERR) DHKSEQ is an adaptation of subroutine DPSIFN, ACM Trans. Math. Software, 1983 to generate H(K,X)=(-X)**(K+1)*(PSI(K,X)- -PSI(K,X+0.5))/GAMMA(K+1) for K=0,...,M.
DHSTRT
SUBROUTINE DHSTRT(DF,NEQ,A,B,Y,YPRIME,ETOL,MORDER,SMALL,BIG,SPY,
DIFF
FUNCTION DIFF(X,Y)
DLLSIA
SUBROUTINE DLLSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP,KRANK, **** Double Precision version of LLSIA **** DLLSIA computes the least squares solution(s) to the problem AX=B where A is an M by N matrix with M.GE.N and B is the M by NB matrix of right hand sides. User input bounds on the uncertainty in the elements of A are used to detect numerical rank deficiency. The algorithm employs a row and column pivot strategy to minimize the growth of uncertainty and round-off errors. DLLSIA requires (MDA+6)*N + (MDB+1)*NB + M dimensioned space ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** SUBROUTINE DLLSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP, 1 KRANK,KSURE,RNORM,W,LW,IWORK,LIW,INFO) Input..All TYPE REAL variables are DOUBLE PRECISION A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). Must have MDA.GE.M and M.GE.N. B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Must have MDB.GE.M. If NB = 0, B is never accessed. ****************************************************************** * * * Note - Use of RE and AE are what make this * * code significantly different from * * other linear least squares solvers. * * However, the inexperienced user is * * advised to set RE=0.,AE=0.,KEY=0. * * * ****************************************************************** RE(),AE(),KEY RE() RE() is a vector of length N such that RE(I) is the maximum relative uncertainty in column I of the matrix A. The values of RE() must be between 0 and 1. A minimum of 10*machine precision will be enforced. AE() AE() is a vector of length N such that AE(I) is the maximum absolute uncertainty in column I of the matrix A. The values of AE() must be greater than or equal to 0. KEY For ease of use, RE and AE may be input as either vectors or scalars. If a scalar is input, the algo- rithm will use that value for each column of A. The parameter key indicates whether scalars or vectors are being input. KEY=0 RE scalar AE scalar KEY=1 RE vector AE scalar KEY=2 RE scalar AE vector KEY=3 RE vector AE vector MODE The integer mode indicates how the routine is to react if rank deficiency is detected. If MODE = 0 return immediately, no solution 1 compute truncated solution 2 compute minimal length solution The inexperienced user is advised to set MODE=0 NP The first NP columns of A will not be interchanged with other columns even though the pivot strategy would suggest otherwise. The inexperienced user is advised to set NP=0. WORK() A real work array dimensioned 5*N. However,if RE or AE have been specified as vectors, dimension WORK 4*N. If both RE and AE have been specified as vectors, dimension WORK 3*N. LW Actual dimension of WORK IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO Is a flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, KRANK, LW, IWORK, LIW, and the first 2*N locations of WORK as output by the original call to DLLSIA. MODE must be equal to the value of MODE in the original call. If MODE.LT.2, only the first N locations of WORK are accessed. AE, RE, KEY, and NP are not accessed. Output..All TYPE REAL variable are DOUBLE PRECISION A(,) Contains the upper triangular part of the reduced matrix and the transformation information. It togeth with the first N elements of WORK (see below) completely specify the QR factorization of A. B(,) Contains the N by NB solution matrix for X. KRANK,KSURE The numerical rank of A, based upon the relative and absolute bounds on uncertainty, is bounded above by KRANK and below by KSURE. The algorithm returns a solution based on KRANK. KSURE provides an indication of the precision of the rank. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. WORK() The first N locations of WORK contain values necessary to reproduce the Householder transformatio IWORK() The first N locations contain the order in which the columns of A were used. The next M locations contain the order in which the rows of A were used. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Rank deficient, no solution 1 - Rank deficient, truncated solution 2 - Rank deficient, minimal length solution 3 - Numerical rank 0, zero solution 4 - Rank .LT. NP 5 - Full rank
DNBCO
SUBROUTINE DNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) DNBCO factors a double precision band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, DNBFA is slightly faster. To solve A*X = B , follow DNBCO by DNBSL. To compute INVERSE(A)*C , follow DNBCO by DNBSL. To compute DETERMINANT(A) , follow DNBCO by DNBDI. On Entry ABE DOUBLE PRECISION(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 07/28/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions SLATEC DNBFA DDOT,DAXPY,DSCAL,DASUM Fortran DABS,DMAX1,MAX0,MIN0,DSIGN
DNBDI
SUBROUTINE DNBDI(ABE,LDA,N,ML,MU,IPVT,DET) DNBDI computes the determinant of a band matrix using the factors computed by DNBCO or DNBFA. If the inverse is needed, use DNBSL N times. On Entry ABE DOUBLE PRECISION(LDA, NC) the output from DNBCO or DNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from DNBCO or DNBFA. On Return DET DOUBLE PRECISION(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) = 0.0 . SLATEC. This version dated 07/28/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions Fortran DABS
DNBFA
SUBROUTINE DNBFA(ABE,LDA,N,ML,MU,IPVT,INFO) DNBFA factors a double precision band matrix by elimination. DNBFA is usually called by DNBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABE DOUBLE PRECISION(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER =0 normal value =K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that DNBSL will divide by zero if called. Use RCOND in DNBCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 07/28/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions IDAMAX,DAXPY,DSCAL,DSWAP Fortran MIN0
DNBFS
SUBROUTINE DNBFS(ABE,LDA,N,ML,MU,V,ITASK,IND,WORK,IWORK) Subroutine DNBFS solves a general nonsymmetric banded NxN system of double precision real linear equations using SLATEC subroutines DNBCO and DNBSL. These are adaptations of the LINPACK subroutines DGBCO and DGBSL which require a different format for storing the matrix elements. If A is an NxN double precision matrix and if X and B are double precision N-vectors, then DNBFS solves the equation A*X=B. A band matrix is a matrix whose nonzero elements are all fairly near the main diagonal, specifically A(I,J) = 0 if I-J is greater than ML or J-I is greater than MU . The integers ML and MU are called the lower and upper band widths and M = ML+MU+1 is the total band width. DNBFS uses less time and storage than the corresponding program for general matrices (DGEFS) if 2*ML+MU .LT. N . The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by DNBFS in this case. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + Argument Description *** ABE DOUBLE PRECISION(LDA,NC) on entry, contains the matrix in band storage as described above. NC must not be less than 2*ML+MU+1 . The user is cautioned to specify NC with care since it is not an argument and cannot be checked by DNBFS. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE . on return, contains an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of array ABE. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1 . (terminal error message IND=-2) ML INTEGER the number of diagonals below the main diagonal. ML must not be less than zero nor greater than or equal to N . (terminal error message IND=-5) MU INTEGER the number of diagonals above the main diagonal. MU must not be less than zero nor greater than or equal to N . (terminal error message IND=-6) V DOUBLE PRECISION(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 See error message corresponding to IND below. WORK DOUBLE PRECISION(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-5 terminal ML is less than zero or is greater than or equal to N . IND=-6 terminal MU is less than zero or is greater than or equal to N . IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
DNBSL
SUBROUTINE DNBSL(ABE,LDA,N,ML,MU,IPVT,B,JOB) DNBSL solves the double precision band system A * X = B or TRANS(A) * X = B using the factors computed by DNBCO or DNBFA. On Entry ABE DOUBLE PRECISION(LDA, NC) the output from DNBCO or DNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from DNBCO or DNBFA. B DOUBLE PRECISION(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B . = nonzero to solve TRANS(A)*X = B , where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity but it is often caused by improper arguments or improper setting of LDA. It will not occur if the subroutines are called correctly and if DNBCO has set RCOND .GT. 0.0 or DNBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL DNBSL(ABE,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE SLATEC. This version dated 07/28/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions DAXPY,DDOT Fortran MIN0
DNRM2
DOUBLE PRECISION FUNCTION DNRM2(N,DX,INCX) B L A S Subprogram Description of parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX --Output-- DNRM2 double precision result (zero if N .LE. 0) Euclidean norm of the N-vector stored in DX() with storage increment INCX . If N .LE. 0 return with result = 0. If N .GE. 1 then INCX must be .GE. 1 C.L. Lawson, 1978 Jan 08 Four phase method using two built-in constants that are hopefully applicable to all machines. CUTLO = maximum of DSQRT(U/EPS) over all known machines. CUTHI = minimum of DSQRT(V) over all known machines. where EPS = smallest no. such that EPS + 1. .GT. 1. U = smallest positive no. (underflow limit) V = largest no. (overflow limit) Brief outline of algorithm.. Phase 1 scans zero components. move to phase 2 when a component is nonzero and .LE. CUTLO move to phase 3 when a component is .GT. CUTLO move to phase 4 when a component is .GE. CUTHI/M where M = N for X() real and M = 2*N for complex. Values for CUTLO and CUTHI.. From the environmental parameters listed in the IMSL converter document the limiting values are as followS.. CUTLO, S.P. U/EPS = 2**(-102) for Honeywell. Close seconds are Univac and DEC at 2**(-103) Thus CUTLO = 2**(-51) = 4.44089E-16 CUTHI, S.P. V = 2**127 for Univac, Honeywell, and DEC. Thus CUTHI = 2**(63.5) = 1.30438E19 CUTLO, D.P. U/EPS = 2**(-67) for Honeywell and DEC. Thus CUTLO = 2**(-33.5) = 8.23181D-11 CUTHI, D.P. same as S.P. CUTHI = 1.30438D19 SAVE CUTLO, CUTHI, ZERO, ONE DATA CUTLO, CUTHI / 8.232D-11, 1.304D19 / DATA CUTLO, CUTHI / 4.441E-16, 1.304E19 /
DPBCO
SUBROUTINE DPBCO(ABD,LDA,N,M,RCOND,Z,INFO) DPBCO factors a double precision symmetric positive definite matrix stored in band form and estimates the condition of the matrix. If RCOND is not needed, DPBFA is slightly faster. To solve A*X = B , follow DPBCO by DPBSL. To compute INVERSE(A)*C , follow DPBCO by DPBSL. To compute DETERMINANT(A) , follow DPBCO by DPBDI. On Entry ABD DOUBLE PRECISION(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = TRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Band Storage If A is a symmetric positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses M + 1 rows of A , except for the M by M upper left triangle, which is ignored. Example: If the original matrix is 11 12 13 0 0 0 12 22 23 24 0 0 13 23 33 34 35 0 0 24 34 44 45 46 0 0 35 45 55 56 0 0 0 46 56 66 then N = 6 , M = 2 and ABD should contain * * 13 24 35 46 * 12 23 34 45 56 11 22 33 44 55 66 LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DPBFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,MAX0,MIN0,DREAL,DSIGN
DPBDI
SUBROUTINE DPBDI(ABD,LDA,N,M,DET) DPBDI computes the determinant of a double precision symmetric positive definite band matrix using the factors computed by DPBCO or DPBFA. If the inverse is needed, use DPBSL N times. On Entry ABD DOUBLE PRECISION(LDA, N) the output from DPBCO or DPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. On Return DET DOUBLE PRECISION(2) determinant of original matrix in the form DETERMINANT = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab.
DPBFA
SUBROUTINE DPBFA(ABD,LDA,N,M,INFO) DPBFA factors a double precision symmetric positive definite matrix stored in band form. DPBFA is usually called by DPBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD DOUBLE PRECISION(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = TRANS(R)*R . INFO INTEGER = 0 for normal return. = K if the leading minor of order K is not positive definite. Band Storage If A is a symmetric positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DDOT Fortran MAX0,DSQRT
DPBSL
SUBROUTINE DPBSL(ABD,LDA,N,M,B) DPBSL solves the double precision symmetric positive definite band system A*X = B using the factors computed by DPBCO or DPBFA. On Entry ABD DOUBLE PRECISION(LDA, N) the output from DPBCO or DPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. B DOUBLE PRECISION(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly, and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DPBCO(ABD,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL DPBSL(ABD,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT Fortran MIN0
DPCHCE
SUBROUTINE DPCHCE(IC,VC,N,X,H,SLOPE,D,INCFD,IERR) DPCHCE: DPCHIC End Derivative Setter. Called by DPCHIC to set end derivatives as requested by the user. It must be called after interior derivative values have been set. ----- To facilitate two-dimensional applications, includes an increment between successive values of the D-array.
Calling sequence: PARAMETER (INCFD = ...) INTEGER IC(2), N, IERR DOUBLE PRECISION VC(2), X(N), H(N), SLOPE(N), D(INCFD,N) CALL DPCHCE (IC, VC, N, X, H, SLOPE, D, INCFD, IERR) Parameters: IC -- (input) integer array of length 2 specifying desired boundary conditions: IC(1) = IBEG, desired condition at beginning of data. IC(2) = IEND, desired condition at end of data. ( see prologue to DPCHIC for details. ) VC -- (input) real*8 array of length 2 specifying desired boundary values. VC(1) need be set only if IC(1) = 2 or 3 . VC(2) need be set only if IC(2) = 2 or 3 . N -- (input) number of data points. (assumes N.GE.2) X -- (input) real*8 array of independent variable values. (the elements of X are assumed to be strictly increasing.) H -- (input) real*8 array of interval lengths. SLOPE -- (input) real*8 array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (input) real*8 array of derivative values at the data points. The value corresponding to X(I) must be stored in D(1+(I-1)*INCFD), I=1(1)N. (output) the value of D at X(1) and/or X(N) is changed, if necessary, to produce the requested boundary conditions. no other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. IERR -- (output) error flag. Normal return: IERR = 0 (no errors). Warning errors: IERR = 1 if IBEG.LT.0 and D(1) had to be adjusted for monotonicity. IERR = 2 if IEND.LT.0 and D(1+(N-1)*INCFD) had to be adjusted for monotonicity. IERR = 3 if both of the above are true. ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: DABS, IABS.DPCHCI
SUBROUTINE DPCHCI(N,H,SLOPE,D,INCFD) DPCHCI: DPCHIC Initial Derivative Setter. Called by DPCHIC to set derivatives needed to determine a monotone piecewise cubic Hermite interpolant to the data. Default boundary conditions are provided which are compatible with monotonicity. If the data are only piecewise monotonic, the interpolant will have an extremum at each point where monotonicity switches direction. To facilitate two-dimensional applications, includes an increment between successive values of the D-array. The resulting piecewise cubic Hermite function should be identical (within roundoff error) to that produced by DPCHIM.
Calling sequence: PARAMETER (INCFD = ...) INTEGER N DOUBLE PRECISION H(N), SLOPE(N), D(INCFD,N) CALL DPCHCI (N, H, SLOPE, D, INCFD) Parameters: N -- (input) number of data points. If N=2, simply does linear interpolation. H -- (input) real*8 array of interval lengths. SLOPE -- (input) real*8 array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (output) real*8 array of derivative values at data points. If the data are monotonic, these values will determine a a monotone cubic Hermite function. The value corresponding to X(I) is stored in D(1+(I-1)*INCFD), I=1(1)N. No other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: DABS, DMAX1, DMIN1.DPCHCS
SUBROUTINE DPCHCS(SWITCH,N,H,SLOPE,D,INCFD,IERR) DPCHCS: DPCHIC Monotonicity Switch Derivative Setter. Called by DPCHIC to adjust the values of D in the vicinity of a switch in direction of monotonicity, to produce a more "visually pleasing" curve than that given by DPCHIM .
Calling sequence: PARAMETER (INCFD = ...) INTEGER N, IERR DOUBLE PRECISION SWITCH, H(N), SLOPE(N), D(INCFD,N) CALL DPCHCS (SWITCH, N, H, SLOPE, D, INCFD, IERR) Parameters: SWITCH -- (input) indicates the amount of control desired over local excursions from data. N -- (input) number of data points. (assumes N.GT.2 .) H -- (input) real*8 array of interval lengths. SLOPE -- (input) real*8 array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (input) real*8 array of derivative values at the data points, as determined by DPCHCI. (output) derivatives in the vicinity of switches in direction of monotonicity may be adjusted to produce a more "visually pleasing" curve. The value corresponding to X(I) is stored in D(1+(I-1)*INCFD), I=1(1)N. No other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. IERR -- (output) error flag. should be zero. If negative, trouble in DPCHSW. (should never happen.) ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: DABS, DMAX1, DMIN1.DPCHDF
DOUBLE PRECISION FUNCTION DPCHDF(K,X,S,IERR) DPCHDF: DPCHIP Finite Difference Formula Uses a divided difference formulation to compute a K-point approx- imation to the derivative at X(K) based on the data in X and S. Called by DPCHCE and DPCHSP to compute 3- and 4-point boundary derivative approximations.
On input: K is the order of the desired derivative approximation. K must be at least 3 (error return if not). X contains the K values of the independent variable. X need not be ordered, but the values **MUST** be distinct. (Not checked here.) S contains the associated slope values: S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1. (Note that S need only be of length K-1.) On return: S will be destroyed. IERR will be set to -1 if K.LT.2 . DPCHDF will be set to the desired derivative approximation if IERR=0 or to zero if IERR=-1.
Reference: Carl de Boor, A Practical Guide to Splines, Springer- Verlag (New York, 1978), pp. 10-16.DPOCO
SUBROUTINE DPOCO(A,LDA,N,RCOND,Z,INFO) DPOCO factors a double precision symmetric positive definite matrix and estimates the condition of the matrix. If RCOND is not needed, DPOFA is slightly faster. To solve A*X = B , follow DPOCO by DPOSL. To compute INVERSE(A)*C , follow DPOCO by DPOSL. To compute DETERMINANT(A) , follow DPOCO by DPODI. To compute INVERSE(A) , follow DPOCO by DPODI. On Entry A DOUBLE PRECISION(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = TRANS(R)*R where TRANS(R) is the transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DPOFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,DREAL,DSIGN
DPODI
SUBROUTINE DPODI(A,LDA,N,DET,JOB) DPODI computes the determinant and inverse of a certain double precision symmetric positive definite matrix (see below) using the factors computed by DPOCO, DPOFA or DQRDC. On Entry A DOUBLE PRECISION(LDA, N) the output A from DPOCO or DPOFA or the output X from DQRDC. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A If DPOCO or DPOFA was used to factor A , then DPODI produces the upper half of INVERSE(A) . If DQRDC was used to decompose X , then DPODI produces the upper half of inverse(TRANS(X)*X) where TRANS(X) is the transpose. Elements of A below the diagonal are unchanged. If the units digit of JOB is zero, A is unchanged. DET DOUBLE PRECISION(2) determinant of A or of TRANS(X)*X if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if DPOCO or DPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL Fortran MOD
DPOFA
SUBROUTINE DPOFA(A,LDA,N,INFO) DPOFA factors a double precision symmetric positive definite matrix. DPOFA is usually called by DPOCO, but it can be called directly with a saving in time if RCOND is not needed. (time for DPOCO) = (1 + 18/N)*(time for DPOFA) . On Entry A DOUBLE PRECISION(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = TRANS(R)*R where TRANS(R) is the transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DDOT Fortran DSQRT
DPOFS
SUBROUTINE DPOFS(A,LDA,N,V,ITASK,IND,WORK) Subroutine DPOFS solves a positive definite symmetric NxN system of double precision linear equations using LINPACK subroutines DPOCO and DPOSL. That is, if A is an NxN double precision positive definite symmetric matrix and if X and B are double precision N-vectors, then DPOFS solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices R and R-TRANPOSE. These factors are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option only to solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, and N must not have been altered by the user following factorization (ITASK=1). IND will not be changed by DPOFS in this case. Argument Description *** A DOUBLE PRECISION(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. Only the upper triangle, including the diagonal, of the coefficient matrix need be entered and will subse- quently be referenced and changed by the routine. on return, A contains in its upper triangle an upper triangular matrix R such that A = (R-TRANPOSE) * R . LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1. (terminal error message IND=-2) V DOUBLE PRECISION(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK = 1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 See error message corresponding to IND below. WORK DOUBLE PRECISION(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 Terminal N is greater than LDA. IND=-2 Terminal N is less than 1. IND=-3 Terminal ITASK is less than 1. IND=-4 Terminal The matrix A is computationally singular or is not positive definite. A solution has not been computed. IND=-10 Warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above Terminal(*fatal*) Error Messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
DPOLCF
SUBROUTINE DPOLCF(XX,N,X,C,D,WORK) **** Double Precision version of POLCOF **** Written by Robert E. Huddleston, Sandia Laboratories, Livermore Abstract Subroutine DPOLCF computes the coefficients of the polynomial fit (including Hermite polynomial fits ) produced by a previous call to HRMITE or DPLINT. The coefficients of the polynomial, expanded about XX, are stored in the array D. The expansion is of the form P(Z) = D(1) + D(2)*(Z-XX) +D(3)*((Z-XX)**2) + ... + D(N)*((Z-XX)**(N-1)). Between the call to DPLINT (or to HRMITE) and the call to DPOLCF the variable N and the arrays X and C must not be altered. ***** INPUT PARAMETERS *** All TYPE REAL variables are DOUBLE PRECISION *** XX - The point about which the Taylor expansion is to be made. N - **** * N, X, and C must remain unchanged between the X - * call to DPLINT or the call to HRMITE and the * call to DPOLCF. C - **** ***** OUTPUT PARAMETER *** All TYPE REAL variables are DOUBLE PRECISION *** D - The array of coefficients for the Taylor expansion as explained in the abstract ***** STORAGE PARAMETER WORK - This is an array to provide internal working storage. It must be dimensioned by at least 2*N in the calling program. **** Note - There are two methods for evaluating the fit produced by DPLINT or HRMITE. You may call DPOLVL to perform the task, or you may call DPOLCF to obtain the coefficients of the Taylor expansion and then write your own evaluation scheme. Due to the inherent errors in the computations of the Taylor expansion from the Newton coefficients produced by DPLINT or HRMITE, much more accuracy may be expected by calling DPOLVL as opposed to writing your own scheme.
DPOSL
SUBROUTINE DPOSL(A,LDA,N,B) DPOSL solves the double precision symmetric positive definite system A * X = B using the factors computed by DPOCO or DPOFA. On Entry A DOUBLE PRECISION(LDA, N) the output from DPOCO or DPOFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . B DOUBLE PRECISION(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DPOCO(A,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL DPOSL(A,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT
DPPCO
SUBROUTINE DPPCO(AP,N,RCOND,Z,INFO) DPPCO factors a double precision symmetric positive definite matrix stored in packed form and estimates the condition of the matrix. If RCOND is not needed, DPPFA is slightly faster. To solve A*X = B , follow DPPCO by DPPSL. To compute INVERSE(A)*C , follow DPPCO by DPPSL. To compute DETERMINANT(A) , follow DPPCO by DPPDI. To compute INVERSE(A) , follow DPPCO by DPPDI. On Entry AP DOUBLE PRECISION (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = TRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DPPFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,DREAL,DSIGN
DPPDI
SUBROUTINE DPPDI(AP,N,DET,JOB) DPPDI computes the determinant and inverse of a double precision symmetric positive definite matrix using the factors computed by DPPCO or DPPFA . On Entry AP DOUBLE PRECISION (N*(N+1)/2) the output from DPPCO or DPPFA. N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return AP the upper triangular half of the inverse . The strict lower triangle is unaltered. DET DOUBLE PRECISION(2) determinant of original matrix if requested. Otherwise not referenced. DETERMINANT = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if DPOCO or DPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL Fortran MOD
DPPFA
SUBROUTINE DPPFA(AP,N,INFO) DPPFA factors a double precision symmetric positive definite matrix stored in packed form. DPPFA is usually called by DPPCO, but it can be called directly with a saving in time if RCOND is not needed. (time for DPPCO) = (1 + 18/N)*(time for DPPFA) . On Entry AP DOUBLE PRECISION (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = TRANS(R)*R . INFO INTEGER = 0 for normal return. = K if the leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DDOT Fortran DSQRT
DPPGQ8
SUBROUTINE DPPGQ8(FUN,LDC,C,XI,LXI,KK,ID,A,B,INPPV,ERR,ANS,IERR)
DPPSL
SUBROUTINE DPPSL(AP,N,B) DPPSL solves the double precision symmetric positive definite system A * X = B using the factors computed by DPPCO or DPPFA. On Entry AP DOUBLE PRECISION (N*(N+1)/2) the output from DPPCO or DPPFA. N INTEGER the order of the matrix A . B DOUBLE PRECISION(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DPPCO(AP,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL DPPSL(AP,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT
DPTSL
SUBROUTINE DPTSL(N,D,E,B) DPTSL, given a positive definite symmetric tridiagonal matrix and a right hand side, will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. D DOUBLE PRECISION(N) is the diagonal of the tridiagonal matrix. On output D is destroyed. E DOUBLE PRECISION(N) is the offdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the offdiagonal. B DOUBLE PRECISION(N) is the right hand side vector. On Return B contains the solution. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No externals Fortran MOD
DQDOTA
DOUBLE PRECISION FUNCTION DQDOTA(N,DB,QC,DX,INCX,DY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(S) DB double precision scalar to be added to inner product QC extended precision scalar to be added to inner product DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DQDOTA double precision result QC extended precision result D.P. dot product with extended precision accumulation (and result) QC and DQDOTA are set = DB + QC + sum for I = 0 to N-1 of DX(LX+I*INCX) * DY(LY+I*INCY), where QC is an extended precision result previously computed by DQDOTI or DQDOTA and LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY. The MP package by Richard P. Brent is used for the extended precision arithmetic. Fred T. Krogh, JPL, 1977, June 1 The common block for the MP package is name MPCOM. If local variable I1 is zero, DQDOTA calls MPBLAS to initialize the MP package and reset I1 to 1.
DQDOTI
DOUBLE PRECISION FUNCTION DQDOTI(N,DB,QC,DX,INCX,DY,INCY) B L A S Subprogram Description of parameters --Input-- N number of elements in input vector(s) DB double precision scalar to be added to inner product QC extended precision scalar to be added DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DQDOTI double precision result QC extended precision result D.P. dot product with extended precision accumulation (and result) QC and DQDOTI are set = DB + sum for I = 0 to N-1 of DX(LX+I*INCX) * DY(LY+I*INCY), where QC is an extended precision result which can be used as input to DQDOTA, and LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY. The MP package by Richard P. Brent is used for the extended precision arithmetic. Fred T. Krogh, JPL, 1977, June 1 The common block for the MP package is named MPCOM. If local variable I1 is zero, DQDOTI calls MPBLAS to initialize the MP package and reset I1 to 1.
DQELG
SUBROUTINE DQELG(N,EPSTAB,RESULT,ABSERR,RES3LA,NRES) Epsilon algorithm Standard fortran subroutine Double precision version PARAMETERS N - Integer EPSTAB(N) contains the new element in the first column of the epsilon table. EPSTAB - Double precision Vector of dimension 52 containing the elements of the two lower diagonals of the triangular epsilon table. The elements are numbered starting at the right-hand corner of the triangle. RESULT - Double precision Resulting approximation to the integral ABSERR - Double precision Estimate of the absolute error computed from RESULT and the 3 previous results RES3LA - Double precision Vector of dimension 3 containing the last 3 results NRES - Integer Number of calls to the routine (should be zero at first call)
DQFORM
SUBROUTINE DQFORM(M,N,Q,LDQ,WA)
DQRDC
SUBROUTINE DQRDC(X,LDX,N,P,QRAUX,JPVT,WORK,JOB) DQRDC uses Householder transformations to compute the QR factorization of an N by P matrix X. Column pivoting based on the 2-norms of the reduced columns may be performed at the user's option. On Entry X DOUBLE PRECISION(LDX,P), where LDX .GE. N. X contains the matrix whose decomposition is to be computed. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of rows of the matrix X. P INTEGER. P is the number of columns of the matrix X. JPVT INTEGER(P). JPVT contains integers that control the selection of the pivot columns. The K-th column X(K) of X is placed in one of three classes according to the value of JPVT(K). If JPVT(K) .GT. 0, then X(K) is an initial column. If JPVT(K) .EQ. 0, then X(K) is a free column. If JPVT(K) .LT. 0, then X(K) is a final column. Before the decomposition is computed, initial columns are moved to the beginning of the array X and final columns to the end. Both initial and final columns are frozen in place during the computation and only free columns are moved. At the K-th stage of the reduction, if X(K) is occupied by a free column it is interchanged with the free column of largest reduced norm. JPVT is not referenced if JOB .EQ. 0. WORK DOUBLE PRECISION(P). WORK is a work array. WORK is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. If JOB .EQ. 0, no pivoting is done. If JOB .NE. 0, pivoting is done. On Return X X contains in its upper triangle the upper triangular matrix R of the QR factorization. Below its diagonal X contains information from which the orthogonal part of the decomposition can be recovered. Note that if pivoting has been requested, the decomposition is not that of the original matrix X but that of X with its columns permuted as described by JPVT. QRAUX DOUBLE PRECISION(P). QRAUX contains further information required to recover the orthogonal part of the decomposition. JPVT JPVT(K) contains the index of the column of the original matrix that has been interchanged into the K-th column, if pivoting was requested. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. DQRDC uses the following functions and subprograms. BLAS DAXPY,DDOT,DSCAL,DSWAP,DNRM2 Fortran DABS,DMAX1,MIN0,DSQRT
DQRFAC
SUBROUTINE DQRFAC(M,N,A,LDA,PIVOT,IPVT,LIPVT,SIGMA,ACNORM,WA) **** Double Precision version of QRFAC **** ********** Subroutine DQRFAC This subroutine uses Householder transformations with column pivoting (optional) to compute a QR factorization of the M by N matrix A. That is, DQRFAC determines an orthogonal matrix Q, a permutation matrix P, and an upper trapezoidal matrix R with diagonal elements of nonincreasing magnitude, such that A*P = Q*R. The Householder transformation for column K, K = 1,2,...,MIN(M,N), is of the form T I - (1/U(K))*U*U where U has zeros in the first K-1 positions. The form of this transformation and the method of pivoting first appeared in the corresponding LINPACK subroutine. The subroutine statement is SUBROUTINE DQRFAC(M,N,A,LDA,PIVOT,IPVT,LIPVT,SIGMA,ACNORM,WA) where M is a positive integer input variable set to the number of rows of A. N is a positive integer input variable set to the number of columns of A. A is an M by N array. On input A contains the matrix for which the QR factorization is to be computed. On output the strict upper trapezoidal part of A contains the strict upper trapezoidal part of R, and the lower trapezoidal part of A contains a factored form of Q (the non-trivial elements of the U vectors described above). LDA is a positive integer input variable not less than M which specifies the leading dimension of the array A. PIVOT is a logical input variable. If pivot is set .TRUE., then column pivoting is enforced. If pivot is set .FALSE., then no column pivoting is done. IPVT is an integer output array of length LIPVT. IPVT defines the permutation matrix P such that A*P = Q*R. Column J of P is column IPVT(J) of the identity matrix. If pivot is .FALSE., IPVT is not referenced. LIPVT is a positive integer input variable. If PIVOT is .FALSE., then LIPVT may be as small as 1. If PIVOT is .TRUE., then LIPVT must be at least N. SIGMA is an output array of length N which contains the diagonal elements of R. ACNORM is an output array of length N which contains the norms of the corresponding columns of the input matrix A. If this information is not needed, then ACNORM can coincide with SIGMA. WA is a work array of length N. If pivot is .FALSE., then WA can coincide with SIGMA. Subprograms called SLATEC-Supplied ... D1MACH,DENORM FORTRAN-Supplied ... DMAX1,DSQRT,MIN0 MINPACK. Version of December 1978. Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More **********
DQRSL
SUBROUTINE DQRSL(X,LDX,N,K,QRAUX,Y,QY,QTY,B,RSD,XB,JOB,INFO) DQRSL applies the output of DQRDC to compute coordinate transformations, projections, and least squares solutions. For K .LE. MIN(N,P), let XK be the matrix XK = (X(JPVT(1)),X(JPVT(2)), ... ,X(JPVT(K))) formed from columnns JPVT(1), ... ,JPVT(K) of the original N X P matrix X that was input to DQRDC (if no pivoting was done, XK consists of the first K columns of X in their original order). DQRDC produces a factored orthogonal matrix Q and an upper triangular matrix R such that XK = Q * (R) (0) This information is contained in coded form in the arrays X and QRAUX. On Entry X DOUBLE PRECISION(LDX,P). X contains the output of DQRDC. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of rows of the matrix XK. It must have the same value as N in DQRDC. K INTEGER. K is the number of columns of the matrix XK. K must not be greater than MIN(N,P), where P is the same as in the calling sequence to DQRDC. QRAUX DOUBLE PRECISION(P). QRAUX contains the auxiliary output from DQRDC. Y DOUBLE PRECISION(N) Y contains an N-vector that is to be manipulated by DQRSL. JOB INTEGER. JOB specifies what is to be computed. JOB has the decimal expansion ABCDE, with the following meaning. If A .NE. 0, compute QY. If B,C,D, or E .NE. 0, compute QTY. If C .NE. 0, compute B. If D .NE. 0, compute RSD. If E .NE. 0, compute XB. Note that a request to compute B, RSD, or XB automatically triggers the computation of QTY, for which an array must be provided in the calling sequence. On Return QY DOUBLE PRECISION(N). QY contains Q*Y, if its computation has been requested. QTY DOUBLE PRECISION(N). QTY contains TRANS(Q)*Y, if its computation has been requested. Here TRANS(Q) is the transpose of the matrix Q. B DOUBLE PRECISION(K) B contains the solution of the least squares problem minimize norm2(Y - XK*B), if its computation has been requested. (Note that if pivoting was requested in DQRDC, the J-th component of B will be associated with column JPVT(J) of the original matrix X that was input into DQRDC.) RSD DOUBLE PRECISION(N). RSD contains the least squares residual Y - XK*B, if its computation has been requested. RSD is also the orthogonal projection of Y onto the orthogonal complement of the column space of XK. XB DOUBLE PRECISION(N). XB contains the least squares approximation XK*B, if its computation has been requested. XB is also the orthogonal projection of Y onto the column space of X. INFO INTEGER. INFO is zero unless the computation of B has been requested and R is exactly singular. In this case, INFO is the index of the first zero diagonal element of R and B is left unaltered. The parameters QY, QTY, B, RSD, and XB are not referenced if their computation is not requested and in this case can be replaced by dummy variables in the calling program. To save storage, the user may in some cases use the same array for different parameters in the calling sequence. A frequently occuring example is when one wishes to compute any of B, RSD, or XB and does not need Y or QTY. In this case one may identify Y, QTY, and one of B, RSD, or XB, while providing separate arrays for anything else that is to be computed. Thus the calling sequence CALL DQRSL(X,LDX,N,K,QRAUX,Y,DUM,Y,B,Y,DUM,110,INFO) will result in the computation of B and RSD, with RSD overwriting Y. More generally, each item in the following list contains groups of permissible identifications for a single calling sequence. 1. (Y,QTY,B) (RSD) (XB) (QY) 2. (Y,QTY,RSD) (B) (XB) (QY) 3. (Y,QTY,XB) (B) (RSD) (QY) 4. (Y,QY) (QTY,B) (RSD) (XB) 5. (Y,QY) (QTY,RSD) (B) (XB) 6. (Y,QY) (QTY,XB) (B) (RSD) In any group the value returned in the array allocated to the group corresponds to the last member of the group. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. DQRSL uses the following functions and subprograms. BLAS DAXPY,DCOPY,DDOT Fortran DABS,MIN0,MOD
DQRSLV
SUBROUTINE DQRSLV(N,R,LDR,IPVT,DIAG,QTB,X,SIGMA,WA) **** Double Precision version of QRSOLV **** ********** Subroutine DQRSLV Given an M by N matrix A, an N by N diagonal matrix D, and an M-vector B, the problem is to determine an X which solves the system A*X = B , D*X = 0 , in the least squares sense. This subroutine completes the solution of the problem if it is provided with the necessary information from the QR factorization, with column pivoting, of A. That is, if A*P = Q*R, where P is a permutation matrix, Q has orthogonal columns, and R is an upper triangular matrix with diagonal elements of nonincreasing magnitude, then DQRSLV expects the full upper triangle of R, the permutation matrix P, and the first N components of (Q TRANSPOSE)*B. The system A*X = B, D*X = 0, is then equivalent to T T R*Z = Q *B , P *D*P*Z = 0 , where X = P*Z. If this system does not have full rank, then a least squares solution is obtained. On output DQRSLV also provides an upper triangular matrix S such that T T T P *(A *A + D*D)*P = S *S . S is computed within DQRSLV and may be of separate interest. The subroutine statement is SUBROUTINE DQRSLV(N,R,LDR,IPVT,DIAG,QTB,X,SIGMA,WA) where N is a positive integer input variable set to the order of R. R is an N by N array. On input the full upper triangle must contain the full upper triangle of the matrix R. On output the full upper triangle is unaltered, and the strict lower triangle contains the strict upper triangle (transposed) of the upper triangular matrix S. LDR is a positive integer input variable not less than N which specifies the leading dimension of the array R. IPVT is an integer input array of length N which defines the permutation matrix P such that A*P = Q*R. Column J of P is column IPVT(J) of the identity matrix. DIAG is an input array of length N which must contain the diagonal elements of the matrix D. QTB is an input array of length N which must contain the first N elements of the vector (Q TRANSPOSE)*B. X is an output array of length N which contains the least squares solution of the system A*X = B, D*X = 0. SIGMA is an output array of length N which contains the diagonal elements of the upper triangular matrix S. WA is a work array of length N. Subprograms called FORTRAN-Supplied ... DABS,DSQRT MINPACK. Version of December 1978. Burton S. Garbow, Kenneth E. Hillstrom, Jorge J. More **********
DQWGTC
DOUBLE PRECISION FUNCTION DQWGTC(X,C,P2,P3,P4,KP)
DQWGTF
DOUBLE PRECISION FUNCTION DQWGTF(X,OMEGA,P2,P3,P4,INTEGR)
DQWGTS
DOUBLE PRECISION FUNCTION DQWGTS(X,A,B,ALFA,BETA,INTEGR)
DROT
SUBROUTINE DROT(N,DX,INCX,DY,INCY,DC,DS) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY DC D.P. element of rotation matrix DS D.P. element of rotation matrix --Output-- DX rotated vector (unchanged if N .LE. 0) DY rotated vector (unchanged if N .LE. 0) Multiply the 2 X 2 matrix ( DC DS) times the 2 X N matrix (DX**T) (-DS DC) (DY**T) where **T indicates transpose. The elements of DX are in DX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for DY using LY and INCY.
DROTG
SUBROUTINE DROTG(DA,DB,DC,DS) B L A S Subprogram Description of Parameters --Input-- DA double precision scalar DB double precision scalar --Output-- DA double precision result R DB double precision result Z DC double precision result DS double precision result Designed by C. L. Lawson, JPL, 1977 Sept 08 Construct the Givens transformation ( DC DS ) G = ( ) , DC**2 + DS**2 = 1 , (-DS DC ) which zeros the second entry of the 2-vector (DA,DB)**T . The quantity R = (+/-)DSQRT(DA**2 + DB**2) overwrites DA in storage. The value of DB is overwritten by a value Z which allows DC and DS to be recovered by the following algorithm. If Z=1 set DC=0.D0 and DS=1.D0 If DABS(Z) .LT. 1 set DC=DSQRT(1-Z**2) and DS=Z If DABS(Z) .GT. 1 set DC=1/Z and DS=DSQRT(1-DC**2) Normally, the subprogram DROT(N,DX,INCX,DY,INCY,DC,DS) will next be called to apply the transformation to a 2 by N matrix.
DROTM
SUBROUTINE DROTM(N,DX,INCX,DY,INCY,DPARAM) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY DPARAM 5-element D.P. vector. DPARAM(1) is DFLAG described below. Elements 2-5 form the transformation matrix H. --Output-- DX rotated vector (unchanged if N .LE. 0) DY rotated vector (unchanged if N .LE. 0) Apply the modified Givens transformation, H, to the 2 by N matrix (DX**T), where **T indicates transpose. The elements of DX are in (DY**T) DX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for SY using LY and INCY. With DPARAM(1)=DFLAG, H has one of the following forms. DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) H=( ) ( ) ( ) ( ) (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). See DROTMG for a description of data storage in DPARAM.
DROTMG
SUBROUTINE DROTMG(DD1,DD2,DX1,DY1,DPARAM) B L A S Subprogram Description of Parameters --Input-- DD1 double precision scalar DD2 double precision scalar DX1 double precision scalar DX2 double precision scalar DPARAM D.P. 5-vector. DPARAM(1)=DFLAG defined below. Elements 2-5 define the transformation matrix H. --Output-- DD1 changed to represent the effect of the transformation DD2 changed to reflect the transformation DX1 changed to reflect the transformation DX2 unchanged Construct the modified Givens transformation matrix H which zeros the second component of the 2-vector (DSQRT(DD1)*DX1,DSQRT(DD2)* DY2)**T. With DPARAM(1)=DFLAG, H has one of the following forms.. DFLAG=-1.D0 DFLAG=0.D0 DFLAG=1.D0 DFLAG=-2.D0 (DH11 DH12) (1.D0 DH12) (DH11 1.D0) (1.D0 0.D0) H=( ) ( ) ( ) ( ) (DH21 DH22), (DH21 1.D0), (-1.D0 DH22), (0.D0 1.D0). Locations 2-5 of DPARAM contain DH11, DH21, DH12, and DH22 respectively. (Values of 1.D0, -1.D0, or 0.D0 implied by the value of DPARAM(1) are not stored in DPARAM.)
DRSCO
SUBROUTINE DRSCO(RSAV,ISAV) DRSCO transfers data from arrays to a common block within the integrator package DDEBDF.
DSCAL
SUBROUTINE DSCAL(N,DA,DX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DA double precision scale factor DX double precision vector with N elements INCX storage spacing between elements of DX --Output-- DX double precision result (unchanged if N.LE.0) Replace double precision DX by double precision DA*DX. For I = 0 to N-1, replace DX(1+I*INCX) with DA * DX(1+I*INCX)
DSDOT
DOUBLE PRECISION FUNCTION DSDOT(N,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- DSDOT double precision dot product (zero if N.LE.0) Returns D.P. dot product accumulated in D.P., for S.P. SX and SY DSDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
DSICO
SUBROUTINE DSICO(A,LDA,N,KPVT,RCOND,Z) DSICO factors a double precision symmetric matrix by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, DSIFA is slightly faster. To solve A*X = B , follow DSICO by DSISL. To compute INVERSE(A)*C , follow DSICO by DSISL. To compute INVERSE(A) , follow DSICO by DSIDI. To compute DETERMINANT(A) , follow DSICO by DSIDI. To compute INERTIA(A), follow DSICO by DSIDI. On Entry A DOUBLE PRECISION(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . Output A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices, TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DSIFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,IABS,DSIGN
DSIDI
SUBROUTINE DSIDI(A,LDA,N,KPVT,DET,INERT,WORK,JOB) DSIDI computes the determinant, inertia and inverse of a double precision symmetric matrix using the factors from DSIFA. On Entry A DOUBLE PRECISION(LDA,N) the output from DSIFA. LDA INTEGER the leading dimension of the array A. N INTEGER the order of the matrix A. KPVT INTEGER(N) the pivot vector from DSIFA. WORK DOUBLE PRECISION(N) work vector. Contents destroyed. JOB INTEGER JOB has the decimal expansion ABC where if C .NE. 0, the inverse is computed, if B .NE. 0, the determinant is computed, if A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. A contains the upper triangle of the inverse of the original matrix. The strict lower triangle is never referenced. DET DOUBLE PRECISION(2) determinant of original matrix. DETERMINANT = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero may occur if the inverse is requested and DSICO has set RCOND .EQ. 0.0 or DSIFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab Subroutines and Functions BLAS DAXPY,DCOPY,DDOT,DSWAP Fortran DABS,IABS,MOD
DSIFA
SUBROUTINE DSIFA(A,LDA,N,KPVT,INFO) DSIFA factors a double precision symmetric matrix by elimination with symmetric pivoting. To solve A*X = B , follow DSIFA by DSISL. To compute INVERSE(A)*C , follow DSIFA by DSISL. To compute DETERMINANT(A) , follow DSIFA by DSIDI. To compute INERTIA(A) , follow DSIFA by DSIDI. To compute INVERSE(A) , follow DSIFA by DSIDI. On Entry A DOUBLE PRECISION(LDA,N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices, TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that DSISL or DSIDI may divide by zero if called. LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS DAXPY,DSWAP,IDAMAX Fortran DABS,DMAX1,DSQRT
DSISL
SUBROUTINE DSISL(A,LDA,N,KPVT,B) DSISL solves the double precision symmetric system A * X = B using the factors computed by DSIFA. On Entry A DOUBLE PRECISION(LDA,N) the output from DSIFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . KPVT INTEGER(N) the pivot vector from DSIFA. B DOUBLE PRECISION(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if DSICO has set RCOND .EQ. 0.0 or DSIFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DSIFA(A,LDA,N,KPVT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL DSISL(A,LDA,N,KPVT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS DAXPY,DDOT Fortran IABS
DSLVS
SUBROUTINE DSLVS(WM,IWM,X,TEM) DSLVS solves the linear system in the iteration scheme for the integrator package DDEBDF.
DSPCO
SUBROUTINE DSPCO(AP,N,KPVT,RCOND,Z) DSPCO factors a double precision symmetric matrix stored in packed form by elimination with symmetric pivoting and estimates the condition of the matrix. IF RCOND is not needed, DSPFA is slightly faster. To solve A*X = B , follow DSPCO by DSPSL. To compute INVERSE(A)*C , follow DSPCO by DSPSL. To compute INVERSE(A) , follow DSPCO by DSPDI. To compute DETERMINANT(A) , follow DSPCO by DSPDI. To compute INERTIA(A), follow DSPCO by DSPDI. On Entry AP DOUBLE PRECISION (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. RCOND DOUBLE PRECISION an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK DSPFA BLAS DAXPY,DDOT,DSCAL,DASUM Fortran DABS,DMAX1,IABS,DSIGN
DSPDI
SUBROUTINE DSPDI(AP,N,KPVT,DET,INERT,WORK,JOB) DSPDI computes the determinant, inertia and inverse of a double precision symmetric matrix using the factors from DSPFA, where the matrix is stored in packed form. On Entry AP DOUBLE PRECISION (N*(N+1)/2) the output from DSPFA. N INTEGER the order of the matrix A. KPVT INTEGER(N) the pivot vector from DSPFA. WORK DOUBLE PRECISION(N) work vector. Contents ignored. JOB INTEGER JOB has the decimal expansion ABC where if C .NE. 0, the inverse is computed, if B .NE. 0, the determinant is computed, if A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. AP contains the upper triangle of the inverse of the original matrix, stored in packed form. The columns of the upper triangle are stored sequentially in a one-dimensional array. DET DOUBLE PRECISION(2) determinant of original matrix. DETERMINANT = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero will occur if the inverse is requested and DSPCO has set RCOND .EQ. 0.0 or DSPFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS DAXPY,DCOPY,DDOT,DSWAP Fortran DABS,IABS,MOD
DSPFA
SUBROUTINE DSPFA(AP,N,KPVT,INFO) DSPFA factors a double precision symmetric matrix stored in packed form by elimination with symmetric pivoting. To solve A*X = B , follow DSPFA by DSPSL. To compute INVERSE(A)*C , follow DSPFA by DSPSL. To compute DETERMINANT(A) , follow DSPFA by DSPDI. To compute INERTIA(A) , follow DSPFA by DSPDI. To compute INVERSE(A) , follow DSPFA by DSPDI. On Entry AP DOUBLE PRECISION (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices, TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that DSPSL or DSPDI may divide by zero if called. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS DAXPY,DSWAP,IDAMAX Fortran DABS,DMAX1,DSQRT
DSPSL
SUBROUTINE DSPSL(AP,N,KPVT,B) DSISL solves the double precision symmetric system A * X = B using the factors computed by DSPFA. On Entry AP DOUBLE PRECISION(N*(N+1)/2) the output from DSPFA. N INTEGER the order of the matrix A . KPVT INTEGER(N) the pivot vector from DSPFA. B DOUBLE PRECISION(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if DSPCO has set RCOND .EQ. 0.0 or DSPFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL DSPFA(AP,N,KPVT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL DSPSL(AP,N,KPVT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS DAXPY,DDOT Fortran IABS
DSVDC
SUBROUTINE DSVDC(X,LDX,N,P,S,E,U,LDU,V,LDV,WORK,JOB,INFO) DSVDC is a subroutine to reduce a double precision NxP matrix X by orthogonal transformations U and V to diagonal form. The diagonal elements S(I) are the singular values of X. The columns of U are the corresponding left singular vectors, and the columns of V the right singular vectors. On Entry X DOUBLE PRECISION(LDX,P), where LDX .GE. N. X contains the matrix whose singular value decomposition is to be computed. X is destroyed by DSVDC. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of columns of the matrix X. P INTEGER. P is the number of rows of the matrix X. LDU INTEGER. LDU is the leading dimension of the array U. (See below). LDV INTEGER. LDV is the leading dimension of the array V. (See below). WORK DOUBLE PRECISION(N). WORK is a scratch array. JOB INTEGER. JOB controls the computation of the singular vectors. It has the decimal expansion AB with the following meaning A .EQ. 0 do not compute the left singular vectors. A .EQ. 1 return the N left singular vectors in U. A .GE. 2 return the first MIN(N,P) singular vectors in U. B .EQ. 0 do not compute the right singular vectors. B .EQ. 1 return the right singular vectors in V. On Return S DOUBLE PRECISION(MM), where MM=MIN(N+1,P). The first MIN(N,P) entries of S contain the singular values of X arranged in descending order of magnitude. E DOUBLE PRECISION(P). E ordinarily contains zeros. However see the discussion of INFO for exceptions. U DOUBLE PRECISION(LDU,K), where LDU .GE. N. If JOBA .EQ. 1, then K .EQ. N. If JOBA .GE. 2, then K .EQ. MIN(N,P). U contains the matrix of right singular vectors. U is not referenced if JOBA .EQ. 0. If N .LE. P or if JOBA .EQ. 2, then U may be identified with X in the subroutine call. V DOUBLE PRECISION(LDV,P), where LDV .GE. P. V contains the matrix of right singular vectors. V is not referenced if JOB .EQ. 0. If P .LE. N, then V may be identified with X in the subroutine call. INFO INTEGER. The singular values (and their corresponding singular vectors) S(INFO+1),S(INFO+2),...,S(M) are correct (here M=MIN(N,P)). Thus if INFO .EQ. 0, all the singular values and their vectors are correct. In any event, the matrix B = TRANS(U)*X*V is the bidiagonal matrix with the elements of S on its diagonal and the elements of E on its super-diagonal (TRANS(U) is the transpose of U). Thus the singular values of X and B are the same. LINPACK. This version dated 03/19/79 . G. W. Stewart, University of Maryland, Argonne National Lab. DSVDC uses the following functions and subprograms. External DROT BLAS DAXPY,DDOT,DSCAL,DSWAP,DNRM2,DROTG Fortran DABS,DMAX1,MAX0,MIN0,MOD,DSQRT
DSWAP
SUBROUTINE DSWAP(N,DX,INCX,DY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX DY double precision vector with N elements INCY storage spacing between elements of DY --Output-- DX input vector DY (unchanged if N .LE. 0) DY input vector DX (unchanged if N .LE. 0) Interchange double precision DX and double precision DY. For I = 0 to N-1, interchange DX(LX+I*INCX) and DY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
DTRCO
SUBROUTINE DTRCO(T,LDT,N,RCOND,Z,JOB) DTRCO estimates the condition of a double precision triangular matrix. On Entry T DOUBLE PRECISION(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 0 T is lower triangular. = nonzero T is upper triangular. On Return RCOND DOUBLE PRECISION an estimate of the reciprocal condition of T . For the system T*X = B , relative perturbations in T and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then T may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z DOUBLE PRECISION(N) a work vector whose contents are usually unimportant. If T is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL,DASUM Fortran DABS,DMAX1,DSIGN
DTRDI
SUBROUTINE DTRDI(T,LDT,N,DET,JOB,INFO) DTRDI computes the determinant and inverse of a double precision triangular matrix. On Entry T DOUBLE PRECISION(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 010 no det, inverse of lower triangular. = 011 no det, inverse of upper triangular. = 100 det, no inverse. = 110 det, inverse of lower triangular. = 111 det, inverse of upper triangular. On Return T inverse of original matrix if requested. Otherwise unchanged. DET DOUBLE PRECISION(2) determinant of original matrix if requested. Otherwise not referenced. DETERMINANT = DET(1) * 10.0**DET(2) with 1.0 .LE. DABS(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . INFO INTEGER INFO contains zero if the system is nonsingular and the inverse is requested. Otherwise INFO contains the index of a zero diagonal element of T. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DSCAL Fortran DABS,MOD
DTRSL
SUBROUTINE DTRSL(T,LDT,N,B,JOB,INFO) DTRSL solves systems of the form T * X = B or TRANS(T) * X = B where T is a triangular matrix of order N. Here TRANS(T) denotes the transpose of the matrix T. On Entry T DOUBLE PRECISION(LDT,N) T contains the matrix of the system. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. B DOUBLE PRECISION(N). B contains the right hand side of the system. JOB INTEGER JOB specifies what kind of system is to be solved. If JOB is 00 solve T*X=B, T lower triangular, 01 solve T*X=B, T upper triangular, 10 solve TRANS(T)*X=B, T lower triangular, 11 solve TRANS(T)*X=B, T upper triangular. On Return B B contains the solution, if INFO .EQ. 0. Otherwise B is unaltered. INFO INTEGER INFO contains zero if the system is nonsingular. Otherwise INFO contains the index of the first zero diagonal element of T. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. Subroutines and Functions BLAS DAXPY,DDOT Fortran MOD
DU11LS
SUBROUTINE DU11LS(A,MDA,M,N,UB,DB,MODE,NP,KRANK,KSURE,H,W,EB,IC, **** Double Precision version of U11LS **** This routine performs a QR factorization of A using Householder transformations. Row and column pivots are chosen to reduce the growth of round-off and to help detect possible rank deficiency.
DU11US
SUBROUTINE DU11US(A,MDA,M,N,UB,DB,MODE,NP,KRANK,KSURE,H,W,EB,IR, This routine performs an LQ factorization of the matrix A using Householder transformations. Row and column pivots are chosen to reduce the growth of round-off and to help detect possible rank deficiency.
DU12LS
SUBROUTINE DU12LS(A,MDA,M,N,B,MDB,NB,MODE,KRANK,RNORM,H,W,IC,IR) Given the Householder QR factorization of A, this subroutine solves the system AX=B. If the system is of reduced rank, this routine returns a solution according to the selected mode. Note - If MODE.NE.2, W is never accessed.
DU12US
SUBROUTINE DU12US(A,MDA,M,N,B,MDB,NB,MODE,KRANK,RNORM,H,W,IR,IC) Given the Householder LQ factorization of A, this subroutine solves the system AX=B. If the system is of reduced rank, this routine returns a solution according to the selected mode. Note - If MODE.NE.2, W is never accessed.
DULSIA
SUBROUTINE DULSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP,KRANK, **** Double Precision version of ULSIA **** DULSIA computes the minimal length solution(s) to the problem AX=B where A is an M by N matrix with M.LE.N and B is the M by NB matrix of right hand sides. User input bounds on the uncertainty in the elements of A are used to detect numerical rank deficiency. The algorithm employs a row and column pivot strategy to minimize the growth of uncertainty and round-off errors. DULSIA requires (MDA+1)*N + (MDB+1)*NB + 6*M dimensioned space ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** Input.. All TYPE REAL variables are DOUBLE PRECISION A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). Must have MDA.GE.M and M.LE.N. B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Since the solutio is returned in B, must have MDB.GE.N. If NB = 0, B i never accessed. ****************************************************************** * * * Note - Use of RE and AE are what make this * * code significantly different from * * other linear least squares solvers. * * However, the inexperienced user is * * advised to set RE=0.,AE=0.,KEY=0. * * * ****************************************************************** RE(),AE(),KEY RE() RE() is a vector of length N such that RE(I) is the maximum relative uncertainty in row I of the matrix A. The values of RE() must be between 0 and 1. A minimum of 10*machine precision will be enforced. AE() AE() is a vector of length N such that AE(I) is the maximum absolute uncertainty in row I of the matrix A. The values of AE() must be greater than or equal to 0. KEY For ease of use, RE and AE may be input as either vectors or scalars. If a scalar is input, the algo- rithm will use that value for each column of A. The parameter KEY indicates whether scalars or vectors are being input. KEY=0 RE scalar AE scalar KEY=1 RE vector AE scalar KEY=2 RE scalar AE vector KEY=3 RE vector AE vector MODE The integer MODE indicates how the routine is to react if rank deficiency is detected. If MODE = 0 return immediately, no solution 1 compute truncated solution 2 compute minimal length least squares sol The inexperienced user is advised to set MODE=0 NP The first NP rows of A will not be interchanged with other rows even though the pivot strategy would suggest otherwise. The inexperienced user is advised to set NP=0. WORK() A real work array dimensioned 5*M. However,if RE or AE have been specified as vectors, dimension WORK 4*M. If both RE and AE have been specified as vectors, dimension WORK 3*M. LW Actual dimension of WORK IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO Is a flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, KRANK, LW, IWORK, LIW, and the first 2*M locations of WORK as output by the original call to DULSIA. MODE must be equal to the value of MODE in the original call. If MODE.LT.2, only the first N locations of WORK are accessed. AE, RE, KEY, and NP are not accessed. Output..All TYPE REAL variables are DOUBLE PRECISION A(,) Contains the lower triangular part of the reduced matrix and the transformation information. It togeth with the first M elements of WORK (see below) completely specify the LQ factorization of A. B(,) Contains the N by NB solution matrix for X. KRANK,KSURE The numerical rank of A, based upon the relative and absolute bounds on uncertainty, is bounded above by KRANK and below by KSURE. The algorithm returns a solution based on KRANK. KSURE provides an indication of the precision of the rank. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. If the matrix A is of full rank, then RNORM=0.0. WORK() The first M locations of WORK contain values necessary to reproduce the Householder transformatio IWORK() The first N locations contain the order in which the columns of A were used. The next M locations contain the order in which the rows of A were used. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Rank deficient, no solution 1 - Rank deficient, truncated solution 2 - Rank deficient, minimal length least squares sol 3 - Numerical rank 0, zero solution 4 - Rank .LT. NP 5 - Full rank
DUSRMT
SUBROUTINE DUSRMT(I,J,AIJ,INDCAT,PRGOPT,DATTRV,IFLAG) The user may supply this code
DVECS
SUBROUTINE DVECS(NCOMP,LNFC,YHP,WORK,IWORK,INHOMO,IFLAG)
DVNORM
DOUBLE PRECISION FUNCTION DVNORM(V,NCOMP)
DVNRMS
DOUBLE PRECISION FUNCTION DVNRMS(N,V,W)
DVOUT
SUBROUTINE DVOUT(N,DX,IFMT,IDIGIT) REVISED FEB. 27, 1981. DOUBLE PRECISION VECTOR OUTPUT ROUTINE. INPUT.. N,DX(*) PRINT THE DOUBLE PRECISION ARRAY DX(I),I=1,...,N, ON OUTPUT UNIT LOUT. THE HEADING IN THE FORTRAN FORMAT STATEMENT IFMT(*), DESCRIBED BELOW, IS PRINTED AS A FIRST STEP. THE COMPONENTS DX(I) ARE INDEXED, ON OUTPUT, IN A PLEASANT FORMAT. IFMT(*) A FORTRAN FORMAT STATEMENT. THIS IS PRINTED ON OUTPUT UNIT LOUT WITH THE VARIABLE FORMAT FORTRAN STATEMENT WRITE(LOUT,IFMT) IDIGIT PRINT AT LEAST IABS(IDIGIT) DECIMAL DIGITS PER NUMBER. THE SUBPROGRAM WILL CHOOSE THAT INTEGER 4,6,10 OR 14 WHICH WILL PRINT AT LEAST IABS(IDIGIT) NUMBER OF PLACES. IF IDIGIT.LT.0, 72 PRINTING COLUMNS ARE UTILIZED TO WRITE EACH LINE OF OUTPUT OF THE ARRAY DX(*). (THIS CAN BE USED ON MOST TIME-SHARING TERMINALS). IF IDIGIT.GE.0, 133 PRINTING COLUMNS ARE UTILIZED. (THIS CAN BE USED ON MOST LINE PRINTERS). EXAMPLE.. PRINT AN ARRAY CALLED (COSTS OF PURCHASES) OF LENGTH 100 SHOWING 6 DECIMAL DIGITS PER NUMBER. THE USER IS RUNNING ON A TIME-SHARING SYSTEM WITH A 72 COLUMN OUTPUT DEVICE. DOUBLE PRECISION COSTS(100) N = 100 IDIGIT = -6 CALL DVOUT(N,COSTS,'(''1COSTS OF PURCHASES'')',IDIGIT) AUTHORS JOHN A. WISNIEWSKI SANDIA LABS ALBUQUERQUE. RICHARD J. HANSON SANDIA LABS ALBUQUERQUE. DATE JULY 27,1978.
DWNLIT
SUBROUTINE DWNLIT(W,MDW,M,N,L,IPIVOT,ITYPE,H,SCALE,RNORM,IDOPE, THIS IS A COMPANION SUBPROGRAM TO DWNNLS( ). THE DOCUMENTATION FOR DWNNLS( ) HAS MORE COMPLETE USAGE INSTRUCTIONS. NOTE THE M BY (N+1) MATRIX W( , ) CONTAINS THE RT. HAND SIDE B AS THE (N+1)ST COL. TRIANGULARIZE L1 BY L1 SUBSYSTEM, WHERE L1=MIN(M,L), WITH COL INTERCHANGES. REVISED APRIL 19, 1981.
DWNLSM
SUBROUTINE DWNLSM(W,MDW,MME,MA,N,L,PRGOPT,X,RNORM,MODE,IPIVOT, **** Double Precision version of WNLSM **** This is a companion subprogram to DWNNLS( ). The documentation for DWNNLS( ) has more complete usage instructions. Written by Karen H. Haskell, Sandia Laboratories, with the help of R.J. Hanson, Sandia Laboratories, December 1976 - January 1978. Revised March 4, 1982. In addition to the parameters discussed in the prologue to subroutine DWNNLS, the following work arrays are used in subroutine DWNLSM (they are passed through the calling sequence from DWNNLS for purposes of variable dimensioning). Their contents will in general be of no interest to the user. IPIVOT(*) An array of length N. Upon completion it contains the pivoting information for the cols of W(*,*). ITYPE(*) An array of length M which is used to keep track of the classification of the equations. ITYPE(I)=0 denotes equation I as an equality constraint. ITYPE(I)=1 denotes equation I as a least squares equation. WD(*) An array of length N. Upon completion it contains the dual solution vector. H(*) An array of length N. Upon completion it contains the pivot scalars of the Householder transformations performed in the case KRANK.LT.L. SCALE(*) An array of length M which is used by the subroutine to store the diagonal matrix of weights. These are used to apply the modified Givens transformations. Z(*),TEMP(*) Working arrays of length N. D(*) An array of length N that contains the column scaling for the matrix (E). (A)
EISDOC
SUBROUTINE EISDOC **********EISPACK Routines********** single double complx ------ ------ ------ RS - CH Computes eigenvalues and, optionally, eigenvectors of real symmetric (complex Hermitian) matrix. RSP - - Compute eigenvalues and, optionally, eigenvectors of real symmetric matrix packed into a one dimensional array. RG - CG Computes eigenvalues and, optionally, eigenvectors of a real (complex) general matrix. BISECT - - Compute eigenvalues of symmetric tridiagonal matrix given interval using Sturm sequencing. IMTQL1 - - Computes eigenvalues of symmetric tridiagonal matrix implicit QL method. IMTQL2 - - Computes eigenvalues and eigenvectors of symmetric tridiagonal matrix using implicit QL method. IMTQLV - - Computes eigenvalues of symmetric tridiagonal matrix by the implicit QL method. Eigenvectors may be computed later. RATQR - - Computes largest or smallest eigenvalues of symmetric tridiagonal matrix using rational QR method with Newton correction. RST - - Compute eigenvalues and, optionally, eigenvectors of real symmetric tridiagonal matrix. RT - - Compute eigenvalues and eigenvectors of a special real tridiagonal matrix. TQL1 - - Compute eigenvalues of symmetric tridiagonal matrix by QL method. TQL2 - - Compute eigenvalues and eigenvectors of symmetric tridiagonal matrix. TQLRAT - - Computes eigenvalues of symmetric tridiagonal matrix a rational variant of the QL method. TRIDIB - - Computes eigenvalues of symmetric tridiagonal matrix given interval using Sturm sequencing. TSTURM - - Computes eigenvalues of symmetric tridiagonal matrix given interval and eigenvectors by Sturm sequencing. This subroutine is a translation of the ALGOL procedure TRISTURM by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 418-439(1971). BQR - - Computes some of the eigenvalues of a real symmetric matrix using the QR method with shifts of origin. RSB - - Computes eigenvalues and, optionally, eigenvectors of symmetric band matrix. RSG - - Computes eigenvalues and, optionally, eigenvectors of symmetric generalized eigenproblem: A*X=(LAMBDA)*B*X RSGAB - - Computes eigenvalues and, optionally, eigenvectors of symmetric generalized eigenproblem: A*B*X=(LAMBDA)*X RSGBA - - Computes eigenvalues and, optionally, eigenvectors of symmetric generalized eigenproblem: B*A*X=(LAMBDA)*X RGG - - Computes eigenvalues and eigenvectors for real generalized eigenproblem: A*X=(LAMBDA)*B*X. BALANC - CBAL Balances a general real (complex) matrix and isolates eigenvalues whenever possible. BANDR - - Reduces real symmetric band matrix to symmetric tridiagonal matrix and, optionally, accumulates orthogonal similarity transformations. HTRID3 - - Reduces complex Hermitian (packed) matrix to real symmetric tridiagonal matrix by unitary similarity transformations. HTRIDI - - Reduces complex Hermitian matrix to real symmetric tridiagonal matrix using unitary similarity transformations. TRED1 - - Reduce real symmetric matrix to symmetric tridiagonal matrix using orthogonal similarity transformations. TRED2 - - Reduce real symmetric matrix to symmetric tridiagonal matrix using and accumulating orthogonal transformations. TRED3 - - Reduce symmetric matrix stored in packed form to symmetric tridiagonal matrix using orthogonal transformations. ELMHES - COMHES Reduces real (complex) general matrix to upper Hessenberg form using stabilized elementary similarity transformations. ORTHES - CORTH Reduces real (complex) general matrix to upper Hessenberg form orthogonal (unitary) similarity transformations. QZHES - - The first step of the QZ algorithm for solving generalized matrix eigenproblems. Accepts a pair of real general matrices and reduces one of them to upper Hessenberg and the other to upper triangular form using orthogonal transformations. Usually followed by QZIT, QZVAL, QZ QZIT - - The second step of the QZ algorithm for generalized eigenproblems. Accepts an upper Hessenberg and an upper triangular matrix and reduces the former to quasi-triangular form while preserving the form of the latter. Usually preceeded by QZHES and followed by QZVAL and QZVEC. FIGI - - Transforms certain real non-symmetric tridiagonal matrix to symmetric tridiagonal matrix. FIGI2 - - Transforms certain real non-symmetric tridiagonal matrix to symmetric tridiagonal matrix. REDUC - - Reduces generalized symmetric eigenproblem A*X=(LAMBDA)*B*X, to standard symmetric eigenproblem using Cholesky factorization. REDUC2 - - Reduces certain generalized symmetric eigenproblems standard symmetric eigenproblem, using Cholesky factorization. - - COMLR Computes eigenvalues of a complex upper Hessenberg matrix using the modified LR method. - - COMLR2 Computes eigenvalues and eigenvectors of complex upper Hessenberg matrix using modified LR method. HQR - COMQR Computes eigenvalues of a real (complex) upper Hessenberg matrix using the QR method. HQR2 - COMQR2 Computes eigenvalues and eigenvectors of real (complex) upper Hessenberg matrix using QR method. INVIT - CINVIT Computes eigenvectors of real (complex) Hessenberg matrix associated with specified eigenvalues by inverse iteration. QZVAL - - The third step of the QZ algorithm for generalized eigenproblems. Accepts a pair of real matrices, one quasi-triangular form and the other in upper triangular form and computes the eigenvalues of the associated eigenproblem. Usually preceded by QZHES, QZIT, and followed by QZVEC. BANDV - - Forms eigenvectors of real symmetric band matrix associated with a set of ordered approximate eigenvalue by inverse iteration. QZVEC - - The optional fourth step of the QZ algorithm for generalized eigenproblems. Accepts a matrix in quasi-triangular form and another in upper triangular and computes the eigenvectors of the triangular problem and transforms them back to the original coordinates Usually preceded by QZHES, QZIT, QZVAL. TINVIT - - Eigenvectors of symmetric tridiagonal matrix corresponding to some specified eigenvalues, using inverse iteration. BAKVEC - - Forms eigenvectors of certain real non-symmetric tridiagonal matrix from symmetric tridiagonal matrix output from FIGI. BALBAK - CBABK2 Forms eigenvectors of real (complex) general matrix from eigenvectors of matrix output from BALANC (CBAL). ELMBAK - COMBAK Forms eigenvectors of real (complex) general matrix from eigenvectors of upper Hessenberg matrix output from ELMHES (COMHES). ELTRAN - - Accumulates the stabilized elementary similarity transformations used in the reduction of a real general matrix to upper Hessenberg form by ELMHES. HTRIB3 - - Computes eigenvectors of complex Hermitian matrix from eigenvectors of real symmetric tridiagonal matrix output from HTRID3. HTRIBK - - Forms eigenvectors of complex Hermitian matrix from eigenvectors of real symmetric tridiagonal matrix output from HTRIDI. ORTBAK - CORTB Forms eigenvectors of general real (complex) matrix from eigenvectors of upper Hesenberg matrix output from ORTHES (CORTH). ORTRAN - - Accumulates orthogonal similarity transformations in reduction of real general matrix by ORTHES. REBAK - - Forms eigenvectors of generalized symmetric eigensystem from eigenvectors of derived matrix output from REDUC or REDUC2. REBAKB - - Forms eigenvectors of generalized symmetric eigensystem from eigenvectors of derived matrix output from REDUC2 TRBAK1 - - Forms the eigenvectors of real symmetric matrix from eigenvectors of symmetric tridiagonal matrix formed by TRED1. TRBAK3 - - Forms eigenvectors of real symmetric matrix from the eigenvectors of symmetric tridiagonal matrix formed by TRED3. MINFIT - - Compute Singular Value Decomposition of rectangular matrix and solve related Linear Least Squares problem.
ELMBAK
SUBROUTINE ELMBAK(NM,LOW,IGH,A,INT,M,Z) This subroutine is a translation of the ALGOL procedure ELMBAK, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). This subroutine forms the eigenvectors of a REAL GENERAL matrix by back transforming those of the corresponding upper Hessenberg matrix determined by ELMHES. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1 and IGH equal to the order of the matrix. A contains the multipliers which were used in the reduction by ELMHES in its lower triangle below the subdiagonal. INT contains information on the rows and columns interchanged in the reduction by ELMHES. Only elements LOW through IGH are used. M is the number of columns of Z to be back transformed. Z contains the real and imaginary parts of the eigen- vectors to be back transformed in its first M columns. On OUTPUT Z contains the real and imaginary parts of the transformed eigenvectors in its first M columns. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ELMHES
SUBROUTINE ELMHES(NM,N,LOW,IGH,A,INT) This subroutine is a translation of the ALGOL procedure ELMHES, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). Given a REAL GENERAL matrix, this subroutine reduces a submatrix situated in rows and columns LOW through IGH to upper Hessenberg form by stabilized elementary similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. A contains the input matrix. On OUTPUT A contains the Hessenberg matrix. The multipliers which were used in the reduction are stored in the remaining triangle under the Hessenberg matrix. INT contains information on the rows and columns interchanged in the reduction. Only elements LOW through IGH are used. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ELTRAN
SUBROUTINE ELTRAN(NM,N,LOW,IGH,A,INT,Z) This subroutine is a translation of the ALGOL procedure ELMTRANS, NUM. MATH. 16, 181-204(1970) by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971). This subroutine accumulates the stabilized elementary similarity transformations used in the reduction of a REAL GENERAL matrix to upper Hessenberg form by ELMHES. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. A contains the multipliers which were used in the reduction by ELMHES in its lower triangle below the subdiagonal. INT contains information on the rows and columns interchanged in the reduction by ELMHES. only elements LOW through IGH are used. On OUTPUT Z contains the transformation matrix produced in the reduction by ELMHES. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ENORM
REAL FUNCTION ENORM(N,X)
EPMACH
FUNCTION EPMACH(DUM)
FIGI
SUBROUTINE FIGI(NM,N,T,D,E,E2,IERR) Given a NONSYMMETRIC TRIDIAGONAL matrix such that the products of corresponding pairs of off-diagonal elements are all non-negative, this subroutine reduces it to a symmetric tridiagonal matrix with the same eigenvalues. If, further, a zero product only occurs when both factors are zero, the reduced matrix is similar to the original matrix. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. T contains the input matrix. Its subdiagonal is stored in the last N-1 positions of the first column, its diagonal in the N positions of the second column, and its superdiagonal in the first N-1 positions of the third column. T(1,1) and T(N,3) are arbitrary. On OUTPUT T is unaltered. D contains the diagonal elements of the symmetric matrix. E contains the subdiagonal elements of the symmetric matrix in its last N-1 positions. E(1) is not set. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. IERR is set to Zero for normal return, N+I if T(I,1)*T(I-1,3) is negative, -(3*N+I) if T(I,1)*T(I-1,3) is zero with one factor non-zero. In this case, the eigenvectors of the symmetric matrix are not simply related to those of T and should not be sought. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
FIGI2
SUBROUTINE FIGI2(NM,N,T,D,E,Z,IERR) Given a NONSYMMETRIC TRIDIAGONAL matrix such that the products of corresponding pairs of off-diagonal elements are all non-negative, and zero only when both factors are zero, this subroutine reduces it to a SYMMETRIC TRIDIAGONAL matrix using and accumulating diagonal similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. T contains the input matrix. Its subdiagonal is stored in the last N-1 positions of the first column, its diagonal in the N positions of the second column, and its superdiagonal in the first N-1 positions of the third column. T(1,1) and T(N,3) are arbitrary. On OUTPUT T is unaltered. D contains the diagonal elements of the symmetric matrix. E contains the subdiagonal elements of the symmetric matrix in its last N-1 positions. E(1) is not set. Z contains the transformation matrix produced in the reduction. IERR is set to Zero for normal return, N+I if T(I,1)*T(I-1,3) is negative, 2*N+I if T(I,1)*T(I-1,3) is zero with one factor non-zero. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HFTI
SUBROUTINE HFTI(A,MDA,M,N,B,MDB,NB,TAU,KRANK,RNORM,H,G,IP) DIMENSION A(MDA,N),(B(MDB,NB) or B(M)),RNORM(NB),H(N),G(N),IP(N) This subroutine solves a linear least squares problem or a set of linear least squares problems having the same matrix but different right-side vectors. The problem data consists of an M by N matrix A, an M by NB matrix B, and an absolute tolerance parameter TAU whose usage is described below. The NB column vectors of B represent right-side vectors for NB distinct linear least squares problems. This set of problems can also be written as the matrix least squares problem AX = B, where X is the N by NB solution matrix. Note that if B is the M by M identity matrix, then X will be the pseudo-inverse of A. This subroutine first transforms the augmented matrix (A B) to a matrix (R C) using premultiplying Householder transformations with column interchanges. All subdiagonal elements in the matrix R are zero and its diagonal elements satisfy ABS(R(I,I)).GE.ABS(R(I+1,I+1)), I = 1,...,L-1, where L = MIN(M,N). The subroutine will compute an integer, KRANK, equal to the number of diagonal terms of R that exceed TAU in magnitude. Then a solution of minimum Euclidean length is computed using the first KRANK rows of (R C). To be specific we suggest that the user consider an easily computable matrix norm, such as, the maximum of all column sums of magnitudes. Now if the relative uncertainty of B is EPS, (norm of uncertainty/ norm of B), it is suggested that TAU be set approximately equal to EPS*(norm of A). The user must dimension all arrays appearing in the call list.. A(MDA,N),(B(MDB,NB) or B(M)),RNORM(NB),H(N),G(N),IP(N). This permits the solution of a range of problems in the same array space. The entire set of parameters for HFTI are INPUT.. A(*,*),MDA,M,N The array A(*,*) initially contains the M by N matrix A of the least squares problem AX = B. The first dimensioning parameter of the array A(*,*) is MDA, which must satisfy MDA.GE.M Either M.GE.N or M.LT.N is permitted. There is no restriction on the rank of A. The condition MDA.LT.M is considered an error. B(*),MDB,NB If NB = 0 the subroutine will perform the orthogonal decomposition but will make no references to the array B(*). If NB.GT.0 the array B(*) must initially contain the M by NB matrix B of the least squares problem AX = B. If NB.GE.2 the array B(*) must be doubly subscripted with first dimensioning parameter MDB.GE.MAX(M,N). If NB = 1 the array B(*) may be either doubly or singly subscripted. In the latter case the value of MDB is arbitrary but it should be set to some valid integer value such as MDB = M. The condition of NB.GT.1.AND.MDB.LT. MAX(M,N) is considered an error. TAU Absolute tolerance parameter provided by user for pseudorank determination. H(*),G(*),IP(*) Arrays of working space used by HFTI. OUTPUT.. A(*,*) The contents of the array A(*,*) will be modified by the subroutine. These contents are not generally required by the user. B(*) On return the array B(*) will contain the N by NB solution matrix X. KRANK Set by the subroutine to indicate the pseudorank of A. RNORM(*) On return, RNORM(J) will contain the Euclidean norm of the residual vector for the problem defined by the J-th column vector of the array B(*,*) for J = 1,...,NB. H(*),G(*) On return these arrays respectively contain elements of the pre- and post-multiplying Householder transformations used to compute the minimum Euclidean length solution. IP(*) Array in which the subroutine records indices describing the permutation of column vectors. The contents of arrays H(*),G(*) and IP(*) are not generally required by the user.
HKSEQ
SUBROUTINE HKSEQ(X,M,H,IERR) HKSEQ is an adaptation of subroutine PSIFN, ACM Trans. Math. Software, 1983 to generate H(K,X)=(-X)**(K+1)*(PSI(K,X)- -PSI(K,X+0.5))/GAMMA(K+1) FOR K=0,...,M.
HQR
SUBROUTINE HQR(NM,N,LOW,IGH,H,WR,WI,IERR) This subroutine is a translation of the ALGOL procedure HQR, NUM. MATH. 14, 219-231(1970) by Martin, Peters, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 359-371(1971). This subroutine finds the eigenvalues of a REAL UPPER Hessenberg matrix by the QR method. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. H contains the upper Hessenberg matrix. Information about the transformations used in the reduction to Hessenberg form by ELMHES or ORTHES, if performed, is stored in the remaining triangle under the Hessenberg matrix. On OUTPUT H has been destroyed. Therefore, it must be saved before calling HQR if subsequent calculation and back transformation of eigenvectors is to be performed. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. The eigenvalues are unordered except that complex conjugate pairs of values appear consecutively with the eigenvalue having the positive imaginary part first. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HQR2
SUBROUTINE HQR2(NM,N,LOW,IGH,H,WR,WI,Z,IERR) This subroutine is a translation of the ALGOL procedure HQR2, NUM. MATH. 16, 181-204(1970) by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971). This subroutine finds the eigenvalues and eigenvectors of a REAL UPPER Hessenberg matrix by the QR method. The eigenvectors of a REAL GENERAL matrix can also be found if ELMHES and ELTRAN or ORTHES and ORTRAN have been used to reduce this general matrix to Hessenberg form and to accumulate the similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. H contains the upper Hessenberg matrix. Z contains the transformation matrix produced by ELTRAN after the reduction by ELMHES, or by ORTRAN after the reduction by ORTHES, if performed. If the eigenvectors of the Hessenberg matrix are desired, Z must contain the identity matrix. On OUTPUT H has been destroyed. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. The eigenvalues are unordered except that complex conjugate pairs of values appear consecutively with the eigenvalue having the positive imaginary part first. If an error exit is made, the eigenvalues should be correct for indices IERR+1,...,N. Z contains the real and imaginary parts of the eigenvectors. If the I-th eigenvalue is real, the I-th column of Z contains its eigenvector. If the I-th eigenvalue is complex with positive imaginary part, the I-th and (I+1)-th columns of Z contain the real and imaginary parts of its eigenvector. The eigenvectors are unnormalized. If an error exit is made, none of the eigenvectors has been found. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after a total of 30*N iterations. Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HSTART
SUBROUTINE HSTART(F,NEQ,A,B,Y,YPRIME,ETOL,MORDER,SMALL,BIG,SPY,
HTRIB3
SUBROUTINE HTRIB3(NM,N,A,TAU,M,ZR,ZI) This subroutine is a translation of a complex analogue of the ALGOL procedure TRBAK3, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine forms the eigenvectors of a COMPLEX HERMITIAN matrix by back transforming those of the corresponding real symmetric tridiagonal matrix determined by HTRID3. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains information about the unitary transformations used in the reduction by HTRID3. TAU contains further information about the transformations. M IS the number of eigenvectors to be back transformed. ZR contains the eigenvectors to be back transformed in its first M columns. On OUTPUT ZR and ZI contain the real and imaginary parts, respectively, of the transformed eigenvectors in their first M columns. NOTE that the last component of each returned vector is real and that vector Euclidean norms are preserved. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HTRIBK
SUBROUTINE HTRIBK(NM,N,AR,AI,TAU,M,ZR,ZI) This subroutine is a translation of a complex analogue of the ALGOL procedure TRBAK1, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine forms the eigenvectors of a COMPLEX HERMITIAN matrix by back transforming those of the corresponding real symmetric tridiagonal matrix determined by HTRIDI. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. AR and AI contain information about the unitary trans- formations used in the reduction by HTRIDI in their full lower triangles except for the diagonal of AR. TAU contains further information about the transformations. M is the number of eigenvectors to be back transformed. ZR contains the eigenvectors to be back transformed in its first M columns. On OUTPUT ZR and ZI contain the real and imaginary parts, respectively, of the transformed eigenvectors in their first M columns. Note that the last component of each returned vector is real and that vector Euclidean norms are preserved. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HTRID3
SUBROUTINE HTRID3(NM,N,A,D,E,E2,TAU) This subroutine is a translation of a complex analogue of the ALGOL procedure TRED3, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine reduces a COMPLEX HERMITIAN matrix, stored as a single square array, to a real symmetric tridiagonal matrix using unitary similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains the lower triangle of the complex hermitian input matrix. The real parts of the matrix elements are stored in the full lower triangle of A, and the imaginary parts are stored in the transposed positions of the strict upper triangle of A. No storage is required for the zero imaginary parts of the diagonal elements. On OUTPUT A contains information about the unitary transformations used in the reduction. D contains the diagonal elements of the the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. TAU contains further information about the transformations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
HTRIDI
SUBROUTINE HTRIDI(NM,N,AR,AI,D,E,E2,TAU) This subroutine is a translation of a complex analogue of the ALGOL procedure TRED1, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine reduces a COMPLEX HERMITIAN matrix to a real symmetric tridiagonal matrix using unitary similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. AR and AI contain the real and imaginary parts, respectively, of the complex hermitian input matrix. Only the lower triangle of the matrix need be supplied. On OUTPUT AR and AI contain information about the unitary trans- formations used in the reduction in their full lower triangles. Their strict upper triangles and the diagonal of AR are unaltered. D contains the diagonal elements of the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. TAU contains further information about the transformations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ICAMAX
INTEGER FUNCTION ICAMAX(N,CX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX --Output-- ICAMAX smallest index (zero if N .LE. 0) Returns the index of the component of CX having the largest sum of magnitudes of real and imaginary parts. ICAMAX = first I, I = 1 to N, to minimize ABS(REAL(CX(1-INCX+I*INCX))) + ABS(IMAG(CX(1-INCX+I*INCX)))
IDAMAX
INTEGER FUNCTION IDAMAX(N,DX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) DX double precision vector with N elements INCX storage spacing between elements of DX --Output-- IDAMAX smallest index (zero if N .LE. 0) Find smallest index of maximum magnitude of double precision DX. IDAMAX = first I, I = 1 to N, to minimize ABS(DX(1-INCX+I*INCX)
IMTQL1
SUBROUTINE IMTQL1(N,D,E,IERR) This subroutine is a translation of the ALGOL procedure IMTQL1, NUM. MATH. 12, 377-383(1968) by Martin and Wilkinson, as modified in NUM. MATH. 15, 450(1970) by Dubrulle. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 241-248(1971). This subroutine finds the eigenvalues of a SYMMETRIC TRIDIAGONAL matrix by the implicit QL method. On INPUT N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. On OUTPUT D contains the eigenvalues in ascending order. If an error exit is made, the eigenvalues are correct and ordered for indices 1,2,...IERR-1, but may not be the smallest eigenvalues. E has been destroyed. IERR is set to ZERO for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
IMTQL2
SUBROUTINE IMTQL2(NM,N,D,E,Z,IERR) This subroutine is a translation of the ALGOL procedure IMTQL2, NUM. MATH. 12, 377-383(1968) by Martin and Wilkinson, as modified in NUM. MATH. 15, 450(1970) by Dubrulle. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 241-248(1971). This subroutine finds the eigenvalues and eigenvectors of a SYMMETRIC TRIDIAGONAL matrix by the implicit QL method. The eigenvectors of a FULL SYMMETRIC matrix can also be found if TRED2 has been used to reduce this full matrix to tridiagonal form. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. Z contains the transformation matrix produced in the reduction by TRED2, if performed. If the eigenvectors of the tridiagonal matrix are desired, Z must contain the identity matrix. On OUTPUT D contains the eigenvalues in ASCENDING order. If an error exit is made, the eigenvalues are correct but UNORDERED for indices 1,2,...,IERR-1. E has been destroyed. Z contains orthonormal eigenvectors of the symmetric tridiagonal (or full) matrix. If an error exit is made, Z contains the eigenvectors associated with the stored eigenvalues. IERR is set to ZERO for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
IMTQLV
SUBROUTINE IMTQLV(N,D,E,E2,W,IND,IERR,RV1) This subroutine is a variant of IMTQL1 which is a translation of ALGOL procedure IMTQL1, NUM. MATH. 12, 377-383(1968) by Martin and Wilkinson, as modified in NUM. MATH. 15, 450(1970) by Dubrulle. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 241-248(1971). This subroutine finds the eigenvalues of a SYMMETRIC TRIDIAGONAL matrix by the implicit QL method and associates with them their corresponding submatrix indices. On INPUT N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E. E2(1) is arbitrary. On OUTPUT D and E are unaltered. Elements of E2, corresponding to elements of E regarded as negligible, have been replaced by zero causing the matrix to split into a direct sum of submatrices. E2(1) is also set to zero. W contains the eigenvalues in ascending order. If an error exit is made, the eigenvalues are correct and ordered for indices 1,2,...IERR-1, but may not be the smallest eigenvalues. IND contains the submatrix indices associated with the corresponding eigenvalues in W -- 1 for eigenvalues belonging to the first submatrix from the top, 2 for those belonging to the second submatrix, etc. IERR is set to ZERO for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. RV1 is a temporary storage array. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
INDXA
SUBROUTINE INDXA(I,IR,IDXA,NA)
INDXB
SUBROUTINE INDXB(I,IR,IDX,IDP)
INDXC
SUBROUTINE INDXC(I,IR,IDXC,NC)
INVIT
SUBROUTINE INVIT(NM,N,A,WR,WI,SELECT,MM,M,Z,IERR,RM1,RV1,RV2) This subroutine is a translation of the ALGOL procedure INVIT by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 418-439(1971). This subroutine finds those eigenvectors of a REAL UPPER Hessenberg matrix corresponding to specified eigenvalues, using inverse iteration. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains the Hessenberg matrix. WR and WI contain the real and imaginary parts, respectively, of the eigenvalues of the matrix. The eigenvalues MUST be stored in a manner IDENTICAL to that of subroutine HQR, which recognizes possible splitting of the matrix. SELECT specifies the eigenvectors to be found. The eigenvector corresponding to the J-th eigenvalue is specified by setting SELECT(J) to .TRUE. MM should be set to an upper bound for the number of columns required to store the eigenvectors to be found. NOTE that two columns are required to store the eigenvector corresponding to a complex eigenvalue. On OUTPUT A and WI are unaltered. WR may have been altered since close eigenvalues are perturbed slightly in searching for independent eigenvectors. SELECT may have been altered. If the elements corresponding to a pair of conjugate complex eigenvalues were each initially set to .TRUE., the program resets the second of the two elements to .FALSE. M is the number of columns actually used to store the eigenvectors. Z contains the real and imaginary parts of the eigenvectors. If the next selected eigenvalue is real, the next column of Z contains its eigenvector. If the eigenvalue is complex, the next two columns of Z contain the real and imaginary parts of its eigenvector. The eigenvectors are normalized so that the component of largest magnitude is 1. Any vector which fails the acceptance test is set to zero. IERR is set to ZERO for normal return, -(2*N+1) if more than MM columns of Z are necessary to store the eigenvectors corresponding to the specified eigenvalues. -K if the iteration corresponding to the K-th value fails, -(N+K) if both error situations occur. RM1, RV1, and RV2 are temporary storage arrays. Note that RM1 is square of dimension N by N and, augmented by two columns of Z, is the transpose of the corresponding ALGOL B array. The ALGOL procedure GUESSVEC appears in INVIT in line. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Calls CDIV for complex division. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
INXCA
SUBROUTINE INXCA(I,IR,IDXA,NA)
INXCB
SUBROUTINE INXCB(I,IR,IDX,IDP)
INXCC
SUBROUTINE INXCC(I,IR,IDXC,NC)
IPLOC
INTEGER FUNCTION IPLOC(LOC,SX,IX) RELATIVE ADDRESS DETERMINATION FUNCTION. REVISED 810306-0800 REVISED YYMMDD-HHMM AUTHORS JOHN A. WISNIEWSKI AND R.J. HANSON GIVEN A VIRTUAL LOCATION, FUNCTION IPLOC() RETURNS THE RELATIVE WORKING MEMORY ADDRESS OF THE VECTOR COMPONENT STORED IN SX(*), IX(*). ANY NECESSARY PAGE SWAPS ARE PERFORMED AUTOMATICALLY FOR THE USER IN THIS FUNCTION SUBPROGRAM. LOC IS THE VIRTUAL ADDRESS OF THE DATA TO BE RETRIEVED. SX(*),IX(*) REPRESENT THE MATRIX WHERE THE DATA IS STORED. EXTERNAL REFERENCES PRWPGE,XERROR
ISAMAX
INTEGER FUNCTION ISAMAX(N,SX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX --Output-- ISAMAX smallest index (zero if N .LE. 0) Find smallest index of maximum magnitude of single precision SX. ISAMAX = first I, I = 1 to N, to minimize ABS(SX(1-INCX+I*INCX)
ISWAP
SUBROUTINE ISWAP(N,IX,INCX,IY,INCY) Extended B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) IX integer vector with N elements INCX storage spacing between elements of IX IY integer vector with N elements INCY storage spacing between elements of IY --Output-- IX input vector IY (unchanged if N .LE. 0) IY input vector IX (unchanged if N .LE. 0) Interchange integer IX and integer IY. For I = 0 to N-1, interchange IX(LX+I*INCX) and IY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
IVOUT
SUBROUTINE IVOUT(N,IX,IFMT,IDIGIT) REVISED FEB. 27, 1981. INTEGER VECTOR OUTPUT ROUTINE. INPUT.. N,IX(*) PRINT THE INTEGER ARRAY IX(I),I=1,...,N, ON OUTPUT UNIT LOUT. THE HEADING IN THE FORTRAN FORMAT STATEMENT IFMT(*), DESCRIBED BELOW, IS PRINTED AS A FIRST STEP. THE COMPONENTS IX(I) ARE INDEXED, ON OUTPUT, IN A PLEASANT FORMAT. IFMT(*) A FORTRAN FORMAT STATEMENT. THIS IS PRINTED ON OUTPUT UNIT LOUT WITH THE VARIABLE FORMAT FORTRAN STATEMENT WRITE(LOUT,IFMT) IDIGIT PRINT UP TO IABS(IDIGIT) DECIMAL DIGITS PER NUMBER. THE SUBPROGRAM WILL CHOOSE THAT INTEGER 4,6,10 OR 14 WHICH WILL PRINT AT LEAST IABS(IDIGIT) NUMBER OF PLACES. IF IDIGIT.LT.0, 72 PRINTING COLUMNS ARE UTILIZED TO WRITE EACH LINE OF OUTPUT OF THE ARRAY IX(*). (THIS CAN BE USED ON MOST TIME-SHARING TERMINALS). IF IDIGIT.GE.0, 133 PRINTING COLUMNS ARE UTILIZED. (THIS CAN BE USED ON MOST LINE PRINTERS). EXAMPLE.. PRINT AN ARRAY CALLED (COSTS OF PURCHASES) OF LENGTH 100 SHOWING 6 DECIMAL DIGITS PER NUMBER. THE USER IS RUNNING ON A TIME-SHARING SYSTEM WITH A 72 COLUMN OUTPUT DEVICE. DIMENSION ICOSTS(100) N = 100 IDIGIT = -6 CALL IVOUT(N,ICOSTS,'(''1COSTS OF PURCHASES'')',IDIGIT) AUTHORS JOHN A. WISNIEWSKI SANDIA LABS ALBUQUERQUE. RICHARD J. HANSON SANDIA LABS ALBUQUERQUE. DATE JULY 27,1978.
J4SAVE
FUNCTION J4SAVE(IWHICH,IVALUE,ISET) Abstract J4SAVE saves and recalls several global variables needed by the library error handling routines. Description of Parameters --Input-- IWHICH - Index of item desired. = 1 Refers to current error number. = 2 Refers to current error control flag. = 3 Refers to current unit number to which error messages are to be sent. (0 means use standard.) = 4 Refers to the maximum number of times any message is to be printed (as set by XERMAX). = 5 Refers to the total number of units to which each error message is to be written. = 6 Refers to the 2nd unit for error messages = 7 Refers to the 3rd unit for error messages = 8 Refers to the 4th unit for error messages = 9 Refers to the 5th unit for error messages IVALUE - The value to be set for the IWHICH-th parameter, if ISET is .TRUE. . ISET - If ISET=.TRUE., the IWHICH-th parameter will BE given the value, IVALUE. If ISET=.FALSE., the IWHICH-th parameter will be unchanged, and IVALUE is a dummy parameter. --Output-- The (old) value of the IWHICH-th parameter will be returned in the function value, J4SAVE. Written by Ron Jones, with SLATEC Common Math Library Subcommittee Adapted from Bell Laboratories PORT Library Error Handler Latest revision --- 1 August 1985
JAIRY
SUBROUTINE JAIRY(X,RX,C,AI,DAI)
LA05AD
SUBROUTINE LA05AD(A,IND,NZ,IA,N,IP,IW,W,G,U) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =D= IN THE NAMES USED HERE. REVISIONS MADE BY R J HANSON, SNLA, AUGUST, 1979. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES DSPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED. IP(I,1),IP(I,2) POINT TO THE START OF ROW/COL I. IW(I,1),IW(I,2) HOLD THE NUMBER OF NON-ZEROS IN ROW/COL I. DURING THE MAIN BODY OF THIS SUBROUTINE THE VECTORS IW(.,3),IW(.,5), IW(.,7) ARE USED TO HOLD DOUBLY LINKED LISTS OF ROWS THAT HAVE NOT BEEN PIVOTAL AND HAVE EQUAL NUMBERS OF NON-ZEROS. IW(.,4),IW(.,6),IW(.,8) HOLD SIMILAR LISTS FOR THE COLUMNS. IW(I,3),IW(I,4) HOLD FIRST ROW/COLUMN TO HAVE I NON-ZEROS OR ZERO IF THERE ARE NONE. IW(I,5), IW(I,6) HOLD ROW/COL NUMBER OF ROW/COL PRIOR TO ROW/COL I IN ITS LIST, OR ZERO IF NONE. IW(I,7), IW(I,8) HOLD ROW/COL NUMBER OF ROW/COL AFTER ROW/COL I IN ITS LIST, OR ZERO IF NONE. FOR ROWS/COLS THAT HAVE BEEN PIVOTAL IW(I,5),IW(I,6) HOLD NEGATION OF POSITION OF ROW/COL I IN THE PIVOTAL ORDERING.
LA05AS
SUBROUTINE LA05AS(A,IND,NZ,IA,N,IP,IW,W,G,U) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =S= IN THE NAMES USED HERE. REVISIONS MADE BY R J HANSON, SNLA, AUGUST, 1979. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES SPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED. IP(I,1),IP(I,2) POINT TO THE START OF ROW/COL I. IW(I,1),IW(I,2) HOLD THE NUMBER OF NON-ZEROS IN ROW/COL I. DURING THE MAIN BODY OF THIS SUBROUTINE THE VECTORS IW(.,3),IW(.,5), IW(.,7) ARE USED TO HOLD DOUBLY LINKED LISTS OF ROWS THAT HAVE NOT BEEN PIVOTAL AND HAVE EQUAL NUMBERS OF NON-ZEROS. IW(.,4),IW(.,6),IW(.,8) HOLD SIMILAR LISTS FOR THE COLUMNS. IW(I,3),IW(I,4) HOLD FIRST ROW/COLUMN TO HAVE I NON-ZEROS OR ZERO IF THERE ARE NONE. IW(I,5), IW(I,6) HOLD ROW/COL NUMBER OF ROW/COL PRIOR TO ROW/COL I IN ITS LIST, OR ZERO IF NONE. IW(I,7), IW(I,8) HOLD ROW/COL NUMBER OF ROW/COL AFTER ROW/COL I IN ITS LIST, OR ZERO IF NONE. FOR ROWS/COLS THAT HAVE BEEN PIVOTAL IW(I,5),IW(I,6) HOLD NEGATION OF POSITION OF ROW/COL I IN THE PIVOTAL ORDERING.
LA05BD
SUBROUTINE LA05BD(A,IND,IA,N,IP,IW,W,G,B,TRANS) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =D= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES DSPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED. IP(I,1),IP(I,2) POINT TO START OF ROW/COLUMN I OF U. IW(I,1),IW(I,2) ARE LENGTHS OF ROW/COL I OF U. IW(.,3),IW(.,4) HOLD ROW/COL NUMBERS IN PIVOTAL ORDER.
LA05BS
SUBROUTINE LA05BS(A,IND,IA,N,IP,IW,W,G,B,TRANS) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =S= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES SPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED. IP(I,1),IP(I,2) POINT TO START OF ROW/COLUMN I OF U. IW(I,1),IW(I,2) ARE LENGTHS OF ROW/COL I OF U. IW(.,3),IW(.,4) HOLD ROW/COL NUMBERS IN PIVOTAL ORDER.
LA05CD
SUBROUTINE LA05CD(A,IND,IA,N,IP,IW,W,G,U,MM) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =D= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES DSPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED.
LA05CS
SUBROUTINE LA05CS(A,IND,IA,N,IP,IW,W,G,U,MM) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =S= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES SPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED.
LA05ED
SUBROUTINE LA05ED(A,IRN,IP,N,IW,IA,REALS) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =D= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES DSPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED.
LA05ES
SUBROUTINE LA05ES(A,IRN,IP,N,IW,IA,REALS) THIS SUBPROGRAM IS A SLIGHT MODIFICATION OF A SUBPROGRAM FROM THE C. 1979 AERE HARWELL LIBRARY. THE NAME OF THE CORRESPONDING HARWELL CODE CAN BE OBTAINED BY DELETING THE FINAL LETTER =S= IN THE NAMES USED HERE. REVISED SEP. 13, 1979. ROYALTIES HAVE BEEN PAID TO AERE-UK FOR USE OF THEIR CODES IN THE PACKAGE GIVEN HERE. ANY PRIMARY USAGE OF THE HARWELL SUBROUTINES REQUIRES A ROYALTY AGREEMENT AND PAYMENT BETWEEN THE USER AND AERE-UK. ANY USAGE OF THE SANDIA WRITTEN CODES SPLP( ) (WHICH USES THE HARWELL SUBROUTINES) IS PERMITTED.
LLSIA
SUBROUTINE LLSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP,KRANK, LLSIA computes the least squares solution(s) to the problem AX=B where A is an M by N matrix with M.GE.N and B is the M by NB matrix of right hand sides. User input bounds on the uncertainty in the elements of A are used to detect numerical rank deficiency. The algorithm employs a row and column pivot strategy to minimize the growth of uncertainty and round-off errors. LLSIA requires (MDA+6)*N + (MDB+1)*NB + M dimensioned space ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** SUBROUTINE LLSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP, 1 KRANK,KSURE,RNORM,W,LW,IWORK,LIW,INFO) Input.. A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). Must have MDA.GE.M and M.GE.N. B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Must have MDB.GE.M. If NB = 0, B is never accessed. ****************************************************************** * * * Note - Use of RE and AE are what make this * * code significantly different from * * other linear least squares solvers. * * However, the inexperienced user is * * advised to set RE=0.,AE=0.,KEY=0. * * * ****************************************************************** RE(),AE(),KEY RE() RE() is a vector of length N such that RE(I) is the maximum relative uncertainty in column I of the matrix A. The values of RE() must be between 0 and 1. A minimum of 10*machine precision will be enforced. AE() AE() is a vector of length N such that AE(I) is the maximum absolute uncertainty in column I of the matrix A. The values of AE() must be greater than or equal to 0. KEY For ease of use, RE and AE may be input as either vectors or scalars. If a scalar is input, the algo- rithm will use that value for each column of A. The parameter key indicates whether scalars or vectors are being input. KEY=0 RE scalar AE scalar KEY=1 RE vector AE scalar KEY=2 RE scalar AE vector KEY=3 RE vector AE vector MODE The integer mode indicates how the routine is to react if rank deficiency is detected. If MODE = 0 return immediately, no solution 1 compute truncated solution 2 compute minimal length solution The inexperienced user is advised to set MODE=0 NP The first NP columns of A will not be interchanged with other columns even though the pivot strategy would suggest otherwise. The inexperienced user is advised to set NP=0. WORK() A real work array dimensioned 5*N. However,if RE or AE have been specified as vectors, dimension WORK 4*N. If both RE and AE have been specified as vectors, dimension WORK 3*N. LW Actual dimension of WORK IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO Is a flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, KRANK, LW, IWORK, LIW, and the first 2*N locations of WORK as output by the original call to LLSIA. MODE must be equal to the value of MODE in the original call. If MODE.LT.2, only the first N locations of WORK are accessed. AE, RE, KEY, and NP are not accessed. Output.. A(,) Contains the upper triangular part of the reduced matrix and the transformation information. It togeth with the first N elements of WORK (see below) completely specify the QR factorization of A. B(,) Contains the N by NB solution matrix for X. KRANK,KSURE The numerical rank of A, based upon the relative and absolute bounds on uncertainty, is bounded above by KRANK and below by KSURE. The algorithm returns a solution based on KRANK. KSURE provides an indication of the precision of the rank. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. WORK() The first N locations of WORK contain values necessary to reproduce the Householder transformatio IWORK() The first N locations contain the order in which the columns of A were used. The next M locations contain the order in which the rows of A were used. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Rank deficient, no solution 1 - Rank deficient, truncated solution 2 - Rank deficient, minimal length solution 3 - Numerical rank 0, zero solution 4 - Rank .LT. NP 5 - Full rank
LMPAR
SUBROUTINE LMPAR(N,R,LDR,IPVT,DIAG,QTB,DELTA,PAR,X,SIGMA,WA1,WA2)
LPDP
SUBROUTINE LPDP(A,MDA,M,N1,N2,PRGOPT,X,WNORM,MODE,WS,IS)
MINFIT
SUBROUTINE MINFIT(NM,M,N,A,W,IP,B,IERR,RV1) This subroutine is a translation of the ALGOL procedure MINFIT, NUM. MATH. 14, 403-420(1970) by Golub and Reinsch. HANDBOOK FOR AUTO. COMP., VOL II-LINEAR ALGEBRA, 134-151(1971). This subroutine determines, towards the solution of the linear T system AX=B, the singular value decomposition A=USV of a real T M by N rectangular matrix, forming U B rather than U. Householder bidiagonalization and a variant of the QR algorithm are used. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. Note that NM must be at least as large as the maximum of M and N. M is the number of rows of A and B. N is the number of columns of A and the order of V. A contains the rectangular coefficient matrix of the system. IP is the number of columns of B. IP can be zero. B contains the constant column matrix of the system if IP is not zero. Otherwise B is not referenced. On OUTPUT A has been overwritten by the matrix V (orthogonal) of the decomposition in its first N rows and columns. If an error exit is made, the columns of V corresponding to indices of correct singular values should be correct. W contains the N (non-negative) singular values of A (the diagonal elements of S). They are UNORDERED. If an error exit is made, the singular values should be correct for indices IERR+1,IERR+2,...,N. T B has been overwritten by U B. If an error exit is made, T the rows of U B corresponding to indices of correct singular values should be correct. IERR is set to Zero for normal return, K if the K-th singular value has not been determined after 30 iterations. RV1 is a temporary storage array. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
MINSO4
SUBROUTINE MINSO4(USOL,IDMN,ZN,ZM,PERTB)
MINSOL
SUBROUTINE MINSOL(USOL,IDMN,ZN,ZM,PERTB)
MPADD
SUBROUTINE MPADD(X,Y,Z)
MPADD2
SUBROUTINE MPADD2(X,Y,Z,Y1,TRUNC)
MPADD3
SUBROUTINE MPADD3(X,Y,S,MED,RE)
MPBLAS
SUBROUTINE MPBLAS(I1)
MPCDM
SUBROUTINE MPCDM(DX,Z)
MPCHK
SUBROUTINE MPCHK(I,J)
MPCMD
SUBROUTINE MPCMD(X,DZ)
MPDIVI
SUBROUTINE MPDIVI(X,IY,Z)
MPERR
SUBROUTINE MPERR
MPMAXR
SUBROUTINE MPMAXR(X)
MPMLP
SUBROUTINE MPMLP(U,V,W,J)
MPMUL
SUBROUTINE MPMUL(X,Y,Z)
MPMUL2
SUBROUTINE MPMUL2(X,IY,Z,TRUNC)
MPMULI
SUBROUTINE MPMULI(X,IY,Z)
MPNZR
SUBROUTINE MPNZR(RS,RE,Z,TRUNC)
MPOVFL
SUBROUTINE MPOVFL(X)
MPSTR
SUBROUTINE MPSTR(X,Y)
MPUNFL
SUBROUTINE MPUNFL(X)
NUMXER
FUNCTION NUMXER(NERR) Abstract NUMXER returns the most recent error number, in both NUMXER and the parameter NERR. Written by Ron Jones, with SLATEC Common Math Library Subcommittee Latest revision --- 7 JUNE 1978
OHTROL
SUBROUTINE OHTROL(Q,N,NRDA,DIAG,IRANK,DIV,TD)
OHTROR
SUBROUTINE OHTROR(Q,N,NRDA,DIAG,IRANK,DIV,TD)
ORTBAK
SUBROUTINE ORTBAK(NM,LOW,IGH,A,ORT,M,Z) This subroutine is a translation of the ALGOL procedure ORTBAK, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). This subroutine forms the eigenvectors of a REAL GENERAL matrix by back transforming those of the corresponding upper Hessenberg matrix determined by ORTHES. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1 and IGH equal to the order of the matrix. A contains information about the orthogonal trans- formations used in the reduction by ORTHES in its strict lower triangle. ORT contains further information about the trans- formations used in the reduction by ORTHES. Only elements LOW through IGH are used. M is the number of columns of Z to be back transformed. Z contains the real and imaginary parts of the eigen- vectors to be back transformed in its first M columns. On OUTPUT Z contains the real and imaginary parts of the transformed eigenvectors in its first M columns. ORT has been altered. NOTE that ORTBAK preserves vector Euclidean norms. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ORTHES
SUBROUTINE ORTHES(NM,N,LOW,IGH,A,ORT) This subroutine is a translation of the ALGOL procedure ORTHES, NUM. MATH. 12, 349-368(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 339-358(1971). Given a REAL GENERAL matrix, this subroutine reduces a submatrix situated in rows and columns LOW through IGH to upper Hessenberg form by orthogonal similarity transformations. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. A contains the input matrix. On OUTPUT A contains the Hessenberg matrix. Information about the orthogonal transformations used in the reduction is stored in the remaining triangle under the Hessenberg matrix. ORT contains further information about the transformations. only elements LOW through IGH are used. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
ORTHO4
SUBROUTINE ORTHO4(USOL,IDMN,ZN,ZM,PERTRB)
ORTHOG
SUBROUTINE ORTHOG(USOL,IDMN,ZN,ZM,PERTRB)
ORTHOL
SUBROUTINE ORTHOL(A,M,N,NRDA,IFLAG,IRANK,ISCALE,DIAG,KPIVOT,
ORTHOR
SUBROUTINE ORTHOR(A,N,M,NRDA,IFLAG,IRANK,ISCALE,DIAG,KPIVOT,
ORTRAN
SUBROUTINE ORTRAN(NM,N,LOW,IGH,A,ORT,Z) This subroutine is a translation of the ALGOL procedure ORTRANS, NUM. MATH. 16, 181-204(1970) by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 372-395(1971). This subroutine accumulates the orthogonal similarity transformations used in the reduction of a REAL GENERAL matrix to upper Hessenberg form by ORTHES. On INPUT NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. LOW and IGH are integers determined by the balancing subroutine BALANC. If BALANC has not been used, set LOW=1, IGH=N. A contains information about the orthogonal trans- formations used in the reduction by ORTHES in its strict lower triangle. ORT contains further information about the trans- formations used in the reduction by ORTHES. only elements LOW through IGH are USED. On OUTPUT Z contains the transformation matrix produced in the reduction by ORTHES. ORT has been altered. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
PASSB
SUBROUTINE PASSB(NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
PASSB2
SUBROUTINE PASSB2(IDO,L1,CC,CH,WA1)
PASSB3
SUBROUTINE PASSB3(IDO,L1,CC,CH,WA1,WA2)
PASSB4
SUBROUTINE PASSB4(IDO,L1,CC,CH,WA1,WA2,WA3)
PASSB5
SUBROUTINE PASSB5(IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
PASSF
SUBROUTINE PASSF(NAC,IDO,IP,L1,IDL1,CC,C1,C2,CH,CH2,WA)
PASSF2
SUBROUTINE PASSF2(IDO,L1,CC,CH,WA1)
PASSF3
SUBROUTINE PASSF3(IDO,L1,CC,CH,WA1,WA2)
PASSF4
SUBROUTINE PASSF4(IDO,L1,CC,CH,WA1,WA2,WA3)
PASSF5
SUBROUTINE PASSF5(IDO,L1,CC,CH,WA1,WA2,WA3,WA4)
PCHCE
SUBROUTINE PCHCE(IC,VC,N,X,H,SLOPE,D,INCFD,IERR) PCHCE: PCHIC End Derivative Setter. Called by PCHIC to set end derivatives as requested by the user. It must be called after interior derivative values have been set. ----- To facilitate two-dimensional applications, includes an increment between successive values of the D-array.
Calling sequence: PARAMETER (INCFD = ...) INTEGER IC(2), N, IERR REAL VC(2), X(N), H(N), SLOPE(N), D(INCFD,N) CALL PCHCE (IC, VC, N, X, H, SLOPE, D, INCFD, IERR) Parameters: IC -- (input) integer array of length 2 specifying desired boundary conditions: IC(1) = IBEG, desired condition at beginning of data. IC(2) = IEND, desired condition at end of data. ( see prologue to PCHIC for details. ) VC -- (input) real array of length 2 specifying desired boundary values. VC(1) need be set only if IC(1) = 2 or 3 . VC(2) need be set only if IC(2) = 2 or 3 . N -- (input) number of data points. (assumes N.GE.2) X -- (input) real array of independent variable values. (the elements of X are assumed to be strictly increasing.) H -- (input) real array of interval lengths. SLOPE -- (input) real array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (input) real array of derivative values at the data points. The value corresponding to X(I) must be stored in D(1+(I-1)*INCFD), I=1(1)N. (output) the value of D at X(1) and/or X(N) is changed, if necessary, to produce the requested boundary conditions. no other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. IERR -- (output) error flag. Normal return: IERR = 0 (no errors). Warning errors: IERR = 1 if IBEG.LT.0 and D(1) had to be adjusted for monotonicity. IERR = 2 if IEND.LT.0 and D(1+(N-1)*INCFD) had to be adjusted for monotonicity. IERR = 3 if both of the above are true. ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: ABS, IABS.PCHCI
SUBROUTINE PCHCI(N,H,SLOPE,D,INCFD) PCHCI: PCHIC Initial Derivative Setter. Called by PCHIC to set derivatives needed to determine a monotone piecewise cubic Hermite interpolant to the data. Default boundary conditions are provided which are compatible with monotonicity. If the data are only piecewise monotonic, the interpolant will have an extremum at each point where monotonicity switches direction. To facilitate two-dimensional applications, includes an increment between successive values of the D-array. The resulting piecewise cubic Hermite function should be identical (within roundoff error) to that produced by PCHIM.
Calling sequence: PARAMETER (INCFD = ...) INTEGER N REAL H(N), SLOPE(N), D(INCFD,N) CALL PCHCI (N, H, SLOPE, D, INCFD) Parameters: N -- (input) number of data points. If N=2, simply does linear interpolation. H -- (input) real array of interval lengths. SLOPE -- (input) real array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (output) real array of derivative values at the data points. If the data are monotonic, these values will determine a a monotone cubic Hermite function. The value corresponding to X(I) is stored in D(1+(I-1)*INCFD), I=1(1)N. No other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: ABS, AMAX1, AMIN1.PCHCS
SUBROUTINE PCHCS(SWITCH,N,H,SLOPE,D,INCFD,IERR) PCHCS: PCHIC Monotonicity Switch Derivative Setter. Called by PCHIC to adjust the values of D in the vicinity of a switch in direction of monotonicity, to produce a more "visually pleasing" curve than that given by PCHIM .
Calling sequence: PARAMETER (INCFD = ...) INTEGER N, IERR REAL SWITCH, H(N), SLOPE(N), D(INCFD,N) CALL PCHCS (SWITCH, N, H, SLOPE, D, INCFD, IERR) Parameters: SWITCH -- (input) indicates the amount of control desired over local excursions from data. N -- (input) number of data points. (assumes N.GT.2 .) H -- (input) real array of interval lengths. SLOPE -- (input) real array of data slopes. If the data are (X(I),Y(I)), I=1(1)N, then these inputs are: H(I) = X(I+1)-X(I), SLOPE(I) = (Y(I+1)-Y(I))/H(I), I=1(1)N-1. D -- (input) real array of derivative values at the data points, as determined by PCHCI. (output) derivatives in the vicinity of switches in direction of monotonicity may be adjusted to produce a more "visually pleasing" curve. The value corresponding to X(I) is stored in D(1+(I-1)*INCFD), I=1(1)N. No other entries in D are changed. INCFD -- (input) increment between successive values in D. This argument is provided primarily for 2-D applications. IERR -- (output) error flag. should be zero. If negative, trouble in PCHSW. (should never happen.) ------- WARNING: This routine does no validity-checking of arguments. ------- Fortran intrinsics used: ABS, AMAX1, AMIN1.PCHDF
REAL FUNCTION PCHDF(K,X,S,IERR) PCHDF: PCHIP Finite Difference Formula Uses a divided difference formulation to compute a K-point approx- imation to the derivative at X(K) based on the data in X and S. Called by PCHCE and PCHSP to compute 3- and 4-point boundary derivative approximations.
On input: K is the order of the desired derivative approximation. K must be at least 3 (error return if not). X contains the K values of the independent variable. X need not be ordered, but the values **MUST** be distinct. (Not checked here.) S contains the associated slope values: S(I) = (F(I+1)-F(I))/(X(I+1)-X(I)), I=1(1)K-1. (Note that S need only be of length K-1.) On return: S will be destroyed. IERR will be set to -1 if K.LT.2 . PCHDF will be set to the desired derivative approximation if IERR=0 or to zero if IERR=-1.
Reference: Carl de Boor, A Practical Guide to Splines, Springer- Verlag (New York, 1978), pp. 10-16.
Programmed by: Fred N. Fritsch, FTS 532-4275, (415) 422-4275, Mathematics and Statistics Division, Lawrence Livermore National Laboratory. Change record: 82-08-05 Converted to SLATEC library version.
Programming notes: To produce a double precision version, simply: a. Change PCHDF to DPCHDF wherever it occurs, b. Change the real declarations to double precision, and c. Change the constant ZERO to double precision.QZHES
SUBROUTINE QZHES(NM,N,A,B,MATZ,Z) This subroutine is the first step of the QZ algorithm for solving generalized matrix eigenvalue problems, SIAM J. NUMER. ANAL. 10, 241-256(1973) by MOLER and STEWART. This subroutine accepts a pair of REAL GENERAL matrices and reduces one of them to upper Hessenberg form and the other to upper triangular form using orthogonal transformations. It is usually followed by QZIT, QZVAL and, possibly, QZVEC. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices. A contains a real general matrix. B contains a real general matrix. MATZ should be set to .TRUE. if the right hand transformations are to be accumulated for later use in computing eigenvectors, and to .FALSE. otherwise. On Output A has been reduced to upper Hessenberg form. The elements below the first subdiagonal have been set to zero. B has been reduced to upper triangular form. The elements below the main diagonal have been set to zero. Z contains the product of the right hand transformations if MATZ has been set to .TRUE. Otherwise, Z is not referenced. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
QZIT
SUBROUTINE QZIT(NM,N,A,B,EPS1,MATZ,Z,IERR) This subroutine is the second step of the QZ algorithm for solving generalized matrix eigenvalue problems, SIAM J. NUMER. ANAL. 10, 241-256(1973) by MOLER and STEWART, as modified in technical note NASA TN D-7305(1973) by WARD. This subroutine accepts a pair of REAL matrices, one of them in upper Hessenberg form and the other in upper triangular form. It reduces the Hessenberg matrix to quasi-triangular form using orthogonal transformations while maintaining the triangular form of the other matrix. It is usually preceded by QZHES and followed by QZVAL and, possibly, QZVEC. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices. A contains a real upper Hessenberg matrix. B contains a real upper triangular matrix. EPS1 is a tolerance used to determine negligible elements. EPS1 = 0.0 (or negative) may be input, in which case an element will be neglected only if it is less than roundoff error times the norm of its matrix. If the input EPS1 is positive, then an element will be considered negligible if it is less than EPS1 times the norm of its matrix. A positive value of EPS1 may result in faster execution, but less accurate results. MATZ should be set to .TRUE. If the right hand transformations are to be accumulated for later use in computing eigenvectors, and to .FALSE. otherwise. Z contains, if MATZ has been set to .TRUE., the transformation matrix produced in the reduction by QZHES, if performed, or else the identity matrix. If MATZ has been set to .FALSE., Z is not referenced. On Output A has been reduced to quasi-triangular form. The elements below the first subdiagonal are still zero and no two consecutive subdiagonal elements are nonzero. B is still in upper triangular form, although its elements have been altered. The location B(N,1) is used to store EPS1 times the norm of B for later use by QZVAL and QZVEC. Z contains the product of the right hand transformations (for both steps) if MATZ has been set to .TRUE. IERR is set to ZERO for normal return, J if neither A(J,J-1) nor A(J-1,J-2) has become zero after a total of 30*N iterations. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
QZVAL
SUBROUTINE QZVAL(NM,N,A,B,ALFR,ALFI,BETA,MATZ,Z) This subroutine is the third step of the QZ algorithm for solving generalized matrix eigenvalue problems, SIAM J. NUMER. ANAL. 10, 241-256(1973) by MOLER and STEWART. This subroutine accepts a pair of REAL matrices, one of them in quasi-triangular form and the other in upper triangular form. It reduces the quasi-triangular matrix further, so that any remaining 2-by-2 blocks correspond to pairs of complex eigenvalues, and returns quantities whose ratios give the generalized eigenvalues. It is usually preceded by QZHES and QZIT and may be followed by QZVEC. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices. A contains a real upper quasi-triangular matrix. B contains a real upper triangular matrix. In addition, location B(N,1) contains the tolerance quantity (EPSB) computed and saved in QZIT. MATZ should be set to .TRUE. If the right hand transformations are to be accumulated for later use in computing eigenvectors, and to .FALSE. otherwise. Z contains, if MATZ has been set to .TRUE., the transformation matrix produced in the reductions by QZHES and QZIT, if performed, or else the identity matrix. If MATZ has been set to .FALSE., Z is not referenced. On Output A has been reduced further to a quasi-triangular matrix in which all nonzero subdiagonal elements correspond to pairs of complex eigenvalues. B is still in upper triangular form, although its elements have been altered. B(N,1) is unaltered. ALFR and ALFI contain the real and imaginary parts of the diagonal elements of the triangular matrix that would be obtained if a were reduced completely to triangular form by unitary transformations. Non-zero values of ALFI occur in pairs, the first member positive and the second negative. BETA contains the diagonal elements of the corresponding B, normalized to be real and non-negative. The generalized eigenvalues are then the ratios ((ALFR+I*ALFI)/BETA). Z contains the product of the right hand transformations (for all three steps) if MATZ has been set to .TRUE. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
QZVEC
SUBROUTINE QZVEC(NM,N,A,B,ALFR,ALFI,BETA,Z) This subroutine is the optional fourth step of the QZ algorithm for solving generalized matrix eigenvalue problems, SIAM J. NUMER. ANAL. 10, 241-256(1973) by MOLER and STEWART. This subroutine accepts a pair of REAL matrices, one of them in quasi-triangular form (in which each 2-by-2 block corresponds to a pair of complex eigenvalues) and the other in upper triangular form. It computes the eigenvectors of the triangular problem and transforms the results back to the original coordinate system. It is usually preceded by QZHES, QZIT, and QZVAL. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices. A contains a real upper quasi-triangular matrix. B contains a real upper triangular matrix. In addition, location B(N,1) contains the tolerance quantity (EPSB) computed and saved in QZIT. ALFR, ALFI, and BETA are vectors with components whose ratios ((ALFR+I*ALFI)/BETA) are the generalized eigenvalues. They are usually obtained from QZVAL. Z contains the transformation matrix produced in the reductions by QZHES, QZIT, and QZVAL, if performed. If the eigenvectors of the triangular problem are desired, Z must contain the identity matrix. On Output A is unaltered. Its subdiagonal elements provide information about the storage of the complex eigenvectors. B has been destroyed. ALFR, ALFI, and BETA are unaltered. Z contains the real and imaginary parts of the eigenvectors. If ALFI(I) .EQ. 0.0, the I-th eigenvalue is real and the I-th column of Z contains its eigenvector. If ALFI(I) .NE. 0.0, the I-th eigenvalue is complex. If ALFI(I) .GT. 0.0, the eigenvalue is the first of a complex pair and the I-th and (I+1)-th columns of Z contain its eigenvector. If ALFI(I) .LT. 0.0, the eigenvalue is the second of a complex pair and the (I-1)-th and I-th columns of Z contain the conjugate of its eigenvector. Each eigenvector is normalized so that the modulus of its largest component is 1.0 . Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RATQR
SUBROUTINE RATQR(N,EPS1,D,E,E2,M,W,IND,BD,TYPE,IDEF,IERR) This subroutine is a translation of the ALGOL procedure RATQR, NUM. MATH. 11, 264-272(1968) by REINSCH and BAUER. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 257-265(1971). This subroutine finds the algebraically smallest or largest eigenvalues of a SYMMETRIC TRIDIAGONAL matrix by the rational QR method with Newton corrections. On Input N is the order of the matrix. EPS1 is a theoretical absolute error tolerance for the computed eigenvalues. If the input EPS1 is non-positive, or indeed smaller than its default value, it is reset at each iteration to the respective default value, namely, the product of the relative machine precision and the magnitude of the current eigenvalue iterate. The theoretical absolute error in the K-th eigenvalue is usually not greater than K times EPS1. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E. E2(1) is arbitrary. M is the number of eigenvalues to be found. IDEF should be set to 1 if the input matrix is known to be positive definite, to -1 if the input matrix is known to be negative definite, and to 0 otherwise. TYPE should be set to .TRUE. if the smallest eigenvalues are to be found, and to .FALSE. If the largest eigenvalues are to be found. On Output EPS1 is unaltered unless it has been reset to its (last) default value. D and E are unaltered (unless W overwrites D). ELEMENTS of E2, corresponding to elements of E regarded as negligible, have been replaced by zero causing the matrix to split into a direct sum of submatrices. E2(1) is set to 0.0e0 if the smallest eigenvalues have been found, and to 2.0e0 if the largest eigenvalues have been found. E2 is otherwise unaltered (unless overwritten by BD). W contains the M algebraically smallest eigenvalues in ascending order, or the M largest eigenvalues in descending order. If an error exit is made because of an incorrect specification of IDEF, no eigenvalues are found. If the Newton iterates for a particular eigenvalue are not monotone, the best estimate obtained is returned and IERR is set. W may coincide with D. IND contains in its first M positions the submatrix indices associated with the corresponding eigenvalues in W -- 1 for eigenvalues belonging to the first submatrix from the top, 2 for those belonging to the second submatrix, etc. BD contains refined bounds for the theoretical errors of the corresponding eigenvalues in W. These bounds are usually within the tolerance specified by EPS1. BD may coincide with E2. IERR is set to Zero for normal return, 6*N+1 if IDEF is set to 1 and type to .TRUE. when the matrix is NOT positive definite, or if IDEF is set to -1 and type to .FALSE. when the matrix is NOT negative definite, 5*N+K if successive iterates to the K-th eigenvalue are NOT monotone increasing, where K refers to the last such occurrence. Note that subroutine TRIDIB is generally faster and more accurate than RATQR if the eigenvalues are clustered. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
REBAK
SUBROUTINE REBAK(NM,N,B,DL,M,Z) This subroutine is a translation of the ALGOL procedure REBAKA, NUM. MATH. 11, 99-110(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 303-314(1971). This subroutine forms the eigenvectors of a generalized SYMMETRIC eigensystem by back transforming those of the derived symmetric matrix determined by REDUC. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix system. B contains information about the similarity transformation (Cholesky decomposition) used in the reduction by REDUC in its strict lower triangle. DL contains further information about the transformation. M is the number of eigenvectors to be back transformed. Z contains the eigenvectors to be back transformed in its first M columns. On Output Z contains the transformed eigenvectors in its first M columns. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
REBAKB
SUBROUTINE REBAKB(NM,N,B,DL,M,Z) This subroutine is a translation of the ALGOL procedure REBAKB, NUM. MATH. 11, 99-110(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 303-314(1971). This subroutine forms the eigenvectors of a generalized SYMMETRIC eigensystem by back transforming those of the derived symmetric matrix determined by REDUC2. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix system. B contains information about the similarity transformation (cholesky decomposition) used in the reduction by REDUC2 in its strict lower triangle. DL contains further information about the transformation. M is the number of eigenvectors to be back transformed. Z contains the eigenvectors to be back transformed in its first M columns. On Output Z contains the transformed eigenvectors in its first M columns. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
REDUC
SUBROUTINE REDUC(NM,N,A,B,DL,IERR) This subroutine is a translation of the ALGOL procedure REDUC1, NUM. MATH. 11, 99-110(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 303-314(1971). This subroutine reduces the generalized SYMMETRIC eigenproblem Ax=(LAMBDA)Bx, where B is POSITIVE DEFINITE, to the standard symmetric eigenproblem using the Cholesky factorization of B. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. If the Cholesky factor L of B is already available, N should be prefixed with a minus sign. A and B contain the real symmetric input matrices. Only the full upper triangles of the matrices need be supplied. If N is negative, the strict lower triangle of B contains, instead, the strict lower triangle of its Cholesky factor L. DL contains, if N is negative, the diagonal elements of L. On Output A contains in its full lower triangle the full lower triangle of the symmetric matrix derived from the reduction to the standard form. The strict upper triangle of A is unaltered. B contains in its strict lower triangle the strict lower triangle of its Cholesky factor L. The full upper triangle of B is unaltered. DL contains the diagonal elements of L. IERR is set to Zero for normal return, 7*N+1 if B is not positive definite. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
REDUC2
SUBROUTINE REDUC2(NM,N,A,B,DL,IERR) This subroutine is a translation of the ALGOL procedure REDUC2, NUM. MATH. 11, 99-110(1968) by Martin and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 303-314(1971). This subroutine reduces the generalized SYMMETRIC eigenproblems ABx=(LAMBDA)x OR BAy=(LAMBDA)y, where B is POSITIVE DEFINITE, to the standard symmetric eigenproblem using the Cholesky factorization of B. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. If the Cholesky factor L of B is already available, N should be prefixed with a minus sign. A AND B contain the real symmetric input matrices. Only the full upper triangles of the matrices need be supplied. If N is negative, the strict lower triangle of B contains, instead, the strict lower triangle of its Cholesky factor L. DL contains, if N is negative, the diagonal elements of L. On Output A contains in its full lower triangle the full lower triangle of the symmetric matrix derived from the reduction to the standard form. The strict upper triangle of A is unaltered. B contains in its strict lower triangle the strict lower triangle of its Cholesky factor L. The full upper triangle of B is unaltered. DL contains the diagonal elements of L. IERR is set to Zero for normal return, 7*N+1 if B is not positive definite. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
REORT
SUBROUTINE REORT(NCOMP,Y,YP,YHP,NIV,W,S,P,IP,STOWA,IFLAG)
RG
SUBROUTINE RG(NM,N,A,WR,WI,MATZ,Z,IV1,FV1,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) To find the eigenvalues and eigenvectors (if desired) of a REAL GENERAL matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A. A contains the real general matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output WR and WI contain the real and imaginary parts, respectively, of the eigenvalues. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having the positive imaginary part first. Z contains the real and imaginary parts of the eigenvectors if MATZ is not zero. If the J-th eigenvalue is real, the J-th column of Z contains its eigenvector. If the J-TH eigenvalue is complex with positive imaginary part, the J-th and (J+1)-th columns of Z contain the real and imaginary parts of its eigenvector. The conjugate of this vector is the eigenvector for the conjugate eigenvalue. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. IV1 and FV1 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RGG
SUBROUTINE RGG(NM,N,A,B,ALFR,ALFI,BETA,MATZ,Z,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) for the REAL GENERAL GENERALIZED eigenproblem Ax = (LAMBDA)Bx. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. A contains a real general matrix. B contains a real general matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output ALFR and ALFI contain the real and imaginary parts, respectively, of the numerators of the eigenvalues. BETA contains the denominators of the eigenvalues, which are thus given by the ratios (ALFR+I*ALFI)/BETA. Complex conjugate pairs of eigenvalues appear consecutively with the eigenvalue having the positive imaginary part first. Z contains the real and imaginary parts of the eigenvectors if MATZ is not zero. If the J-th eigenvalue is real, the J-th column of Z contains its eigenvector. If the J-th eigenvalue is complex with positive imaginary part, the J-th and (J+1)-th columns of Z contain the real and imaginary parts of its eigenvector. The conjugate of this vector is the eigenvector for the conjugate eigenvalue. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RS
SUBROUTINE RS(NM,N,A,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a REAL SYMMETRIC matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A. A contains the real symmetric matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RSB
SUBROUTINE RSB(NM,N,MB,A,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a REAL SYMMETRIC BAND matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A. MB is the half band width of the matrix, defined as the number of adjacent diagonals, including the principal diagonal, required to specify the non-zero portion of the lower triangle of the matrix. A contains the lower triangle of the real symmetric band matrix. Its lowest subdiagonal is stored in the last N+1-MB positions of the first column, its next subdiagonal in the last N+2-MB positions of the second column, further subdiagonals similarly, and finally its principal diagonal in the N positions of the last column. Contents of storages not part of the matrix are arbitrary. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RSCO
SUBROUTINE RSCO(RSAV,ISAV)
RSG
SUBROUTINE RSG(NM,N,A,B,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) To find the eigenvalues and eigenvectors (if desired) for the REAL SYMMETRIC generalized eigenproblem Ax = (LAMBDA)Bx. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. A contains a real symmetric matrix. B contains a positive definite real symmetric matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not ZERO. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RSGAB
SUBROUTINE RSGAB(NM,N,A,B,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) for the REAL SYMMETRIC generalized eigenproblem ABx = (LAMBDA)x. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. A contains a real symmetric matrix. B contains a positive definite real symmetric matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RSGBA
SUBROUTINE RSGBA(NM,N,A,B,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) for the REAL SYMMETRIC generalized eigenproblem BAx = (LAMBDA)x. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrices A and B. A contains a real symmetric matrix. B contains a positive definite real symmetric matrix. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RSP
SUBROUTINE RSP(NM,N,NV,A,W,MATZ,Z,FV1,FV2,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a REAL SYMMETRIC PACKED matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A. NV is an integer variable set equal to the dimension of the array A as specified for A in the calling program. NV must not be less than N*(N+1)/2. A contains the lower triangle of the real symmetric packed matrix stored row-wise. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B OF the documentation. The normal completion code is zero. FV1 and FV2 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RST
SUBROUTINE RST(NM,N,W,E,MATZ,Z,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a REAL SYMMETRIC TRIDIAGONAL matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. W contains the diagonal elements of the real symmetric tridiagonal matrix. E contains the subdiagonal elements of the matrix in its last N-1 POSITIONS. E(1) is arbitrary. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
RT
SUBROUTINE RT(NM,N,A,W,MATZ,Z,FV1,IERR) This subroutine calls the recommended sequence of subroutines from the eigensystem subroutine package (EISPACK) to find the eigenvalues and eigenvectors (if desired) of a special REAL TRIDIAGONAL matrix. On Input NM must be set to the row dimension of the two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix A. A contains the special real tridiagonal matrix in its first three columns. The subdiagonal elements are stored in the last N-1 positions of the first column, the diagonal elements in the second column, and the superdiagonal elements in the first N-1 positions of the third column. elements A(1,1) and A(N,3) are arbitrary. MATZ is an integer variable set equal to zero if only eigenvalues are desired. Otherwise it is set to any non-zero integer for both eigenvalues and eigenvectors. On Output W contains the eigenvalues in ascending order. Z contains the eigenvectors if MATZ is not zero. IERR is an integer output variable set equal to an error completion code described in section 2B of the documentation. The normal completion code is zero. FV1 is a temporary storage array. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
SASUM
REAL FUNCTION SASUM(N,SX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(S) SX single precision vector with N elements INCX storage spacing between elements of SX --Output-- SASUM single precision result (zero if N .LE. 0) Returns sum of magnitudes of single precision SX. SASUM = sum from 0 to N-1 of ABS(SX(1+I*INCX))
SAXPY
SUBROUTINE SAXPY(N,SA,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SA single precision scalar multiplier SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- SY single precision result (unchanged if N .LE. 0) Overwrite single precision SY with single precision SA*SX +SY. For I = 0 to N-1, replace SY(LY+I*INCY) with SA*SX(LX+I*INCX) + SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N and LY is defined in a similar way using INCY.
SCASUM
FUNCTION SCASUM(N,CX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX --Output-- SCASUM single precision result (zero if N .LE. 0) Returns sums of magnitudes of real and imaginary parts of components of CX. Note that this is not the L1 norm of CX. CASUM = sum from 0 to N-1 of ABS(REAL(CX(1+I*INCX))) + ABS(IMAG(CX(1+I*INCX)))
SCHDC
SUBROUTINE SCHDC(A,LDA,P,WORK,JPVT,JOB,INFO) SCHDC computes the Cholesky decomposition of a positive definite matrix. A pivoting option allows the user to estimate the condition of a positive definite matrix or determine the rank of a positive semidefinite matrix. On Entry A REAL(LDA,P). A contains the matrix whose decomposition is to be computed. Only the upper half of A need be stored. The lower part of the array A is not referenced. LDA INTEGER. LDA is the leading dimension of the array A. P INTEGER. P is the order of the matrix. WORK REAL. WORK is a work array. JPVT INTEGER(P). JPVT contains integers that control the selection of the pivot elements, if pivoting has been requested. Each diagonal element A(K,K) is placed in one of three classes according to the value of JPVT(K). If JPVT(K) .GT. 0, then X(K) is an initial element. If JPVT(K) .EQ. 0, then X(K) is a free element. If JPVT(K) .LT. 0, then X(K) is a final element. Before the decomposition is computed, initial elements are moved by symmetric row and column interchanges to the beginning of the array A and final elements to the end. Both initial and final elements are frozen in place during the computation and only free elements are moved. At the K-th stage of the reduction, if A(K,K) is occupied by a free element it is interchanged with the largest free element A(L,L) with L .GE. K. JPVT is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. If JOB .EQ. 0, no pivoting is done. If JOB .NE. 0, pivoting is done. On Return A A contains in its upper half the Cholesky factor of the matrix A as it has been permuted by pivoting. JPVT JPVT(J) contains the index of the diagonal element of a that was moved into the J-th position, provided pivoting was requested. INFO contains the index of the last positive diagonal element of the Cholesky factor. For positive definite matrices INFO = P is the normal return. For pivoting with positive semidefinite matrices INFO will in general be less than P. However, INFO may be greater than the rank of A, since rounding error can cause an otherwise zero element to be positive. Indefinite systems will always cause INFO to be less than P. LINPACK. This version dated 03/19/79 . J. J. Dongarra and G. W. Stewart, Argonne National Laboratory and University of Maryland. BLAS SAXPY,SSWAP Fortran SQRT
SCHDD
SUBROUTINE SCHDD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S,INFO) SCHDD downdates an augmented Cholesky decomposition or the triangular factor of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, SCHDD determines an orthogonal matrix U and a scalar ZETA such that (R Z ) (RR ZZ) U * ( ) = ( ) , (0 ZETA) ( X Y) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) removed. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the downdated problem is SQRT(RHO**2 - ZETA**2). SCHDD will simultaneously downdate several triplets (Z,Y,RHO) along with R. For a less terse description of what SCHDD does and how it may be applied, see the LINPACK guide. The matrix U is determined as the product U(1)*...*U(P) where U(I) is a rotation in the (P+1,I)-plane of the form ( C(I) -S(I) ) ( ) . ( S(I) C(I) ) The rotations are chosen so that C(I) is real. The user is warned that a given downdating problem may be impossible to accomplish or may produce inaccurate results. For example, this can happen if X is near a vector whose removal will reduce the rank of R. Beware. On Entry R REAL(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be downdated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. X REAL(P). X contains the row vector that is to be removed from R. X is not altered by SCHDD. Z REAL(LDZ,NZ), where LDZ .GE. P. Z is an array of NZ P-vectors which are to be downdated along with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be downdated NZ may be zero, in which case Z, Y, and RHO are not referenced. Y REAL(NZ). Y contains the scalars for the downdating of the vectors Z. Y is not altered by SCHDD. RHO REAL(NZ). RHO contains the norms of the residual vectors that are to be downdated. On Return R Z contain the downdated quantities. RHO C REAL(P). C contains the cosines of the transforming rotations. S REAL(P). S contains the sines of the transforming rotations. INFO INTEGER. INFO is set as follows. INFO = 0 if the entire downdating was successful. INFO =-1 if R could not be downdated. In this case, all quantities are left unaltered. INFO = 1 if some RHO could not be downdated. The offending RHOs are set to -1. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. SCHDD uses the following functions and subprograms. Fortran ABS BLAS SDOT, SNRM2
SCHEX
SUBROUTINE SCHEX(R,LDR,P,K,L,Z,LDZ,NZ,C,S,JOB) SCHEX updates the Cholesky factorization A = TRANS(R)*R of a positive definite matrix A of order P under diagonal permutations of the form TRANS(E)*A*E where E is a permutation matrix. Specifically, given an upper triangular matrix R and a permutation matrix E (which is specified by K, L, and JOB), SCHEX determines an orthogonal matrix U such that U*R*E = RR, where RR is upper triangular. At the users option, the transformation U will be multiplied into the array Z. If A = TRANS(X)*X, so that R is the triangular part of the QR factorization of X, then RR is the triangular part of the QR factorization of X*E, i.e., X with its columns permuted. For a less terse description of what SCHEX does and how it may be applied, see the LINPACK guide. The matrix Q is determined as the product U(L-K)*...*U(1) of plane rotations of the form ( C(I) S(I) ) ( ) , ( -S(I) C(I) ) where C(I) is real. The rows these rotations operate on are described below. There are two types of permutations, which are determined by the value of JOB. 1. Right circular shift (JOB = 1). The columns are rearranged in the following order. 1,...,K-1,L,K,K+1,...,L-1,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (L-I,L-I+1)-plane. 2. Left circular shift (JOB = 2). The columns are rearranged in the following order 1,...,K-1,K+1,K+2,...,L,K,L+1,...,P. U is the product of L-K rotations U(I), where U(I) acts in the (K+I-1,K+I)-plane. On Entry R REAL(LDR,P), where LDR .GE. P. R contains the upper triangular factor that is to be updated. Elements of R below the diagonal are not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. K INTEGER. K is the first column to be permuted. L INTEGER. L is the last column to be permuted. L must be strictly greater than K. Z REAL(LDZ,NZ), where LDZ.GE.P. Z is an array of NZ P-vectors into which the transformation U is multiplied. Z is not referenced if NZ = 0. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of columns of the matrix Z. JOB INTEGER. JOB determines the type of permutation. JOB = 1 right circular shift. JOB = 2 left circular shift. On Return R contains the updated factor. Z contains the updated matrix Z. C REAL(P). C contains the cosines of the transforming rotations. S REAL(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. SCHEX uses the following functions and subroutines. BLAS SROTG Fortran MIN0
SCHUD
SUBROUTINE SCHUD(R,LDR,P,X,Z,LDZ,NZ,Y,RHO,C,S) SCHUD updates an augmented Cholesky decomposition of the triangular part of an augmented QR decomposition. Specifically, given an upper triangular matrix R of order P, a row vector X, a column vector Z, and a scalar Y, SCHUD determines a unitary matrix U and a scalar ZETA such that (R Z) (RR ZZ ) U * ( ) = ( ) , (X Y) ( 0 ZETA) where RR is upper triangular. If R and Z have been obtained from the factorization of a least squares problem, then RR and ZZ are the factors corresponding to the problem with the observation (X,Y) appended. In this case, if RHO is the norm of the residual vector, then the norm of the residual vector of the updated problem is SQRT(RHO**2 + ZETA**2). SCHUD will simultaneously update several triplets (Z,Y,RHO). For a less terse description of what SCHUD does and how it may be applied, see the LINPACK guide. The matrix U is determined as the product U(P)*...*U(1), where U(I) is a rotation in the (I,P+1) plane of the form ( C(I) S(I) ) ( ) . ( -S(I) C(I) ) The rotations are chosen so that C(I) is real. On Entry R REAL(LDR,P), where LDR .GE. P. R contains the upper triangular matrix that is to be updated. The part of R below the diagonal is not referenced. LDR INTEGER. LDR is the leading dimension of the array R. P INTEGER. P is the order of the matrix R. X REAL(P). X contains the row to be added to R. X is not altered by SCHUD. Z REAL(LDZ,NZ), where LDZ .GE. P. Z is an array containing NZ P-vectors to be updated with R. LDZ INTEGER. LDZ is the leading dimension of the array Z. NZ INTEGER. NZ is the number of vectors to be updated. NZ may be zero, in which case Z, Y, and RHO are not referenced. Y REAL(NZ). Y contains the scalars for updating the vectors Z. Y is not altered by SCHUD. RHO REAL(NZ). RHO contains the norms of the residual vectors that are to be updated. If RHO(J) is negative, it is left unaltered. On Return RC RHO contain the updated quantities. Z C REAL(P). C contains the cosines of the transforming rotations. S REAL(P). S contains the sines of the transforming rotations. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. SCHUD uses the following functions and subroutines. Extended BLAS SROTG Fortran SQRT
SCLOSM
SUBROUTINE SCLOSM(IPAGE) 1. UNLOAD, RELEASE, OR CLOSE UNIT NUMBER IPAGEF. THIS IS FORTRAN 77 STANDARD FOR THE 'CLOSE' STATEMENT.
SCNRM2
REAL FUNCTION SCNRM2(N,CX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) CX complex vector with N elements INCX storage spacing between elements of CX --Output-- SCNRM2 single precision result (zero if N .LE. 0) unitary norm of the complex N-vector stored in CX() with storage increment INCX . If N .LE. 0, return with result = 0. If N .GE. 1, then INCX must be .GE. 1 C. L. Lawson, 1978 Jan 08 Four phase method using two built-in constants that are hopefully applicable to all machines. CUTLO = maximum of SQRT(U/EPS) over all known machines. CUTHI = minimum of SQRT(V) over all known machines. where EPS = smallest no. such that EPS + 1. .GT. 1. U = smallest positive no. (underflow limit) V = largest no. (overflow limit) Brief outline of algorithm.. Phase 1 scans zero components. Move to phase 2 when a component is nonzero and .LE. CUTLO Move to phase 3 when a component is .GT. CUTLO Move to phase 4 when a component is .GE. CUTHI/M where M = N for X() real and M = 2*N for complex. Values for CUTLO and CUTHI.. From the environmental parameters listed in the IMSL converter document the limiting values are as follows.. CUTLO, S.P. U/EPS = 2**(-102) for Honeywell. Close seconds are Univac and DEC at 2**(-103) Thus CUTLO = 2**(-51) = 4.44089E-16 CUTHI, S.P. V = 2**127 for Univac, Honeywell, and DEC. Thus CUTHI = 2**(63.5) = 1.30438E19 CUTLO, D.P. U/EPS = 2**(-67) for Honeywell and DEC. Thus CUTLO = 2**(-33.5) = 8.23181D-11 CUTHI, D.P. same as S.P. CUTHI = 1.30438D19 SAVE CUTLO, CUTHI, ZERO, ONE DATA CUTLO, CUTHI / 8.232D-11, 1.304D19 / DATA CUTLO, CUTHI / 4.441E-16, 1.304E19 /
SCOEF
SUBROUTINE SCOEF(YH,YP,NCOMP,NROWB,NFC,NIC,B,BETA,COEF,INHOMO,RE,
SCOPY
SUBROUTINE SCOPY(N,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- SY copy of vector SX (unchanged if N .LE. 0) Copy single precision SX to single precision SY. For I = 0 to N-1, copy SX(LX+I*INCX) to SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
SCOPYM
SUBROUTINE SCOPYM(N,SX,INCX,SY,INCY) Description of Parameters The * Flags Output Variables N Number of elements in vector(s) SX Real vector with N elements INCX Storage spacing between elements of SX SY* Real negative copy of SX INCY Storage spacing between elements of SY *** Note that SY = -SX *** Copy negative of real SX to real SY. For I=0 to N-1, copy -SX(LX+I*INCX) to SY(LY+I*INCY), where LX=1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
SDOT
REAL FUNCTION SDOT(N,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- SDOT single precision dot product (zero if N .LE. 0) Returns the dot product of single precision SX and SY. SDOT = sum for I = 0 to N-1 of SX(LX+I*INCX) * SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
SDSDOT
REAL FUNCTION SDSDOT(N,SB,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SB single precision scalar to be added to inner product SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- SDSDOT single precision dot product (zero if N .LE. 0) Returns S.P. result with dot product accumulated in D.P. SDSDOT = SB + sum for I = 0 to N-1 of SX(LX+I*INCX)*SY(LY+I*INCY) where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
SGBCO
SUBROUTINE SGBCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) SBGCO factors a real band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, SGBFA is slightly faster. To solve A*X = B , follow SBGCO by SGBSL. To compute INVERSE(A)*C , follow SBGCO by SGBSL. To compute DETERMINANT(A) , follow SBGCO by SGBDI. On Entry ABD REAL(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) M = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(N, J+ML) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABD should contain * * * + + + , * = not used * * 13 24 35 46 , + = used for pivoting * 12 23 34 45 56 11 22 33 44 55 66 21 32 43 54 65 * LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SGBFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,MAX0,MIN0,SIGN
SGBDI
SUBROUTINE SGBDI(ABD,LDA,N,ML,MU,IPVT,DET) SGBDI computes the determinant of a band matrix using the factors computed by SBGCO or SGBFA. If the inverse is needed, use SGBSL N times. On Entry ABD REAL(LDA, N) the output from SBGCO or SGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from SBGCO or SGBFA. On Return DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions Fortran ABS
SGBFA
SUBROUTINE SGBFA(ABD,LDA,N,ML,MU,IPVT,INFO) SGBFA factors a real band matrix by elimination. SGBFA is usually called by SBGCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD REAL(LDA, N) contains the matrix in band storage. The columns of the matrix are stored in the columns of ABD and the diagonals of the matrix are stored in rows ML+1 through 2*ML+MU+1 of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. 2*ML + MU + 1 . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABD an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U , where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that SGBSL will divide by zero if called. Use RCOND in SBGCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) M = ML + MU + 1 DO 20 J = 1, N I1 = MAX0(1, J-MU) I2 = MIN0(N, J+ML) DO 10 I = I1, I2 K = I - J + M ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses rows ML+1 through 2*ML+MU+1 of ABD . In addition, the first ML rows in ABD are used for elements generated during the triangularization. The total number of rows needed in ABD is 2*ML+MU+1 . The ML+MU by ML+MU upper left triangle and the ML by ML lower right triangle are not referenced. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL,ISAMAX Fortran MAX0,MIN0
SGBSL
SUBROUTINE SGBSL(ABD,LDA,N,ML,MU,IPVT,B,JOB) SGBSL solves the real band system A * X = B or TRANS(A) * X = B using the factors computed by SBGCO or SGBFA. On Entry ABD REAL(LDA, N) the output from SBGCO or SGBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from SBGCO or SGBFA. B REAL(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve TRANS(A)*X = B , where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if SBGCO has set RCOND .GT. 0.0 or SGBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SBGCO(ABD,LDA,N,ML,MU,IPVT,RCOND,Z) If (RCOND is too small) GO TO ... DO 10 J = 1, P CALL SGBSL(ABD,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT Fortran MIN0
SGECO
SUBROUTINE SGECO(A,LDA,N,IPVT,RCOND,Z) SGECO factors a real matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, SGEFA is slightly faster. To solve A*X = B , follow SGECO by SGESL. To compute INVERSE(A)*C , follow SGECO by SGESL. To compute DETERMINANT(A) , follow SGECO by SGEDI. To compute INVERSE(A) , follow SGECO by SGEDI. On Entry A REAL(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U , where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SGEFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,SIGN
SGEDI
SUBROUTINE SGEDI(A,LDA,N,IPVT,DET,WORK,JOB) SGEDI computes the determinant and inverse of a matrix using the factors computed by SGECO or SGEFA. On Entry A REAL(LDA, N) the output from SGECO or SGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from SGECO or SGEFA. WORK REAL(N) work vector. Contents destroyed. JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A inverse of original matrix if requested. Otherwise unchanged. DET REAL(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if SGECO has set RCOND .GT. 0.0 or SGEFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL,SSWAP Fortran ABS,MOD
SGEEV
SUBROUTINE SGEEV(A,LDA,N,E,V,LDV,WORK,JOB,INFO) LICEPACK. This version dated 08/08/80. David Kahaner, Cleve Moler, G. W. Stewart, N.B.S. U.N.M. N.B.S./U.MD. Abstract SGEEV computes the eigenvalues and, optionally, the eigenvectors of a general real matrix. Call Sequence Parameters- (The values of parameters marked with * (star) will be changed by SGEEV.) A* REAL(LDA,N) real nonsymmetric input matrix. LDA INTEGER set by the user to the leading dimension of the real array A. N INTEGER set by the user to the order of the matrices A and V, and the number of elements in E. E* COMPLEX(N) on return from SGEEV, E contains the eigenvalues of A. See also INFO below. V* COMPLEX(LDV,N) on return from SGEEV, if the user has set JOB = 0 V is not referenced. = nonzero the N eigenvectors of A are stored in the first N columns of V. See also INFO below. (Note that if the input matrix A is nearly degenerate, V may be badly conditioned, i.e., may have nearly dependent columns.) LDV INTEGER set by the user to the leading dimension of the array V if JOB is also set nonzero. In that case, N must be .LE. LDV. If JOB is set to zero, LDV is not referenced. WORK* REAL(2N) temporary storage vector. Contents changed by SGEEV. JOB INTEGER set by the user to = 0 eigenvalues only to be calculated by SGEEV. Neither V nor LDV is referenced. = nonzero eigenvalues and vectors to be calculated. In this case, A & V must be distinct arrays. Also, if LDA .GT. LDV, SGEEV changes all the elements of A thru column N. If LDA < LDV, SGEEV changes all the elements of V through column N. If LDA = LDV, only A(I,J) and V(I, J) for I,J = 1,...,N are changed by SGEEV. INFO* INTEGER on return from SGEEV the value of INFO is = 0 normal return, calculation successful. = K if the eigenvalue iteration fails to converge, eigenvalues K+1 through N are correct, but no eigenvectors were computed even if they were requested (JOB nonzero). Error Messages No. 1 recoverable N is greater than LDA No. 2 recoverable N is less than one. No. 3 recoverable JOB is nonzero and N is greater than LDV No. 4 warning LDA > LDV, elements of A other than the N by N input elements have been changed. No. 5 warning LDA < LDV, elements of V other than the N x N output elements have been changed. Subroutines used EISPACK- BALANC,BALBAK, ORTHES, ORTRAN, HQR, HQR2 BLAS- SCOPY, SCOPYM SLATEC- XERROR
SGEFA
SUBROUTINE SGEFA(A,LDA,N,IPVT,INFO) SGEFA factors a real matrix by Gaussian elimination. SGEFA is usually called by SGECO, but it can be called directly with a saving in time if RCOND is not needed. (Time for SGECO) = (1 + 9/N)*(Time for SGEFA) . On Entry A REAL(LDA, N) the matrix to be factored. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix and the multipliers which were used to obtain it. The factorization can be written A = L*U , where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that SGESL or SGEDI will divide by zero if called. Use RCOND in SGECO for a reliable indication of singularity. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL,ISAMAX
SGEFS
SUBROUTINE SGEFS(A,LDA,N,V,ITASK,IND,WORK,IWORK) Subroutine SGEFS solves a general NxN system of single precision linear equations using LINPACK subroutines SGECO and SGESL. That is, if A is an NxN real matrix and if X and B are real N-vectors, then SGEFS solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by SGEFS in this case. Argument Description *** A REAL(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. on return, an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. The first N elements of the array A are the elements of the first column of the matrix A. N must be greater than or equal to 1. (terminal error message IND=-2) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 see error message corresponding to IND below. WORK REAL(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SGEIR
SUBROUTINE SGEIR(A,LDA,N,V,ITASK,IND,WORK,IWORK) Subroutine SGEIR solves a general NxN system of single precision linear equations using LINPACK subroutines SGEFA and SGESL. One pass of iterative refinement is used only to obtain an estimate of the accuracy. That is, if A is an NxN real matrix and if X and B are real N-vectors, then SGEIR solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to calculate the solution, X. Then the residual vector is found and used to calculate an estimate of the relative error, IND. IND estimates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to solve only (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N, WORK, and IWORK must not have been altered by the user following factorization (ITASK=1). IND will not be changed by SGEIR in this case. Argument Description *** A REAL(LDA,N) the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. A is not altered by the routine. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. The first N elements of the array A are the elements of the first column of matrix A. N must be greater than or equal to 1. (terminal error message IND=-2) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A (stored in WORK). If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. IND=75 means that the solution vector X is zero. LT. 0 see error message corresponding to IND below. WORK REAL(N*(N+1)) a singly subscripted array of dimension at least N*(N+1). IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than one. IND=-3 terminal ITASK is less than one. IND=-4 terminal The matrix A is computationally singular. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SGESL
SUBROUTINE SGESL(A,LDA,N,IPVT,B,JOB) SGESL solves the real system A * X = B or TRANS(A) * X = B using the factors computed by SGECO or SGEFA. On Entry A REAL(LDA, N) the output from SGECO or SGEFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . IPVT INTEGER(N) the pivot vector from SGECO or SGEFA. B REAL(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B , = nonzero to solve TRANS(A)*X = B where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is often caused by improper arguments or improper setting of LDA . It will not occur if the subroutines are called correctly and if SGECO has set RCOND .GT. 0.0 or SGEFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SGECO(A,LDA,N,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL SGESL(A,LDA,N,IPVT,C(1,J),0) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT
SGLSS
SUBROUTINE SGLSS(A,MDA,M,N,B,MDB,NB,RNORM,WORK,LW,IWORK,LIW,INFO) SGLSS solves both underdetermined and overdetermined LINEAR systems AX = B, where A is an M by N matrix and B is an M by NB matrix of right hand sides. If M.GE.N, the least squares solution is computed by decomposing the matrix A into the product of an orthogonal matrix Q and an upper triangular matrix R (QR factorization). If M.LT.N, the minimal length solution is computed by factoring the matrix A into the product of a lower triangular matrix L and an orthogonal matrix Q (LQ factor- ization). If the matrix A is determined to be rank deficient, that is the rank of A is less than MIN(M,N), then the minimal length least squares solution is computed. SGLSS assumes full machine precision in the data. If more control over the uncertainty in the data is desired, the codes LLSIA and ULSIA are recommended. SGLSS requires MDA*N + (MDB + 1)*NB + 5*MIN(M,N) dimensioned real space and M+N dimensioned integer space. ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** SUBROUTINE SGLSS(A,MDA,M,N,B,MDB,NB,RNORM,WORK,LW,IWORK,LIW,INFO) Input.. A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Must have MDB.GE.MAX(M,N). If NB = 0, B is never accessed. RNORM() Vector of length at least NB. On input the contents of RNORM are unused. WORK() A real work array dimensioned 5*MIN(M,N). LW Actual dimension of WORK. IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO A flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, INFO, LW, IWORK, LIW, and the first 2*MIN(M,N) locations of WORK as output by the original call to SGLSS. Output.. A(,) Contains the triangular part of the reduced matrix and the transformation information. It together with the first 2*MIN(M,N) elements of WORK (see below) completely specify the factorization of A. B(,) Contains the N by NB solution matrix X. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. WORK() The first 2*MIN(M,N) locations of WORK contain value necessary to reproduce the factorization of A. IWORK() The first M+N locations contain the order in which the rows and columns of A were used. If M.GE.N columns then rows. If M.LT.N rows then columns. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Full rank N.GT.0 - Reduced rank rank=MIN(M,N)-INFO
SGTSL
SUBROUTINE SGTSL(N,C,D,E,B,INFO) SGTSL given a general tridiagonal matrix and a right hand side will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. C REAL(N) is the subdiagonal of the tridiagonal matrix. C(2) through C(N) should contain the subdiagonal. On output, C is destroyed. D REAL(N) is the diagonal of the tridiagonal matrix. On output, D is destroyed. E REAL(N) is the superdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the superdiagonal. On output, E is destroyed. B REAL(N) is the right hand side vector. On Return B is the solution vector. INFO INTEGER = 0 normal value. = K if the K-th element of the diagonal becomes exactly zero. The subroutine returns when this is detected. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No externals Fortran ABS
SNBCO
SUBROUTINE SNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) SNBCO factors a real band matrix by Gaussian elimination and estimates the condition of the matrix. If RCOND is not needed, SNBFA is slightly faster. To solve A*X = B , follow SNBCO by SNBSL. To compute INVERSE(A)*C , follow SNBCO by SNBSL. To compute DETERMINANT(A) , follow SNBCO by SNBDI. On Entry ABE REAL(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U , where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 07/23/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions SLATEC SNBFA SDOT,SAXPY,SSCAL,SASUM Fortran ABS,AMAX1,MAX0,MIN0,SIGN
SNBDI
SUBROUTINE SNBDI(ABE,LDA,N,ML,MU,IPVT,DET) SNBDI computes the determinant of a band matrix using the factors computed by SNBCO or SNBFA. If the inverse is needed, use SNBSL N times. On Entry ABE REAL(LDA, NC) the output from SNBCO or SNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from SNBCO or SNBFA. On Return DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0 . SLATEC. This version dated 07/25/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions Fortran ABS
SNBFA
SUBROUTINE SNBFA(ABE,LDA,N,ML,MU,IPVT,INFO) SNBFA factors a real band matrix by elimination. SNBFA is usually called by SNBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABE REAL(LDA, NC) contains the matrix in band storage. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE. NC must be .GE. 2*ML+MU+1 . See the comments below for details. LDA INTEGER the leading dimension of the array ABE. LDA must be .GE. N . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. 0 .LE. ML .LT. N . MU INTEGER number of diagonals above the main diagonal. 0 .LE. MU .LT. N . More efficient if ML .LE. MU . On Return ABE an upper triangular matrix in band storage and the multipliers which were used to obtain it. The factorization can be written A = L*U , where L is a product of permutation and unit lower triangular matrices and U is upper triangular. IPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER =0 normal value =K if U(K,K) .EQ. 0.0 . This is not an error condition for this subroutine, but it does indicate that SNBSL will divide by zero if called. Use RCOND in SNBCO for a reliable indication of singularity. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + SLATEC. This version dated 06/16/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions ISAMAX,SAXPY,SSCAL,SSWAP Fortran MIN0
SNBFS
SUBROUTINE SNBFS(ABE,LDA,N,ML,MU,V,ITASK,IND,WORK,IWORK) Subroutine SNBFS solves a general nonsymmetric banded NxN system of single precision real linear equations using SLATEC subroutines SNBCO and SNBSL. These are adaptations of the LINPACK subroutines SBGCO and SGBSL, which require a different format for storing the matrix elements. If A is an NxN real matrix and if X and B are real N-vectors, then SNBFS solves the equation A*X=B. A band matrix is a matrix whose nonzero elements are all fairly near the main diagonal, specifically A(I,J) = 0 if I-J is greater than ML or J-I is greater than MU . The integers ML and MU are called the lower and upper band widths and M = ML+MU+1 is the total band width. SNBFS uses less time and storage than the corresponding program for general matrices (SGEFS) if 2*ML+MU .LT. N . The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by SNBFS in this case. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 through ML+MU+1 of ABE . Furthermore, ML additional columns are needed in ABE starting with column ML+MU+2 for elements generated during the triangularization. The total number of columns needed in ABE is 2*ML+MU+1 . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 + , * = not used 21 22 23 24 + , + = used for pivoting 32 33 34 35 + 43 44 45 46 + 54 55 56 * + 65 66 * * + Argument Description *** ABE REAL(LDA,NC) on entry, contains the matrix in band storage as described above. NC must not be less than 2*ML+MU+1 . The user is cautioned to specify NC with care since it is not an argument and cannot be checked by SNBFS. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE . on return, contains an upper triangular matrix U and the multipliers necessary to construct a matrix L so that A=L*U. LDA INTEGER the leading dimension of array ABE. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1 . (terminal error message IND=-2) ML INTEGER the number of diagonals below the main diagonal. ML must not be less than zero nor greater than or equal to N . (terminal error message IND=-5) MU INTEGER the number of diagonals above the main diagonal. MU must not be less than zero nor greater than or equal to N . (terminal error message IND=-6) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 See error message corresponding to IND below. WORK REAL(N) a singly subscripted array of dimension at least N. IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal the matrix A is computationally singular. A solution has not been computed. IND=-5 terminal ML is less than zero or is greater than or equal to N . IND=-6 terminal MU is less than zero or is greater than or equal to N . IND=-10 warning the solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SNBIR
SUBROUTINE SNBIR(ABE,LDA,N,ML,MU,V,ITASK,IND,WORK,IWORK) Subroutine SNBIR solves a general nonsymmetric banded NxN system of single precision real linear equations using SLATEC subroutines SNBFA and SNBSL. These are adaptations of the LINPACK subroutines SGBFA and SGBSL, which require a different format for storing the matrix elements. One pass of iterative refinement is used only to obtain an estimate of the accuracy. If A is an NxN real banded matrix and if X and B are real N-vectors, then SNBIR solves the equation A*X=B. A band matrix is a matrix whose nonzero elements are all fairly near the main diagonal, specifically A(I,J) = 0 if I-J is greater than ML or J-I is greater than MU . The integers ML and MU are called the lower and upper band widths and M = ML+MU+1 is the total band width. SNBIR uses less time and storage than the corresponding program for general matrices (SGEIR) if 2*ML+MU .LT. N . The matrix A is first factored into upper and lower tri- angular matrices U and L using partial pivoting. These factors and the pivoting information are used to find the solution vector X . Then the residual vector is found and used to calculate an estimate of the relative error, IND . IND esti- mates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N, work and IWORK must not have been altered by the user follow- ing factorization (ITASK=1). IND will not be changed by SNBIR in this case. Band Storage If A is a band matrix, the following program segment will set up the input. ML = (band width below the diagonal) MU = (band width above the diagonal) DO 20 I = 1, N J1 = MAX0(1, I-ML) J2 = MIN0(N, I+MU) DO 10 J = J1, J2 K = J - I + ML + 1 ABE(I,K) = A(I,J) 10 CONTINUE 20 CONTINUE This uses columns 1 Through ML+MU+1 of ABE . Example: If the original matrix is 11 12 13 0 0 0 21 22 23 24 0 0 0 32 33 34 35 0 0 0 43 44 45 46 0 0 0 54 55 56 0 0 0 0 65 66 then N = 6, ML = 1, MU = 2, LDA .GE. 5 and ABE should contain * 11 12 13 , * = not used 21 22 23 24 32 33 34 35 43 44 45 46 54 55 56 * 65 66 * * Argument Description *** ABE REAL(LDA,MM) on entry, contains the matrix in band storage as described above. MM must not be less than M = ML+MU+1 . The user is cautioned to dimension ABE with care since MM is not an argument and cannot be checked by SNBIR. The rows of the original matrix are stored in the rows of ABE and the diagonals of the original matrix are stored in columns 1 through ML+MU+1 of ABE . ABE is not altered by the program. LDA INTEGER the leading dimension of array ABE. LDA must be great- er than or equal to N. (terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1 . (terminal error message IND=-2) ML INTEGER the number of diagonals below the main diagonal. ML must not be less than zero nor greater than or equal to N . (terminal error message IND=-5) MU INTEGER the number of diagonals above the main diagonal. MU must not be less than zero nor greater than or equal to N . (terminal error message IND=-6) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK=1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A and IWORK. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X . IND=75 means that the solution vector X is zero. LT. 0 See error message corresponding to IND below. WORK REAL(N*(NC+1)) a singly subscripted array of dimension at least N*(NC+1) where NC = 2*ML+MU+1 . IWORK INTEGER(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 terminal the matrix A is computationally singular. A solution has not been computed. IND=-5 terminal ML is less than zero or is greater than or equal to N . IND=-6 terminal MU is less than zero or is greater than or equal to N . IND=-10 warning the solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SNBSL
SUBROUTINE SNBSL(ABE,LDA,N,ML,MU,IPVT,B,JOB) SNBSL solves the real band system A * X = B or TRANS(A) * X = B using the factors computed by SNBCO or SNBFA. On Entry ABE REAL(LDA, NC) the output from SNBCO or SNBFA. NC must be .GE. 2*ML+MU+1 . LDA INTEGER the leading dimension of the array ABE . N INTEGER the order of the original matrix. ML INTEGER number of diagonals below the main diagonal. MU INTEGER number of diagonals above the main diagonal. IPVT INTEGER(N) the pivot vector from SNBCO or SNBFA. B REAL(N) the right hand side vector. JOB INTEGER = 0 to solve A*X = B . = nonzero to solve TRANS(A)*X = B , where TRANS(A) is the transpose. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is often caused by improper arguments or improper setting of LDA. It will not occur if the subroutines are called correctly and if SNBCO has set RCOND .GT. 0.0 or SNBFA has set INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SNBCO(ABE,LDA,N,ML,MU,IPVT,RCOND,Z) IF (RCOND is too small) GO TO ... DO 10 J = 1, P CALL SNBSL(ABE,LDA,N,ML,MU,IPVT,C(1,J),0) 10 CONTINUE SLATEC. This version dated 07/17/80 . E. A. Voorhees, Los Alamos Scientific Laboratory Subroutines and Functions SAXPY,SDOT Fortran MIN0
SNRM2
REAL FUNCTION SNRM2(N,SX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX --Output-- SNRM2 single precision result (zero if N .LE. 0) Euclidean norm of the N-vector stored in SX() with storage increment INCX . If N .LE. 0, return with result = 0. If N .GE. 1, then INCX must be .GE. 1 C. L. Lawson, 1978 Jan 08 Four Phase Method using two built-in constants that are hopefully applicable to all machines. CUTLO = maximum of SQRT(U/EPS) over all known machines. CUTHI = minimum of SQRT(V) over all known machines. where EPS = smallest no. such that EPS + 1. .GT. 1. U = smallest positive no. (underflow limit) V = largest no. (overflow limit) Brief Outline of Algorithm.. Phase 1 scans zero components. Move to phase 2 when a component is nonzero and .LE. CUTLO Move to phase 3 when a component is .GT. CUTLO Move to phase 4 when a component is .GE. CUTHI/M where M = N for X() real and M = 2*N for complex. Values for CUTLO and CUTHI.. From the environmental parameters listed in the IMSL converter document the limiting values are as follows.. CUTLO, S.P. U/EPS = 2**(-102) for Honeywell. Close seconds are Univac and DEC at 2**(-103) Thus CUTLO = 2**(-51) = 4.44089E-16 CUTHI, S.P. V = 2**127 for Univac, Honeywell, and DEC. Thus CUTHI = 2**(63.5) = 1.30438E19 CUTLO, D.P. U/EPS = 2**(-67) for Honeywell and DEC. Thus CUTLO = 2**(-33.5) = 8.23181D-11 CUTHI, D.P. same as S.P. CUTHI = 1.30438D19 SAVE CUTLO, CUTHI, ZERO, ONE DATA CUTLO, CUTHI / 8.232D-11, 1.304D19 / DATA CUTLO, CUTHI / 4.441E-16, 1.304E19 /
SPBCO
SUBROUTINE SPBCO(ABD,LDA,N,M,RCOND,Z,INFO) SPBCO factors a real symmetric positive definite matrix stored in band form and estimates the condition of the matrix. If RCOND is not needed, SPBFA is slightly faster. To solve A*X = B , follow SPBCO by SPBSL. To compute INVERSE(A)*C , follow SPBCO by SPBSL. To compute DETERMINANT(A) , follow SPBCO by SPBDI. On Entry ABD REAL(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = TRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z REAL(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Band Storage If A is a symmetric positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE This uses M + 1 rows of A , except for the M by M upper left triangle, which is ignored. Example: If the original matrix is 11 12 13 0 0 0 12 22 23 24 0 0 13 23 33 34 35 0 0 24 34 44 45 46 0 0 35 45 55 56 0 0 0 46 56 66 then N = 6 , M = 2 and ABD should contain * * 13 24 35 46 * 12 23 34 45 56 11 22 33 44 55 66 LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SPBFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,MAX0,MIN0,REAL,SIGN
SPBDI
SUBROUTINE SPBDI(ABD,LDA,N,M,DET) SPBDI computes the determinant of a real symmetric positive definite band matrix using the factors computed by SPBCO or SPBFA. If the inverse is needed, use SPBSL N times. On Entry ABD REAL(LDA, N) the output from SPBCO or SPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. On Return DET REAL(2) determinant of original matrix in the form Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab.
SPBFA
SUBROUTINE SPBFA(ABD,LDA,N,M,INFO) SPBFA factors a real symmetric positive definite matrix stored in band form. SPBFA is usually called by SPBCO, but it can be called directly with a saving in time if RCOND is not needed. On Entry ABD REAL(LDA, N) the matrix to be factored. The columns of the upper triangle are stored in the columns of ABD and the diagonals of the upper triangle are stored in the rows of ABD . See the comments below for details. LDA INTEGER the leading dimension of the array ABD . LDA must be .GE. M + 1 . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. 0 .LE. M .LT. N . On Return ABD an upper triangular matrix R , stored in band form, so that A = TRANS(R)*R . INFO INTEGER = 0 for normal return. = K if the leading minor of order K is not positive definite. Band Storage If A is a symmetric positive definite band matrix, the following program segment will set up the input. M = (band width above diagonal) DO 20 J = 1, N I1 = MAX0(1, J-M) DO 10 I = I1, J K = I-J+M+1 ABD(K,J) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SDOT Fortran MAX0,SQRT
SPBSL
SUBROUTINE SPBSL(ABD,LDA,N,M,B) SPBSL solves the real symmetric positive definite band system A*X = B using the factors computed by SPBCO or SPBFA. On Entry ABD REAL(LDA, N) the output from SPBCO or SPBFA. LDA INTEGER the leading dimension of the array ABD . N INTEGER the order of the matrix A . M INTEGER the number of diagonals above the main diagonal. B REAL(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SPBCO(ABD,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL SPBSL(ABD,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT Fortran MIN0
SPELI4
SUBROUTINE SPELI4(IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,D,N,
SPELIP
SUBROUTINE SPELIP(INTL,IORDER,A,B,M,MBDCND,BDA,ALPHA,BDB,BETA,C,
SPOCO
SUBROUTINE SPOCO(A,LDA,N,RCOND,Z,INFO) SPOCO factors a real symmetric positive definite matrix and estimates the condition of the matrix. If RCOND is not needed, SPOFA is slightly faster. To solve A*X = B , follow SPOCO by SPOSL. To compute INVERSE(A)*C , follow SPOCO by SPOSL. To compute DETERMINANT(A) , follow SPOCO by SPODI. To compute INVERSE(A) , follow SPOCO by SPODI. On Entry A REAL(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = TRANS(R)*R where TRANS(R) is the transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SPOFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,REAL,SIGN
SPODI
SUBROUTINE SPODI(A,LDA,N,DET,JOB) SPODI computes the determinant and inverse of a certain real symmetric positive definite matrix (see below) using the factors computed by SPOCO, SPOFA or SQRDC. On Entry A REAL(LDA, N) the output A from SPOCO or SPOFA or the output X from SQRDC. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return A If SPOCO or SPOFA was used to factor A , then SPODI produces the upper half of INVERSE(A) . If SQRDC was used to decompose X , then SPODI produces the upper half of INVERSE(TRANS(X)*X), where TRANS(X) is the transpose. Elements of A below the diagonal are unchanged. If the units digit of JOB is zero, A is unchanged. DET REAL(2) determinant of A or of TRANS(X)*X if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if SPOCO or SPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL Fortran MOD
SPOFA
SUBROUTINE SPOFA(A,LDA,N,INFO) SPOFA factors a real symmetric positive definite matrix. SPOFA is usually called by SPOCO, but it can be called directly with a saving in time if RCOND is not needed. (Time for SPOCO) = (1 + 18/N)*(Time for SPOFA) . On Entry A REAL(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A an upper triangular matrix R so that A = TRANS(R)*R where TRANS(R) is the transpose. The strict lower triangle is unaltered. If INFO .NE. 0 , the factorization is not complete. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SDOT Fortran SQRT
SPOFS
SUBROUTINE SPOFS(A,LDA,N,V,ITASK,IND,WORK) Subroutine SPOFS solves a real positive definite symmetric NxN system of single precision linear equations using LINPACK subroutines SPOCO and SPOSL. That is, if A is an NxN real positive definite symmetric matrix and if X and B are real N-vectors, then SPOFS solves the equation A*X=B. The matrix A is first factored into upper and lower tri- angular matrices R and R-TRANSPOSE. These factors are used to find the solution vector X. An approximate condition number is calculated to provide a rough estimate of the number of digits of accuracy in the computed solution. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to solve only (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, and N must not have been altered by the user following factorization (ITASK=1). IND will not be changed by SPOFS in this case. Argument Description *** A REAL(LDA,N) on entry, the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. Only the upper triangle, including the diagonal, of the coefficient matrix need be entered and will subse- quently be referenced and changed by the routine. on return, contains in its upper triangle an upper triangular matrix R such that A = (R-TRANSPOSE) * R . LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (Terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to 1. (Terminal error message IND=-2) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK = 1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A. If ITASK .LT. 1, then terminal error message IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. LT. 0 see error message corresponding to IND below. WORK REAL(N) a singly subscripted array of dimension at least N. Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than 1. IND=-3 terminal ITASK is less than 1. IND=-4 Terminal The matrix A is computationally singular or is not positive definite. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SPOIR
SUBROUTINE SPOIR(A,LDA,N,V,ITASK,IND,WORK) Subroutine SPOIR solves a real positive definite symmetric NxN system of single precision linear equations using LINPACK subroutines SPOFA and SPOSL. One pass of iterative refine- ment is used only to obtain an estimate of the accuracy. That is, if A is an NxN real positive definite symmetric matrix and if X and B are real N-vectors, then SPOIR solves the equation A*X=B. The matrix A is first factored into upper and lower triangular matrices R and R-TRANSPOSE. These factors are used to calculate the solution, X. Then the residual vector is found and used to calculate an estimate of the relative error, IND. IND estimates the accuracy of the solution only when the input matrix and the right hand side are represented exactly in the computer and does not take into account any errors in the input data. If the equation A*X=B is to be solved for more than one vector B, the factoring of A does not need to be performed again and the option to only solve (ITASK .GT. 1) will be faster for the succeeding solutions. In this case, the contents of A, LDA, N, and WORK must not have been altered by the user following factorization (ITASK=1). IND will not be changed by SPOIR in this case. Argument Description *** A REAL(LDA,N) the doubly subscripted array with dimension (LDA,N) which contains the coefficient matrix. Only the upper triangle, including the diagonal, of the coefficient matrix need be entered. A is not altered by the routine. LDA INTEGER the leading dimension of the array A. LDA must be great- er than or equal to N. (Terminal error message IND=-1) N INTEGER the order of the matrix A. N must be greater than or equal to one. (Terminal error message IND=-2) V REAL(N) on entry, the singly subscripted array(vector) of di- mension N which contains the right hand side B of a system of simultaneous linear equations A*X=B. on return, V contains the solution vector, X . ITASK INTEGER If ITASK = 1, the matrix A is factored and then the linear equation is solved. If ITASK .GT. 1, the equation is solved using the existing factored matrix A (stored in WORK). If ITASK .LT. 1, then terminal terminal error IND=-3 is printed. IND INTEGER GT. 0 IND is a rough estimate of the number of digits of accuracy in the solution, X. IND=75 means that the solution vector X is zero. LT. 0 See error message corresponding to IND below. WORK REAL(N*(N+1)) a singly subscripted array of dimension at least N*(N+1). Error Messages Printed *** IND=-1 terminal N is greater than LDA. IND=-2 terminal N is less than one. IND=-3 terminal ITASK is less than one. IND=-4 Terminal The matrix A is computationally singular or is not positive definite. A solution has not been computed. IND=-10 warning The solution has no apparent significance. The solution may be inaccurate or the matrix A may be poorly scaled. Note- The above terminal(*fatal*) error messages are designed to be handled by XERRWV in which LEVEL=1 (recoverable) and IFLAG=2 . LEVEL=0 for warning error messages from XERROR. Unless the user provides otherwise, an error message will be printed followed by an abort.
SPOPT
SUBROUTINE SPOPT(PRGOPT,MRELAS,NVARS,INFO,CSC,IBASIS,ROPT,INTOPT, THE EDITING REQUIRED TO CONVERT THIS SUBROUTINE FROM SINGLE TO DOUBLE PRECISION INVOLVES THE FOLLOWING CHARACTER STRING CHANGES. USE AN EDITING COMMAND (CHANGE) /STRING-1/(TO)STRING-2/. /REAL (12 BLANKS)/DOUBLE PRECISION/,/ABS(/DABS(/,/AMAX1/ DMAX1/,/SQRT/DSQRT/,/R1MACH/D1MACH/,/AMIN1/DMIN1/,/E0/D0/ REVISED 821122-1045 REVISED YYMMDD-HHMM THIS SUBROUTINE PROCESSES THE OPTION VECTOR, PRGOPT(*), AND VALIDATES ANY MODIFIED DATA.
SPOSL
SUBROUTINE SPOSL(A,LDA,N,B) SPOSL solves the real symmetric positive definite system A * X = B using the factors computed by SPOCO or SPOFA. On Entry A REAL(LDA, N) the output from SPOCO or SPOFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . B REAL(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SPOCO(A,LDA,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL SPOSL(A,LDA,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT
SPPCO
SUBROUTINE SPPCO(AP,N,RCOND,Z,INFO) SPPCO factors a real symmetric positive definite matrix stored in packed form and estimates the condition of the matrix. If RCOND is not needed, SPPFA is slightly faster. To solve A*X = B , follow SPPCO by SPPSL. To compute INVERSE(A)*C , follow SPPCO by SPPSL. To compute DETERMINANT(A) , follow SPPCO by SPPDI. To compute INVERSE(A) , follow SPPCO by SPPDI. On Entry AP REAL (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = TRANS(R)*R . If INFO .NE. 0 , the factorization is not complete. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. If INFO .NE. 0 , RCOND is unchanged. Z REAL(N) a work vector whose contents are usually unimportant. If A is singular to working precision, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . If INFO .NE. 0 , Z is unchanged. INFO INTEGER = 0 for normal return. = K signals an error condition. The leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SPPFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,REAL,SIGN
SPPDI
SUBROUTINE SPPDI(AP,N,DET,JOB) SPPDI computes the determinant and inverse of a real symmetric positive definite matrix using the factors computed by SPPCO or SPPFA . On Entry AP REAL (N*(N+1)/2) the output from SPPCO or SPPFA. N INTEGER the order of the matrix A . JOB INTEGER = 11 both determinant and inverse. = 01 inverse only. = 10 determinant only. On Return AP the upper triangular half of the inverse . The strict lower triangle is unaltered. DET REAL(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. DET(1) .LT. 10.0 or DET(1) .EQ. 0.0 . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal and the inverse is requested. It will not occur if the subroutines are called correctly and if SPOCO or SPOFA has set INFO .EQ. 0 . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL Fortran MOD
SPPFA
SUBROUTINE SPPFA(AP,N,INFO) SPPFA factors a real symmetric positive definite matrix stored in packed form. SPPFA is usually called by SPPCO, but it can be called directly with a saving in time if RCOND is not needed. (Time for SPPCO) = (1 + 18/N)*(Time for SPPFA) . On Entry AP REAL (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . On Return AP an upper triangular matrix R , stored in packed form, so that A = TRANS(R)*R . INFO INTEGER = 0 for normal return. = K if the leading minor of order K is not positive definite. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SDOT Fortran SQRT
SPPSL
SUBROUTINE SPPSL(AP,N,B) SPPSL solves the real symmetric positive definite system A * X = B using the factors computed by SPPCO or SPPFA. On Entry AP REAL (N*(N+1)/2) the output from SPPCO or SPPFA. N INTEGER the order of the matrix A . B REAL(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero will occur if the input factor contains a zero on the diagonal. Technically, this indicates singularity, but it is usually caused by improper subroutine arguments. It will not occur if the subroutines are called correctly and INFO .EQ. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SPPCO(AP,N,RCOND,Z,INFO) IF (RCOND is too small .OR. INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL SPPSL(AP,N,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT
SPTSL
SUBROUTINE SPTSL(N,D,E,B) SPTSL given a positive definite tridiagonal matrix and a right hand side will find the solution. On Entry N INTEGER is the order of the tridiagonal matrix. D REAL(N) is the diagonal of the tridiagonal matrix. On output, D is destroyed. E REAL(N) is the offdiagonal of the tridiagonal matrix. E(1) through E(N-1) should contain the offdiagonal. B REAL(N) is the right hand side vector. On Return B contains the solution. LINPACK. This version dated 08/14/78 . Jack Dongarra, Argonne National Laboratory. No externals Fortran MOD
SQRDC
SUBROUTINE SQRDC(X,LDX,N,P,QRAUX,JPVT,WORK,JOB) SQRDC uses Householder transformations to compute the QR factorization of an N by P matrix X. Column pivoting based on the 2-norms of the reduced columns may be performed at the user's option. On Entry X REAL(LDX,P), where LDX .GE. N. X contains the matrix whose decomposition is to be computed. LDX INTEGER. LDX is the leading dimension of the array X. N INTEGER. N is the number of rows of the matrix X. P INTEGER. P is the number of columns of the matrix X. JPVT INTEGER(P). JPVT contains integers that control the selection of the pivot columns. The K-th column X(K) of X is placed in one of three classes according to the value of JPVT(K). If JPVT(K) .GT. 0, then X(K) is an initial column. If JPVT(K) .EQ. 0, then X(K) is a free column. If JPVT(K) .LT. 0, then X(K) is a final column. Before the decomposition is computed, initial columns are moved to the beginning of the array X and final columns to the end. Both initial and final columns are frozen in place during the computation and only free columns are moved. At the K-th stage of the reduction, if X(K) is occupied by a free column, it is interchanged with the free column of largest reduced norm. JPVT is not referenced if JOB .EQ. 0. WORK REAL(P). WORK is a work array. WORK is not referenced if JOB .EQ. 0. JOB INTEGER. JOB is an integer that initiates column pivoting. If JOB .EQ. 0, no pivoting is done. If JOB .NE. 0, pivoting is done. On Return X X contains in its upper triangle the upper triangular matrix R of the QR factorization. Below its diagonal X contains information from which the orthogonal part of the decomposition can be recovered. Note that if pivoting has been requested, the decomposition is not that of the original matrix X but that of X with its columns permuted as described by JPVT. QRAUX REAL(P). QRAUX contains further information required to recover the orthogonal part of the decomposition. JPVT JPVT(K) contains the index of the column of the original matrix that has been interchanged into the K-th column, if pivoting was requested. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. SQRDC uses the following functions and subprograms. BLAS SAXPY,SDOT,SSCAL,SSWAP,SNRM2 Fortran ABS,AMAX1,MIN0,SQRT
SQRSL
SUBROUTINE SQRSL(X,LDX,N,K,QRAUX,Y,QY,QTY,B,RSD,XB,JOB,INFO) SQRSL applies the output of SQRDC to compute coordinate transformations, projections, and least squares solutions. For K .LE. MIN(N,P), let XK be the matrix XK = (X(JPVT(1)),X(JPVT(2)), ... ,X(JPVT(K))) formed from columnns JPVT(1), ... ,JPVT(K) of the original N x P matrix X that was input to SQRDC (if no pivoting was done, XK consists of the first K columns of X in their original order). SQRDC produces a factored orthogonal matrix Q and an upper triangular matrix R such that XK = Q * (R) (0) This information is contained in coded form in the arrays X and QRAUX. On Entry X REAL(LDX,P) X contains the output of SQRDC. LDX INTEGER LDX is the leading dimension of the array X. N INTEGER N is the number of rows of the matrix XK. It must have the same value as N in SQRDC. K INTEGER K is the number of columns of the matrix XK. K must not be greater than MIN(N,P), where P is the same as in the calling sequence to SQRDC. QRAUX REAL(P) QRAUX contains the auxiliary output from SQRDC. Y REAL(N) Y contains an N-vector that is to be manipulated by SQRSL. JOB INTEGER JOB specifies what is to be computed. JOB has the decimal expansion ABCDE, with the following meaning. If A .NE. 0, compute QY. If B,C,D, or E .NE. 0, compute QTY. If C .NE. 0, compute B. If D .NE. 0, compute RSD. If E .NE. 0, compute XB. Note that a request to compute B, RSD, or XB automatically triggers the computation of QTY, for which an array must be provided in the calling sequence. On Return QY REAL(N). QY contains Q*Y, if its computation has been requested. QTY REAL(N). QTY contains TRANS(Q)*Y, if its computation has been requested. Here TRANS(Q) is the transpose of the matrix Q. B REAL(K) B contains the solution of the least squares problem minimize norm2(Y - XK*B), if its computation has been requested. (Note that if pivoting was requested in SQRDC, the J-th component of B will be associated with column JPVT(J) of the original matrix X that was input into SQRDC.) RSD REAL(N). RSD contains the least squares residual Y - XK*B, if its computation has been requested. RSD is also the orthogonal projection of Y onto the orthogonal complement of the column space of XK. XB REAL(N). XB contains the least squares approximation XK*B, if its computation has been requested. XB is also the orthogonal projection of Y onto the column space of X. INFO INTEGER. INFO is zero unless the computation of B has been requested and R is exactly singular. In this case, INFO is the index of the first zero diagonal element of R and B is left unaltered. The parameters QY, QTY, B, RSD, and XB are not referenced if their computation is not requested and in this case can be replaced by dummy variables in the calling program. To save storage, the user may in some cases use the same array for different parameters in the calling sequence. A frequently occuring example is when one wishes to compute any of B, RSD, or XB and does not need Y or QTY. In this case one may identify Y, QTY, and one of B, RSD, or XB, while providing separate arrays for anything else that is to be computed. Thus the calling sequence CALL SQRSL(X,LDX,N,K,QRAUX,Y,DUM,Y,B,Y,DUM,110,INFO) will result in the computation of B and RSD, with RSD overwriting Y. More generally, each item in the following list contains groups of permissible identifications for a single callinng sequence. 1. (Y,QTY,B) (RSD) (XB) (QY) 2. (Y,QTY,RSD) (B) (XB) (QY) 3. (Y,QTY,XB) (B) (RSD) (QY) 4. (Y,QY) (QTY,B) (RSD) (XB) 5. (Y,QY) (QTY,RSD) (B) (XB) 6. (Y,QY) (QTY,XB) (B) (RSD) In any group the value returned in the array allocated to the group corresponds to the last member of the group. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. SQRSL uses the following functions and subprograms. BLAS SAXPY,SCOPY,SDOT Fortran ABS,MIN0,MOD
SREADP
SUBROUTINE SREADP(IPAGE,LIST,RLIST,LPAGE,IREC) READ RECORD NUMBER IRECN, OF LENGTH LPG, FROM UNIT NUMBER IPAGEF INTO THE STORAGE ARRAY, LIST(*). READ RECORD IRECN+1, OF LENGTH LPG, FROM UNIT NUMBER IPAGEF INTO THE STORAGE ARRAY RLIST(*). TO CONVERT THIS PROGRAM UNIT TO DOUBLE PRECISION CHANGE /REAL (12 BLANKS)/ TO /DOUBLE PRECISION/.
SROT
SUBROUTINE SROT(N,SX,INCX,SY,INCY,SC,SS) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY SC element of rotation matrix SS element of rotation matrix --Output-- SX rotated vector SX (unchanged if N .LE. 0) SY rotated vector SY (unchanged if N .LE. 0) Multiply the 2 x 2 matrix ( SC SS) times the 2 x N matrix (SX**T) (-SS SC) (SY**T) where **T indicates transpose. The elements of SX are in SX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for SY using LY and INCY.
SROTG
SUBROUTINE SROTG(SA,SB,SC,SS) B L A S Subprogram Description of Parameters --Input-- SA single precision scalar SB single precision scalar --Output-- SA single precision result R SB single precision result Z SC single precision result SS single precision result Designed by C. L. Lawson, JPL, 1977 Sept 08 Construct the Givens transformation ( SC SS ) G = ( ) , SC**2 + SS**2 = 1 , (-SS SC ) which zeros the second entry of the 2-vector (SA,SB)**T. The quantity R = (+/-)SQRT(SA**2 + SB**2) overwrites SA in storage. The value of SB is overwritten by a value Z which allows SC and SS to be recovered by the following algorithm: If Z=1 set SC=0. and SS=1. If ABS(Z) .LT. 1 set SC=SQRT(1-Z**2) and SS=Z If ABS(Z) .GT. 1 set SC=1/Z and SS=SQRT(1-SC**2) Normally, the subprogram SROT(N,SX,INCX,SY,INCY,SC,SS) will next be called to apply the transformation to a 2 by N matrix.
SROTM
SUBROUTINE SROTM(N,SX,INCX,SY,INCY,SPARAM) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY SPARAM 5-element vector. SPARAM(1) is SFLAG described below. Locations 2-5 of SPARAM contain elements of the transformation matrix H described below. --Output-- SX rotated vector (unchanged if N .LE. 0) SY rotated vector (unchanged if N .LE. 0) Apply the modified Givens transformation, H, to the 2 by N matrix (SX**T) , where **T indicates transpose. The elements of SX are in (SY**T) SX(LX+I*INCX), I = 0 to N-1, where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and similarly for SY using using LY and INCY. With SPARAM(1)=SFLAG, H has one of the following forms.. SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0 (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0) H=( ) ( ) ( ) ( ) (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0). See SROTMG for a description of data storage in SPARAM.
SROTMG
SUBROUTINE SROTMG(SD1,SD2,SX1,SY1,SPARAM) B L A S Subprogram Description of Parameters --Input-- SD1 single precision scalar used to define A1 below SD2 single precision scalar used to define A2 below SB1 single precision scalar defining A1 below SB2 single precision scalar defining A2 below SPARAM S.P. 5-vector. SPARAM(1)=SFLAG defined below. Locations 2-5 contain the rotation matrix. --Output-- SD1 changed to represent the effect of the transformation SD2 changed to represent the effect of the transformation SB1 changed to represent the effect of the transformation SB2 unchanged Construct the modified Givens transformation matrix H which zeros the second component of the 2-vector (SQRT(SD1)*SX1,SQRT(SD2)* SY2)**T. With SPARAM(1)=SFLAG, H has one of the following forms.. SFLAG=-1.E0 SFLAG=0.E0 SFLAG=1.E0 SFLAG=-2.E0 (SH11 SH12) (1.E0 SH12) (SH11 1.E0) (1.E0 0.E0) H=( ) ( ) ( ) ( ) (SH21 SH22), (SH21 1.E0), (-1.E0 SH22), (0.E0 1.E0). Locations 2-5 of SPARAM contain SH11,SH21,SH12, and SH22 respectively. (Values of 1.E0, -1.E0, or 0.E0 implied by the value of SPARAM(1) are not stored in SPARAM.)
SSCAL
SUBROUTINE SSCAL(N,SA,SX,INCX) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SA single precision scale factor SX single precision vector with N elements INCX storage spacing between elements of SX --Output-- SX single precision result (unchanged if N .LE. 0) Replace single precision SX by single precision SA*SX. For I = 0 to N-1, replace SX(1+I*INCX) with SA * SX(1+I*INCX)
SSICO
SUBROUTINE SSICO(A,LDA,N,KPVT,RCOND,Z) SSICO factors a real symmetric matrix by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, SSIFA is slightly faster. To solve A*X = B , follow SSICO by SSISL. To compute INVERSE(A)*C , follow SSICO by SSISL. To compute INVERSE(A) , follow SSICO by SSIDI. To compute DETERMINANT(A) , follow SSICO by SSIDI. To compute INERTIA(A), follow SSICO by SSIDI. On Entry A REAL(LDA, N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . Output A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SSIFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,IABS,SIGN
SSIDI
SUBROUTINE SSIDI(A,LDA,N,KPVT,DET,INERT,WORK,JOB) SSIDI computes the determinant, inertia and inverse of a real symmetric matrix using the factors from SSIFA. On Entry A REAL(LDA,N) the output from SSIFA. LDA INTEGER the leading dimension of the array A. N INTEGER the order of the matrix A. KPVT INTEGER(N) the pivot vector from SSIFA. WORK REAL(N) work vector. Contents destroyed. JOB INTEGER JOB has the decimal expansion ABC where If C .NE. 0, the inverse is computed, If B .NE. 0, the determinant is computed, If A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. A contains the upper triangle of the inverse of the original matrix. The strict lower triangle is never referenced. DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero may occur if the inverse is requested and SSICO has set RCOND .EQ. 0.0 or SSIFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab Subroutines and Functions BLAS SAXPY,SCOPY,SDOT,SSWAP Fortran ABS,IABS,MOD
SSIEV
SUBROUTINE SSIEV(A,LDA,N,E,WORK,JOB,INFO) LICEPACK. This version dated 08/08/80. David Kahaner, Cleve Moler, Pete Stewart N.B.S. U.N.M. N.B.S./U.MD. Abstract SSIEV computes the eigenvalues and, optionally, the eigenvectors of a real symmetric matrix. Call Sequence Parameters- (The values of parameters marked with * (star) will be changed by SSIEV.) A* REAL (LDA,N) real symmetric input matrix. Only the diagonal and upper triangle of A must be input, as SSIEV copies the upper triangle to the lower. That is, the user must define A(I,J), I=1,..N, and J=I,. ..,N. On return from SSIEV, if the user has set JOB = 0 the lower triangle of A has been altered. = nonzero the N eigenvectors of A are stored in its first N columns. See also INFO below. LDA INTEGER set by the user to the leading dimension of the array A. N INTEGER set by the user to the order of the matrix A and the number of elements in E. E* REAL (N) on return from SSIEV, E contains the N eigenvalues of A. See also INFO below. WORK* REAL (2*N) temporary storage vector. Contents changed by SSIEV. JOB INTEGER set by user on input = 0 only calculate eigenvalues of A. = nonzero calculate eigenvalues and eigenvectors of A. INFO* INTEGER on return from SSIEV, the value of INFO is = 0 for normal return. = K if the eigenvalue iteration fails to converge. eigenvalues and vectors 1 through K-1 are correct. Error Messages- No. 1 recoverable N is greater than LDA No. 2 recoverable N is less than one Subroutines Used EISPACK- TRED1, TRED2, TQLRAT, IMTQL2 SLATEC- XERROR
SSIFA
SUBROUTINE SSIFA(A,LDA,N,KPVT,INFO) SSIFA factors a real symmetric matrix by elimination with symmetric pivoting. To solve A*X = B , follow SSIFA by SSISL. To compute INVERSE(A)*C , follow SSIFA by SSISL. To compute DETERMINANT(A) , follow SSIFA by SSIDI. To compute INERTIA(A) , follow SSIFA by SSIDI. To compute INVERSE(A) , follow SSIFA by SSIDI. On Entry A REAL(LDA,N) the symmetric matrix to be factored. Only the diagonal and upper triangle are used. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . On Return A a block diagonal matrix and the multipliers which were used to obtain it. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that SSISL or SSIDI may divide by zero if called. LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS SAXPY,SSWAP,ISAMAX Fortran ABS,AMAX1,SQRT
SSISL
SUBROUTINE SSISL(A,LDA,N,KPVT,B) SSISL solves the real symmetric system A * X = B using the factors computed by SSIFA. On Entry A REAL(LDA,N) the output from SSIFA. LDA INTEGER the leading dimension of the array A . N INTEGER the order of the matrix A . KPVT INTEGER(N) the pivot vector from SSIFA. B REAL(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if SSICO has set RCOND .EQ. 0.0 or SSIFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SSIFA(A,LDA,N,KPVT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL SSISL(A,LDA,N,KPVT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS SAXPY,SDOT Fortran IABS
SSPCO
SUBROUTINE SSPCO(AP,N,KPVT,RCOND,Z) SSPCO factors a real symmetric matrix stored in packed form by elimination with symmetric pivoting and estimates the condition of the matrix. If RCOND is not needed, SSPFA is slightly faster. To solve A*X = B , follow SSPCO by SSPSL. To compute INVERSE(A)*C , follow SSPCO by SSPSL. To compute INVERSE(A) , follow SSPCO by SSPDI. To compute DETERMINANT(A) , follow SSPCO by SSPDI. To compute INERTIA(A), follow SSPCO by SSPDI. On Entry AP REAL (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. RCOND REAL an estimate of the reciprocal condition of A . For the system A*X = B , relative perturbations in A and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then A may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If A is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions LINPACK SSPFA BLAS SAXPY,SDOT,SSCAL,SASUM Fortran ABS,AMAX1,IABS,SIGN
SSPDI
SUBROUTINE SSPDI(AP,N,KPVT,DET,INERT,WORK,JOB) SSPDI computes the determinant, inertia and inverse of a real symmetric matrix using the factors from SSPFA, where the matrix is stored in packed form. On Entry AP REAL (N*(N+1)/2) the output from SSPFA. N INTEGER the order of the matrix A. KPVT INTEGER(N) the pivot vector from SSPFA. WORK REAL(N) work vector. Contents ignored. JOB INTEGER JOB has the decimal expansion ABC where If C .NE. 0, the inverse is computed, If B .NE. 0, the determinant is computed, If A .NE. 0, the inertia is computed. For example, JOB = 111 gives all three. On Return Variables not requested by JOB are not used. AP contains the upper triangle of the inverse of the original matrix, stored in packed form. The columns of the upper triangle are stored sequentially in a one-dimensional array. DET REAL(2) determinant of original matrix. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) = 0.0. INERT INTEGER(3) the inertia of the original matrix. INERT(1) = number of positive eigenvalues. INERT(2) = number of negative eigenvalues. INERT(3) = number of zero eigenvalues. Error Condition A division by zero will occur if the inverse is requested and SSPCO has set RCOND .EQ. 0.0 or SSPFA has set INFO .NE. 0 . LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS SAXPY,SCOPY,SDOT,SSWAP Fortran ABS,IABS,MOD
SSPEV
SUBROUTINE SSPEV(A,N,E,V,LDV,WORK,JOB,INFO) LICEPACK. This version dated 08/08/80. David Kahaner, Cleve Moler, Pete Stewart N.B.S. U.N.M. N.B.S./U.MD. Abstract SSPEV computes the eigenvalues and, optionally, the eigenvectors of a real symmetric matrix stored in packed form. Call Sequence Parameters- (The values of parameters marked with * (star) will be changed by SSPEV.) A* REAL(N*(N+1)/2) real symmetric packed input matrix. Contains upper triangle and diagonal of A, by column (elements 11, 12, 22, 13, 23, 33, ...). N INTEGER set by the user to the order of the matrix A. E* REAL(N) on return from SSPEV, E contains the eigenvalues of A. See also INFO below. V* REAL(LDV,N) on return from SSPEV, if the user has set JOB = 0 V is not referenced. = nonzero the N eigenvectors of A are stored in the first N columns of V. See also INFO below. LDV INTEGER set by the user to the leading dimension of the array V if JOB is also set nonzero. In that case, N must be .LE. LDV. If JOB is set to zero, LDV is not referenced. WORK* REAL(2N) temporary storage vector. Contents changed by SSPEV. JOB INTEGER set by the user to = 0 eigenvalues only to be calculated by SSPEV. Neither V nor LDV are referenced. = nonzero eigenvalues and vectors to be calculated. In this case, A & V must be distinct arrays. Also, if LDA .GT. LDV, SSPEV changes all the elements of A thru column N. If LDA < LDV, SSPEV changes all the elements of V through column N. If LDA=LDV, only A(I,J) and V(I, J) for I,J = 1,...,N are changed by SSPEV. INFO* INTEGER on return from SSPEV, the value of INFO is = 0 for normal return. = K if the eigenvalue iteration fails to converge. Eigenvalues and vectors 1 through K-1 are correct. Error Messages- No. 1 recoverable N is greater than LDV and JOB is nonzero No. 2 recoverable N is less than one Subroutines Used EISPACK- IMTQL2, TQLRAT, TRBAK3, TRED3 SLATEC- XERROR
SSPFA
SUBROUTINE SSPFA(AP,N,KPVT,INFO) SSPFA factors a real symmetric matrix stored in packed form by elimination with symmetric pivoting. To solve A*X = B , follow SSPFA by SSPSL. To compute INVERSE(A)*C , follow SSPFA by SSPSL. To compute DETERMINANT(A) , follow SSPFA by SSPDI. To compute INERTIA(A) , follow SSPFA by SSPDI. To compute INVERSE(A) , follow SSPFA by SSPDI. On Entry AP REAL (N*(N+1)/2) the packed form of a symmetric matrix A . The columns of the upper triangle are stored sequentially in a one-dimensional array of length N*(N+1)/2 . See comments below for details. N INTEGER the order of the matrix A . Output AP a block diagonal matrix and the multipliers which were used to obtain it stored in packed form. The factorization can be written A = U*D*TRANS(U) where U is a product of permutation and unit upper triangular matrices , TRANS(U) is the transpose of U , and D is block diagonal with 1 by 1 and 2 by 2 blocks. KPVT INTEGER(N) an integer vector of pivot indices. INFO INTEGER = 0 normal value. = K if the K-th pivot block is singular. This is not an error condition for this subroutine, but it does indicate that SSPSL or SSPDI may divide by zero if called. Packed Storage The following program segment will pack the upper triangle of a symmetric matrix. K = 0 DO 20 J = 1, N DO 10 I = 1, J K = K + 1 AP(K) = A(I,J) 10 CONTINUE 20 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS SAXPY,SSWAP,ISAMAX Fortran ABS,AMAX1,SQRT
SSPSL
SUBROUTINE SSPSL(AP,N,KPVT,B) SSISL solves the real symmetric system A * X = B using the factors computed by SSPFA. On Entry AP REAL(N*(N+1)/2) the output from SSPFA. N INTEGER the order of the matrix A . KPVT INTEGER(N) the pivot vector from SSPFA. B REAL(N) the right hand side vector. On Return B the solution vector X . Error Condition A division by zero may occur if SSPCO has set RCOND .EQ. 0.0 or SSPFA has set INFO .NE. 0 . To compute INVERSE(A) * C where C is a matrix with P columns CALL SSPFA(AP,N,KPVT,INFO) IF (INFO .NE. 0) GO TO ... DO 10 J = 1, P CALL SSPSL(AP,N,KPVT,C(1,J)) 10 CONTINUE LINPACK. This version dated 08/14/78 . James Bunch, Univ. Calif. San Diego, Argonne Nat. Lab. Subroutines and Functions BLAS SAXPY,SDOT Fortran IABS
SSVDC
SUBROUTINE SSVDC(X,LDX,N,P,S,E,U,LDU,V,LDV,WORK,JOB,INFO) SSVDC is a subroutine to reduce a real NxP matrix X by orthogonal transformations U and V to diagonal form. The diagonal elements S(I) are the singular values of X. The columns of U are the corresponding left singular vectors, and the columns of V the right singular vectors. On Entry X REAL(LDX,P), where LDX .GE. N. X contains the matrix whose singular value decomposition is to be computed. X is destroyed by SSVDC. LDX INTEGER LDX is the leading dimension of the array X. N INTEGER N is the number of columns of the matrix X. P INTEGER P is the number of rows of the matrix X. LDU INTEGER LDU is the leading dimension of the array U. (See below). LDV INTEGER LDV is the leading dimension of the array V. (See below). WORK REAL(N) work is a scratch array. JOB INTEGER JOB controls the computation of the singular vectors. It has the decimal expansion AB with the following meaning A .EQ. 0 Do not compute the left singular vectors. A .EQ. 1 Return the N left singular vectors in U. A .GE. 2 Return the first MIN(N,P) singular vectors in U. B .EQ. 0 Do not compute the right singular vectors. B .EQ. 1 Return the right singular vectors in V. On Return S REAL(MM), where MM=MIN(N+1,P). The first MIN(N,P) entries of S contain the singular values of X arranged in descending order of magnitude. E REAL(P). E ordinarily contains zeros. However, see the discussion of INFO for exceptions. U REAL(LDU,K), where LDU .GE. N. If JOBA .EQ. 1, then K .EQ. N. If JOBA .GE. 2 , then K .EQ. MIN(N,P). U contains the matrix of right singular vectors. U is not referenced if JOBA .EQ. 0. If N .LE. P or if JOBA .EQ. 2, then U may be identified with X in the subroutine call. V REAL(LDV,P), where LDV .GE. P. V contains the matrix of right singular vectors. V is not referenced if JOB .EQ. 0. If P .LE. N, then V may be identified with X in the subroutine call. INFO INTEGER. the singular values (and their corresponding singular vectors) S(INFO+1),S(INFO+2),...,S(M) are correct (here M=MIN(N,P)). Thus if INFO .EQ. 0, all the singular values and their vectors are correct. In any event, the matrix B = TRANS(U)*X*V is the bidiagonal matrix with the elements of S on its diagonal and the elements of E on its super-diagonal (TRANS(U) is the transpose of U). Thus the singular values of X and B are the same. LINPACK. This version dated 03/19/79 . G. W. Stewart, University of Maryland, Argonne National Lab. ***** Uses the following functions and subprograms. External SROT BLAS SAXPY,SDOT,SSCAL,SSWAP,SNRM2,SROTG Fortran ABS,AMAX1,MAX0,MIN0,MOD,SQRT
SSWAP
SUBROUTINE SSWAP(N,SX,INCX,SY,INCY) B L A S Subprogram Description of Parameters --Input-- N number of elements in input vector(s) SX single precision vector with N elements INCX storage spacing between elements of SX SY single precision vector with N elements INCY storage spacing between elements of SY --Output-- SX input vector SY (unchanged if N .LE. 0) SY input vector SX (unchanged if N .LE. 0) Interchange single precision SX and single precision SY. For I = 0 to N-1, interchange SX(LX+I*INCX) and SY(LY+I*INCY), where LX = 1 if INCX .GE. 0, else LX = (-INCX)*N, and LY is defined in a similar way using INCY.
STRCO
SUBROUTINE STRCO(T,LDT,N,RCOND,Z,JOB) STRCO estimates the condition of a real triangular matrix. On Entry T REAL(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 0 T is lower triangular. = nonzero T is upper triangular. On Return RCOND REAL an estimate of the reciprocal condition of T . For the system T*X = B , relative perturbations in T and B of size EPSILON may cause relative perturbations in X of size EPSILON/RCOND . If RCOND is so small that the logical expression 1.0 + RCOND .EQ. 1.0 is true, then T may be singular to working precision. In particular, RCOND is zero if exact singularity is detected or the estimate underflows. Z REAL(N) a work vector whose contents are usually unimportant. If T is close to a singular matrix, then Z is an approximate null vector in the sense that NORM(A*Z) = RCOND*NORM(A)*NORM(Z) . LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL,SASUM Fortran ABS,AMAX1,SIGN
STRDI
SUBROUTINE STRDI(T,LDT,N,DET,JOB,INFO) STRDI computes the determinant and inverse of a real triangular matrix. On Entry T REAL(LDT,N) T contains the triangular matrix. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. JOB INTEGER = 010 no det, inverse of lower triangular. = 011 no det, inverse of upper triangular. = 100 det, no inverse. = 110 det, inverse of lower triangular. = 111 det, inverse of upper triangular. On Return T inverse of original matrix if requested. Otherwise unchanged. DET REAL(2) determinant of original matrix if requested. Otherwise not referenced. Determinant = DET(1) * 10.0**DET(2) with 1.0 .LE. ABS(DET(1)) .LT. 10.0 or DET(1) .EQ. 0.0 . INFO INTEGER INFO contains zero if the system is nonsingular and the inverse is requested. Otherwise INFO contains the index of a zero diagonal element of T. LINPACK. This version dated 08/14/78 . Cleve Moler, University of New Mexico, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SSCAL Fortran ABS,MOD
STRSL
SUBROUTINE STRSL(T,LDT,N,B,JOB,INFO) STRSL solves systems of the form T * X = B or TRANS(T) * X = B where T is a triangular matrix of order N. Here TRANS(T) denotes the transpose of the matrix T. On Entry T REAL(LDT,N) T contains the matrix of the system. The zero elements of the matrix are not referenced, and the corresponding elements of the array can be used to store other information. LDT INTEGER LDT is the leading dimension of the array T. N INTEGER N is the order of the system. B REAL(N). B contains the right hand side of the system. JOB INTEGER JOB specifies what kind of system is to be solved. If JOB is 00 solve T*X=B, T lower triangular, 01 solve T*X=B, T upper triangular, 10 solve TRANS(T)*X=B, T lower triangular, 11 solve TRANS(T)*X=B, T upper triangular. On Return B B contains the solution, if INFO .EQ. 0. Otherwise B is unaltered. INFO INTEGER INFO contains zero if the system is nonsingular. Otherwise INFO contains the index of the first zero diagonal element of T. LINPACK. This version dated 08/14/78 . G. W. Stewart, University of Maryland, Argonne National Lab. Subroutines and Functions BLAS SAXPY,SDOT Fortran MOD
STWAY
SUBROUTINE STWAY(U,V,YHP,INOUT,STOWA)
SUDS
SUBROUTINE SUDS(A,X,B,NEQ,NUK,NRDA,IFLAG,MLSO,WORK,IWORK)
SVCO
SUBROUTINE SVCO(RSAV,ISAV)
SVD
SUBROUTINE SVD(NM,M,N,A,W,MATU,U,MATV,V,IERR,RV1)
SVECS
SUBROUTINE SVECS(NCOMP,LNFC,YHP,WORK,IWORK,INHOMO,IFLAG)
SVOUT
SUBROUTINE SVOUT(N,SX,IFMT,IDIGIT) SVOUT REVISED FEB. 27, 1981. SINGLE PRECISION VECTOR OUTPUT ROUTINE. INPUT.. N,SX(*) PRINT THE SINGLE PRECISION ARRAY SX(I),I=1,...,N, ON OUTPUT UNIT LOUT. THE HEADING IN THE FORTRAN FORMAT STATEMENT IFMT(*), DESCRIBED BELOW, IS PRINTED AS A FIRST STEP. THE COMPONENTS SX(I) ARE INDEXED, ON OUTPUT, IN A PLEASANT FORMAT. IFMT(*) A FORTRAN FORMAT STATEMENT. THIS IS PRINTED ON OUTPUT UNIT LOUT WITH THE VARIABLE FORMAT FORTRAN STATEMENT WRITE(LOUT,IFMT) IDIGIT PRINT AT LEAST IABS(IDIGIT) DECIMAL DIGITS PER NUMBER. THE SUBPROGRAM WILL CHOOSE THAT INTEGER 4,6,10 OR 14 WHICH WILL PRINT AT LEAST IABS(IDIGIT) NUMBER OF PLACES. IF IDIGIT.LT.0, 72 PRINTING COLUMNS ARE UTILIZED TO WRITE EACH LINE OF OUTPUT OF THE ARRAY SX(*). (THIS CAN BE USED ON MOST TIME-SHARING TERMINALS). IF IDIGIT.GE.0, 133 PRINTING COLUMNS ARE UTILIZED. (THIS CAN BE USED ON MOST LINE PRINTERS). EXAMPLE.. PRINT AN ARRAY CALLED (COSTS OF PURCHASES) OF LENGTH 100 SHOWING 6 DECIMAL DIGITS PER NUMBER. THE USER IS RUNNING ON A TIME-SHARING SYSTEM WITH A 72 COLUMN OUTPUT DEVICE. DIMENSION COSTS(100) N = 100 IDIGIT = -6 CALL SVOUT(N,COSTS,'(''1COSTS OF PURCHASES'')',IDIGIT) AUTHORS JOHN A. WISNIEWSKI SANDIA LABS ALBUQUERQUE. RICHARD J. HANSON SANDIA LABS ALBUQUERQUE. DATE JULY 27,1978.
SWRITP
SUBROUTINE SWRITP(IPAGE,LIST,RLIST,LPAGE,IREC) WRITE RECORD NUMBER IRECN, OF LENGTH LPG, FROM STORAGE ARRAY LIST(*) ONTO UNIT NUMBER IPAGEF. WRITE RECORD NUMBER IRECN+1, OF LENGTH LPG, ONTO UNIT NUMBER IPAGEF FROM THE STORAGE ARRAY RLIST(*). TO CHANGE THIS PROGRAM UNIT TO DOUBLE PRECISION CHANGE /REAL (12 BLANKS)/ TO /DOUBLE PRECISION/.
TEVLC
SUBROUTINE TEVLC(N,D,E2,IERR)
TEVLS
SUBROUTINE TEVLS(N,D,E2,IERR)
TINVIT
SUBROUTINE TINVIT(NM,N,D,E,E2,M,W,IND,Z,IERR,RV1,RV2,RV3,RV4,RV6) This subroutine is a translation of the inverse iteration tech- nique in the ALGOL procedure TRISTURM by Peters and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 418-439(1971). This subroutine finds those eigenvectors of a TRIDIAGONAL SYMMETRIC matrix corresponding to specified eigenvalues, using inverse iteration. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E, with zeros corresponding to negligible elements of E. E(I) is considered negligible if it is not larger than the product of the relative machine precision and the sum of the magnitudes of D(I) and D(I-1). E2(1) must contain 0.0e0 if the eigenvalues are in ascending order, or 2.0e0 if the eigenvalues are in descending order. If BISECT, TRIDIB, or IMTQLV has been used to find the eigenvalues, their output E2 array is exactly what is expected here. M is the number of specified eigenvalues. W CONTAINS the M eigenvalues in ascending or descending order. IND contains in its first M positions the submatrix indices associated with the corresponding eigenvalues in W -- 1 for eigenvalues belonging to the first submatrix from the top, 2 for those belonging to the second submatrix, etc. On Output ** All input arrays are unaltered.** Z contains the associated set of orthonormal eigenvectors. any vector which fails to converge is set to zero. IERR is set to Zero for normal return, -R if the eigenvector corresponding to the R-th eigenvalue fails to converge in 5 iterations. RV1, RV2, RV3, RV4, and RV6 are temporary storage arrays. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TQL1
SUBROUTINE TQL1(N,D,E,IERR) This subroutine is a translation of the ALGOL procedure TQL1, NUM. MATH. 11, 293-306(1968) by Bowdler, Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 227-240(1971). This subroutine finds the eigenvalues of a SYMMETRIC TRIDIAGONAL matrix by the QL method. On Input N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. On Output D contains the eigenvalues in ascending order. If an error exit is made, the eigenvalues are correct and ordered for indices 1,2,...IERR-1, but may not be the smallest eigenvalues. E has been destroyed. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TQL2
SUBROUTINE TQL2(NM,N,D,E,Z,IERR) This subroutine is a translation of the ALGOL procedure TQL2, NUM. MATH. 11, 293-306(1968) by Bowdler, Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 227-240(1971). This subroutine finds the eigenvalues and eigenvectors of a SYMMETRIC TRIDIAGONAL matrix by the QL method. The eigenvectors of a FULL SYMMETRIC matrix can also be found if TRED2 has been used to reduce this full matrix to tridiagonal form. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. Z contains the transformation matrix produced in the reduction by TRED2, if performed. If the eigenvectors of the tridiagonal matrix are desired, Z must contain the identity matrix. On Output D contains the eigenvalues in ascending order. If an error exit is made, the eigenvalues are correct but unordered for indices 1,2,...,IERR-1. E has been destroyed. Z contains orthonormal eigenvectors of the symmetric tridiagonal (or full) matrix. If an error exit is made, Z contains the eigenvectors associated with the stored eigenvalues. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TQLRAT
SUBROUTINE TQLRAT(N,D,E2,IERR) This subroutine is a translation of the ALGOL procedure TQLRAT, ALGORITHM 464, COMM. ACM 16, 689(1973) by Reinsch. This subroutine finds the eigenvalues of a SYMMETRIC TRIDIAGONAL matrix by the rational QL method. On Input N is the order of the matrix. D contains the diagonal elements of the input matrix. E2 contains the squares of the subdiagonal elements of the input matrix in its last N-1 positions. E2(1) is arbitrary. On Output D contains the eigenvalues in ascending order. If an error exit is made, the eigenvalues are correct and ordered for indices 1,2,...IERR-1, but may not be the smallest eigenvalues. E2 has been destroyed. IERR is set to Zero for normal return, J if the J-th eigenvalue has not been determined after 30 iterations. Calls PYTHAG(A,B) for sqrt(A**2 + B**2). Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRBAK1
SUBROUTINE TRBAK1(NM,N,A,E,M,Z) This subroutine is a translation of the ALGOL procedure TRBAK1, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine forms the eigenvectors of a REAL SYMMETRIC matrix by back transforming those of the corresponding symmetric tridiagonal matrix determined by TRED1. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains information about the orthogonal trans- formations used in the reduction by TRED1 in its strict lower triangle. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is arbitrary. M is the number of eigenvectors to be back transformed. Z contains the eigenvectors to be back transformed in its first M columns. On Output Z contains the transformed eigenvectors in its first M columns. Note that TRBAK1 preserves vector Euclidean norms. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRBAK3
SUBROUTINE TRBAK3(NM,N,NV,A,M,Z) This subroutine is a translation of the ALGOL procedure TRBAK3, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine forms the eigenvectors of a REAL SYMMETRIC matrix by back transforming those of the corresponding symmetric tridiagonal matrix determined by TRED3. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. NV must be set to the dimension of the array parameter A as declared in the calling program dimension statement. A contains information about the orthogonal transformations used in the reduction by TRED3 in its first N*(N+1)/2 positions. M is the number of eigenvectors to be back transformed. Z contains the eigenvectors to be back transformed in its first M columns. On Output Z contains the transformed eigenvectors in its first M columns. Note that TRBAK3 preserves vector Euclidean norms. Questions and comments should be directed to b. s. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRED1
SUBROUTINE TRED1(NM,N,A,D,E,E2) This subroutine is a translation of the ALGOL procedure TRED1, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine reduces a REAL SYMMETRIC matrix to a symmetric tridiagonal matrix using orthogonal similarity transformations. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains the real symmetric input matrix. Only the lower triangle of the matrix need be supplied. On Output A contains information about the orthogonal trans- formations used in the reduction in its strict lower triangle. The full upper triangle of A is unaltered. D contains the diagonal elements of the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRED2
SUBROUTINE TRED2(NM,N,A,D,E,Z) This subroutine is a translation of the ALGOL procedure TRED2, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine reduces a REAL SYMMETRIC matrix to a symmetric tridiagonal matrix using and accumulating orthogonal similarity transformations. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. A contains the real symmetric input matrix. Only the lower triangle of the matrix need be supplied. On Output D contains the diagonal elements of the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. Z contains the orthogonal transformation matrix produced in the reduction. A and Z may coincide. If distinct, A is unaltered. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRED3
SUBROUTINE TRED3(N,NV,A,D,E,E2) This subroutine is a translation of the ALGOL procedure TRED3, NUM. MATH. 11, 181-195(1968) by Martin, Reinsch, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 212-226(1971). This subroutine reduces a REAL SYMMETRIC matrix, stored as a one-dimensional array, to a symmetric tridiagonal matrix using orthogonal similarity transformations. On Input n is the order of the matrix. NV must be set to the dimension of the array parameter A as declared in the calling program dimension statement. A contains the lower triangle of the real symmetric input matrix, stored row-wise as a one-dimensional array, in its first N*(N+1)/2 positions. On Output A contains information about the orthogonal transformations used in the reduction. D contains the diagonal elements of the tridiagonal matrix. E contains the subdiagonal elements of the tridiagonal matrix in its last N-1 positions. E(1) is set to zero. E2 contains the squares of the corresponding elements of E. E2 may coincide with E if the squares are not needed. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRI3
SUBROUTINE TRI3(M,A,B,C,K,Y1,Y2,Y3,TCOS,D,W1,W2,W3)
TRID
SUBROUTINE TRID(MR,A,B,C,Y,D)
TRIDIB
SUBROUTINE TRIDIB(N,EPS1,D,E,E2,LB,UB,M11,M,W,IND,IERR,RV4,RV5) This subroutine is a translation of the ALGOL procedure BISECT, NUM. MATH. 9, 386-393(1967) by Barth, Martin, and Wilkinson. HANDBOOK FOR AUTO. COMP., VOL.II-LINEAR ALGEBRA, 249-256(1971). This subroutine finds those eigenvalues of a TRIDIAGONAL SYMMETRIC matrix between specified boundary indices, using bisection. On Input N is the order of the matrix. EPS1 is an absolute error tolerance for the computed eigenvalues. If the input EPS1 is non-positive, it is reset for each submatrix to a default value, namely, minus the product of the relative machine precision and the 1-norm of the submatrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E. E2(1) is arbitrary. M11 specifies the lower boundary index for the desired eigenvalues. M specifies the number of eigenvalues desired. The upper boundary index M22 is then obtained as M22=M11+M-1. On Output EPS1 is unaltered unless it has been reset to its (last) default value. D and E are unaltered. ELEMENTS of E2, corresponding to elements of E regarded as negligible, have been replaced by zero causing the matrix to split into a direct sum of submatrices. E2(1) is also set to zero. LB and UB DEFINE an interval containing exactly the desired eigenvalues. W contains, in its first M positions, the eigenvalues between indices M11 and M22 in ascending order. IND contains in its first M positions the submatrix indices associated with the corresponding eigenvalues in W -- 1 for eigenvalues belonging to the first submatrix from the top, 2 for those belonging to the second submatrix, etc. IERR is set to Zero for normal return, 3*N+1 if multiple eigenvalues at index M11 make unique selection impossible, 3*N+2 if multiple eigenvalues at index M22 make unique selection impossible. RV4 and RV5 are temporary storage arrays. Note that subroutine TQL1, IMTQL1, or TQLRAT is generally faster than TRIDIB, if more than N/4 eigenvalues are to be found. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
TRIS4
SUBROUTINE TRIS4(N,A,B,C,D,U,Z)
TRISP
SUBROUTINE TRISP(N,A,B,C,D,U,Z)
TRIX
SUBROUTINE TRIX(IDEGBR,IDEGCR,M,A,B,C,Y,TCOS,D,W)
TSTURM
SUBROUTINE TSTURM(NM,N,EPS1,D,E,E2,LB,UB,MM,M,W,Z,IERR,RV1,RV2, This subroutine finds those eigenvalues of a TRIDIAGONAL SYMMETRIC matrix which lie in a specified interval and their associated eigenvectors, using bisection and inverse iteration. On Input NM must be set to the row dimension of two-dimensional array parameters as declared in the calling program dimension statement. N is the order of the matrix. EPS1 is an absolute error tolerance for the computed eigenvalues. It should be chosen commensurate with relative perturbations in the matrix elements of the order of the relative machine precision. If the input EPS1 is non-positive, it is reset for each submatrix to a default value, namely, minus the product of the relative machine precision and the 1-norm of the submatrix. D contains the diagonal elements of the input matrix. E contains the subdiagonal elements of the input matrix in its last N-1 positions. E(1) is arbitrary. E2 contains the squares of the corresponding elements of E. E2(1) is arbitrary. LB and UB define the interval to be searched for eigenvalues. If LB is not less than UB, no eigenvalues will be found. MM should be set to an upper bound for the number of eigenvalues in the interval. WARNING. If more than MM eigenvalues are determined to lie in the interval, an error return is made with no values or vectors found. On Output EPS1 is unaltered unless it has been reset to its (last) default value. D and E are unaltered. ELEMENTS of E2, corresponding to elements of E regarded as negligible, have been replaced by zero causing the matrix to split into a direct sum of submatrices. E2(1) is also set to zero. M is the number of eigenvalues determined to lie in (LB,UB). W contains the M eigenvalues in ascending order if the matrix does not split. If the matrix splits, the eigenvalues are in ascending order for each submatrix. If a vector error exit is made, W contains those values already found. Z contains the associated set of orthonormal eigenvectors. If an error exit is made, Z contains those vectors already found. IERR is set to Zero for normal return, 3*N+1 if M exceeds MM. 4*N+R if the eigenvector corresponding to the R-th eigenvalue fails to converge in 5 iterations. RV1, RV2, RV3, RV4, RV5, and RV6 are temporary storage arrays. The ALGOL procedure STURMCNT contained in TRISTURM appears in TSTURM in-line. Questions and comments should be directed to B. S. Garbow, APPLIED MATHEMATICS DIVISION, ARGONNE NATIONAL LABORATORY
U11LS
SUBROUTINE U11LS(A,MDA,M,N,UB,DB,MODE,NP,KRANK,KSURE,H,W,EB,IC, This routine performs a QR factorization of A using Householder transformations. Row and column pivots are chosen to reduce the growth of round-off and to help detect possible rank deficiency.
U11US
SUBROUTINE U11US(A,MDA,M,N,UB,DB,MODE,NP,KRANK,KSURE,H,W,EB,IR, This routine performs an LQ factorization of the matrix A using Householder transformations. Row and column pivots are chosen to reduce the growth of round-off and to help detect possible rank deficiency.
U12LS
SUBROUTINE U12LS(A,MDA,M,N,B,MDB,NB,MODE,KRANK,RNORM,H,W,IC,IR) Given the Householder QR factorization of A, this subroutine solves the system AX=B. If the system is of reduced rank, this routine returns a solution according to the selected mode. Note - If MODE.NE.2, W is never accessed.
U12US
SUBROUTINE U12US(A,MDA,M,N,B,MDB,NB,MODE,KRANK,RNORM,H,W,IR,IC) Given the Householder LQ factorization of A, this subroutine solves the system AX=B. If the system is of reduced rank, this routine returns a solution according to the selected mode. Note - If MODE.NE.2, W is never accessed.
ULSIA
SUBROUTINE ULSIA(A,MDA,M,N,B,MDB,NB,RE,AE,KEY,MODE,NP,KRANK, ULSIA computes the minimal length solution(s) to the problem AX=B where A is an M by N matrix with M.LE.N and B is the M by NB matrix of right hand sides. User input bounds on the uncertainty in the elements of A are used to detect numerical rank deficiency. The algorithm employs a row and column pivot strategy to minimize the growth of uncertainty and round-off errors. ULSIA requires (MDA+1)*N + (MDB+1)*NB + 6*M dimensioned space ****************************************************************** * * * WARNING - All input arrays are changed on exit. * * * ****************************************************************** Input.. A(,) Linear coefficient matrix of AX=B, with MDA the MDA,M,N actual first dimension of A in the calling program. M is the row dimension (no. of EQUATIONS of the problem) and N the col dimension (no. of UNKNOWNS). Must have MDA.GE.M and M.LE.N. B(,) Right hand side(s), with MDB the actual first MDB,NB dimension of B in the calling program. NB is the number of M by 1 right hand sides. Since the solutio is returned in B, must have MDB.GE.N. If NB = 0, B i never accessed. ****************************************************************** * * * Note - Use of RE and AE are what make this * * code significantly different from * * other linear least squares solvers. * * However, the inexperienced user is * * advised to set RE=0.,AE=0.,KEY=0. * * * ****************************************************************** RE(),AE(),KEY RE() RE() is a vector of length N such that RE(I) is the maximum relative uncertainty in row I of the matrix A. The values of RE() must be between 0 and 1. A minimum of 10*machine precision will be enforced. AE() AE() is a vector of length N such that AE(I) is the maximum absolute uncertainty in row I of the matrix A. The values of AE() must be greater than or equal to 0. KEY For ease of use, RE and AE may be input as either vectors or scalars. If a scalar is input, the algo- rithm will use that value for each column of A. The parameter KEY indicates whether scalars or vectors are being input. KEY=0 RE scalar AE scalar KEY=1 RE vector AE scalar KEY=2 RE scalar AE vector KEY=3 RE vector AE vector MODE The integer MODE indicates how the routine is to react if rank deficiency is detected. If MODE = 0 return immediately, no solution 1 compute truncated solution 2 compute minimal length least squares sol The inexperienced user is advised to set MODE=0 NP The first NP rows of A will not be interchanged with other rows even though the pivot strategy would suggest otherwise. The inexperienced user is advised to set NP=0. WORK() A real work array dimensioned 5*M. However,if RE or AE have been specified as vectors, dimension WORK 4*M. If both RE and AE have been specified as vectors, dimension WORK 3*M. LW Actual dimension of WORK IWORK() Integer work array dimensioned at least N+M. LIW Actual dimension of IWORK. INFO Is a flag which provides for the efficient solution of subsequent problems involving the same A but different B. If INFO = 0 original call INFO = 1 subsequent calls On subsequent calls, the user must supply A, KRANK, LW, IWORK, LIW, and the first 2*M locations of WORK as output by the original call to ULSIA. MODE must be equal to the value of MODE in the original call. If MODE.LT.2, only the first N locations of WORK are accessed. AE, RE, KEY, and NP are not accessed. Output.. A(,) Contains the lower triangular part of the reduced matrix and the transformation information. It togeth with the first M elements of WORK (see below) completely specify the LQ factorization of A. B(,) Contains the N by NB solution matrix for X. KRANK,KSURE The numerical rank of A, based upon the relative and absolute bounds on uncertainty, is bounded above by KRANK and below by KSURE. The algorithm returns a solution based on KRANK. KSURE provides an indication of the precision of the rank. RNORM() Contains the Euclidean length of the NB residual vectors B(I)-AX(I), I=1,NB. If the matrix A is of full rank, then RNORM=0.0. WORK() The first M locations of WORK contain values necessary to reproduce the Householder transformatio IWORK() The first N locations contain the order in which the columns of A were used. The next M locations contain the order in which the rows of A were used. INFO Flag to indicate status of computation on completion -1 Parameter error(s) 0 - Rank deficient, no solution 1 - Rank deficient, truncated solution 2 - Rank deficient, minimal length least squares sol 3 - Numerical rank 0, zero solution 4 - Rank .LT. NP 5 - Full rank
USRMAT
SUBROUTINE USRMAT(I,J,AIJ,INDCAT,PRGOPT,DATTRV,IFLAG) The user may supply this code
VNORM
FUNCTION VNORM(V,NCOMP)
VNWRMS
REAL FUNCTION VNWRMS(N,V,W)
WNLIT
SUBROUTINE WNLIT(W,MDW,M,N,L,IPIVOT,ITYPE,H,SCALE,RNORM,IDOPE,
WNLSM
SUBROUTINE WNLSM(W,MDW,MME,MA,N,L,PRGOPT,X,RNORM,MODE,IPIVOT,