|
kusano |
2b45e8 |
SUBROUTINE DTBSVF(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
INTEGER INCX,K,LDA,N
|
|
kusano |
2b45e8 |
CHARACTER DIAG,TRANS,UPLO
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION A(LDA,*),X(*)
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DTBSV solves one of the systems of equations
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A*x = b, or A'*x = b,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* where b and x are n element vectors and A is an n by n unit, or
|
|
kusano |
2b45e8 |
* non-unit, upper or lower triangular band matrix, with ( k + 1 )
|
|
kusano |
2b45e8 |
* diagonals.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* No test for singularity or near-singularity is included in this
|
|
kusano |
2b45e8 |
* routine. Such tests must be performed before calling this routine.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* ==========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO - CHARACTER*1.
|
|
kusano |
2b45e8 |
* On entry, UPLO specifies whether the matrix is an upper or
|
|
kusano |
2b45e8 |
* lower triangular matrix as follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'U' or 'u' A is an upper triangular matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'L' or 'l' A is a lower triangular matrix.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* TRANS - CHARACTER*1.
|
|
kusano |
2b45e8 |
* On entry, TRANS specifies the equations to be solved as
|
|
kusano |
2b45e8 |
* follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* TRANS = 'N' or 'n' A*x = b.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* TRANS = 'T' or 't' A'*x = b.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* TRANS = 'C' or 'c' A'*x = b.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DIAG - CHARACTER*1.
|
|
kusano |
2b45e8 |
* On entry, DIAG specifies whether or not A is unit
|
|
kusano |
2b45e8 |
* triangular as follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DIAG = 'U' or 'u' A is assumed to be unit triangular.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DIAG = 'N' or 'n' A is not assumed to be unit
|
|
kusano |
2b45e8 |
* triangular.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, N specifies the order of the matrix A.
|
|
kusano |
2b45e8 |
* N must be at least zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* K - INTEGER.
|
|
kusano |
2b45e8 |
* On entry with UPLO = 'U' or 'u', K specifies the number of
|
|
kusano |
2b45e8 |
* super-diagonals of the matrix A.
|
|
kusano |
2b45e8 |
* On entry with UPLO = 'L' or 'l', K specifies the number of
|
|
kusano |
2b45e8 |
* sub-diagonals of the matrix A.
|
|
kusano |
2b45e8 |
* K must satisfy 0 .le. K.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
|
|
kusano |
2b45e8 |
* Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
|
|
kusano |
2b45e8 |
* by n part of the array A must contain the upper triangular
|
|
kusano |
2b45e8 |
* band part of the matrix of coefficients, supplied column by
|
|
kusano |
2b45e8 |
* column, with the leading diagonal of the matrix in row
|
|
kusano |
2b45e8 |
* ( k + 1 ) of the array, the first super-diagonal starting at
|
|
kusano |
2b45e8 |
* position 2 in row k, and so on. The top left k by k triangle
|
|
kusano |
2b45e8 |
* of the array A is not referenced.
|
|
kusano |
2b45e8 |
* The following program segment will transfer an upper
|
|
kusano |
2b45e8 |
* triangular band matrix from conventional full matrix storage
|
|
kusano |
2b45e8 |
* to band storage:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DO 20, J = 1, N
|
|
kusano |
2b45e8 |
* M = K + 1 - J
|
|
kusano |
2b45e8 |
* DO 10, I = MAX( 1, J - K ), J
|
|
kusano |
2b45e8 |
* A( M + I, J ) = matrix( I, J )
|
|
kusano |
2b45e8 |
* 10 CONTINUE
|
|
kusano |
2b45e8 |
* 20 CONTINUE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
|
|
kusano |
2b45e8 |
* by n part of the array A must contain the lower triangular
|
|
kusano |
2b45e8 |
* band part of the matrix of coefficients, supplied column by
|
|
kusano |
2b45e8 |
* column, with the leading diagonal of the matrix in row 1 of
|
|
kusano |
2b45e8 |
* the array, the first sub-diagonal starting at position 1 in
|
|
kusano |
2b45e8 |
* row 2, and so on. The bottom right k by k triangle of the
|
|
kusano |
2b45e8 |
* array A is not referenced.
|
|
kusano |
2b45e8 |
* The following program segment will transfer a lower
|
|
kusano |
2b45e8 |
* triangular band matrix from conventional full matrix storage
|
|
kusano |
2b45e8 |
* to band storage:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* DO 20, J = 1, N
|
|
kusano |
2b45e8 |
* M = 1 - J
|
|
kusano |
2b45e8 |
* DO 10, I = J, MIN( N, J + K )
|
|
kusano |
2b45e8 |
* A( M + I, J ) = matrix( I, J )
|
|
kusano |
2b45e8 |
* 10 CONTINUE
|
|
kusano |
2b45e8 |
* 20 CONTINUE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Note that when DIAG = 'U' or 'u' the elements of the array A
|
|
kusano |
2b45e8 |
* corresponding to the diagonal elements of the matrix are not
|
|
kusano |
2b45e8 |
* referenced, but are assumed to be unity.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, LDA specifies the first dimension of A as declared
|
|
kusano |
2b45e8 |
* in the calling (sub) program. LDA must be at least
|
|
kusano |
2b45e8 |
* ( k + 1 ).
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* X - DOUBLE PRECISION array of dimension at least
|
|
kusano |
2b45e8 |
* ( 1 + ( n - 1 )*abs( INCX ) ).
|
|
kusano |
2b45e8 |
* Before entry, the incremented array X must contain the n
|
|
kusano |
2b45e8 |
* element right-hand side vector b. On exit, X is overwritten
|
|
kusano |
2b45e8 |
* with the solution vector x.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* INCX - INTEGER.
|
|
kusano |
2b45e8 |
* On entry, INCX specifies the increment for the elements of
|
|
kusano |
2b45e8 |
* X. INCX must not be zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Level 2 Blas routine.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- Written on 22-October-1986.
|
|
kusano |
2b45e8 |
* Jack Dongarra, Argonne National Lab.
|
|
kusano |
2b45e8 |
* Jeremy Du Croz, Nag Central Office.
|
|
kusano |
2b45e8 |
* Sven Hammarling, Nag Central Office.
|
|
kusano |
2b45e8 |
* Richard Hanson, Sandia National Labs.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION ZERO
|
|
kusano |
2b45e8 |
PARAMETER (ZERO=0.0D+0)
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
DOUBLE PRECISION TEMP
|
|
kusano |
2b45e8 |
INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
|
|
kusano |
2b45e8 |
LOGICAL NOUNIT
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL XERBLA
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC MAX,MIN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
|
|
kusano |
2b45e8 |
INFO = 1
|
|
kusano |
2b45e8 |
ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
|
|
kusano |
2b45e8 |
+ .NOT.LSAME(TRANS,'C')) THEN
|
|
kusano |
2b45e8 |
INFO = 2
|
|
kusano |
2b45e8 |
ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
|
|
kusano |
2b45e8 |
INFO = 3
|
|
kusano |
2b45e8 |
ELSE IF (N.LT.0) THEN
|
|
kusano |
2b45e8 |
INFO = 4
|
|
kusano |
2b45e8 |
ELSE IF (K.LT.0) THEN
|
|
kusano |
2b45e8 |
INFO = 5
|
|
kusano |
2b45e8 |
ELSE IF (LDA.LT. (K+1)) THEN
|
|
kusano |
2b45e8 |
INFO = 7
|
|
kusano |
2b45e8 |
ELSE IF (INCX.EQ.0) THEN
|
|
kusano |
2b45e8 |
INFO = 9
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF (INFO.NE.0) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA('DTBSV ',INFO)
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF (N.EQ.0) RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
NOUNIT = LSAME(DIAG,'N')
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Set up the start point in X if the increment is not unity. This
|
|
kusano |
2b45e8 |
* will be ( N - 1 )*INCX too small for descending loops.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF (INCX.LE.0) THEN
|
|
kusano |
2b45e8 |
KX = 1 - (N-1)*INCX
|
|
kusano |
2b45e8 |
ELSE IF (INCX.NE.1) THEN
|
|
kusano |
2b45e8 |
KX = 1
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Start the operations. In this version the elements of A are
|
|
kusano |
2b45e8 |
* accessed by sequentially with one pass through A.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF (LSAME(TRANS,'N')) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form x := inv( A )*x.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF (LSAME(UPLO,'U')) THEN
|
|
kusano |
2b45e8 |
KPLUS1 = K + 1
|
|
kusano |
2b45e8 |
IF (INCX.EQ.1) THEN
|
|
kusano |
2b45e8 |
DO 20 J = N,1,-1
|
|
kusano |
2b45e8 |
IF (X(J).NE.ZERO) THEN
|
|
kusano |
2b45e8 |
L = KPLUS1 - J
|
|
kusano |
2b45e8 |
IF (NOUNIT) X(J) = X(J)/A(KPLUS1,J)
|
|
kusano |
2b45e8 |
TEMP = X(J)
|
|
kusano |
2b45e8 |
DO 10 I = J - 1,MAX(1,J-K),-1
|
|
kusano |
2b45e8 |
X(I) = X(I) - TEMP*A(L+I,J)
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
KX = KX + (N-1)*INCX
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 40 J = N,1,-1
|
|
kusano |
2b45e8 |
KX = KX - INCX
|
|
kusano |
2b45e8 |
IF (X(JX).NE.ZERO) THEN
|
|
kusano |
2b45e8 |
IX = KX
|
|
kusano |
2b45e8 |
L = KPLUS1 - J
|
|
kusano |
2b45e8 |
IF (NOUNIT) X(JX) = X(JX)/A(KPLUS1,J)
|
|
kusano |
2b45e8 |
TEMP = X(JX)
|
|
kusano |
2b45e8 |
DO 30 I = J - 1,MAX(1,J-K),-1
|
|
kusano |
2b45e8 |
X(IX) = X(IX) - TEMP*A(L+I,J)
|
|
kusano |
2b45e8 |
IX = IX - INCX
|
|
kusano |
2b45e8 |
30 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
JX = JX - INCX
|
|
kusano |
2b45e8 |
40 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
IF (INCX.EQ.1) THEN
|
|
kusano |
2b45e8 |
DO 60 J = 1,N
|
|
kusano |
2b45e8 |
IF (X(J).NE.ZERO) THEN
|
|
kusano |
2b45e8 |
L = 1 - J
|
|
kusano |
2b45e8 |
IF (NOUNIT) X(J) = X(J)/A(1,J)
|
|
kusano |
2b45e8 |
TEMP = X(J)
|
|
kusano |
2b45e8 |
DO 50 I = J + 1,MIN(N,J+K)
|
|
kusano |
2b45e8 |
X(I) = X(I) - TEMP*A(L+I,J)
|
|
kusano |
2b45e8 |
50 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
60 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 80 J = 1,N
|
|
kusano |
2b45e8 |
KX = KX + INCX
|
|
kusano |
2b45e8 |
IF (X(JX).NE.ZERO) THEN
|
|
kusano |
2b45e8 |
IX = KX
|
|
kusano |
2b45e8 |
L = 1 - J
|
|
kusano |
2b45e8 |
IF (NOUNIT) X(JX) = X(JX)/A(1,J)
|
|
kusano |
2b45e8 |
TEMP = X(JX)
|
|
kusano |
2b45e8 |
DO 70 I = J + 1,MIN(N,J+K)
|
|
kusano |
2b45e8 |
X(IX) = X(IX) - TEMP*A(L+I,J)
|
|
kusano |
2b45e8 |
IX = IX + INCX
|
|
kusano |
2b45e8 |
70 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
JX = JX + INCX
|
|
kusano |
2b45e8 |
80 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form x := inv( A')*x.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF (LSAME(UPLO,'U')) THEN
|
|
kusano |
2b45e8 |
KPLUS1 = K + 1
|
|
kusano |
2b45e8 |
IF (INCX.EQ.1) THEN
|
|
kusano |
2b45e8 |
DO 100 J = 1,N
|
|
kusano |
2b45e8 |
TEMP = X(J)
|
|
kusano |
2b45e8 |
L = KPLUS1 - J
|
|
kusano |
2b45e8 |
DO 90 I = MAX(1,J-K),J - 1
|
|
kusano |
2b45e8 |
TEMP = TEMP - A(L+I,J)*X(I)
|
|
kusano |
2b45e8 |
90 CONTINUE
|
|
kusano |
2b45e8 |
IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
|
|
kusano |
2b45e8 |
X(J) = TEMP
|
|
kusano |
2b45e8 |
100 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 120 J = 1,N
|
|
kusano |
2b45e8 |
TEMP = X(JX)
|
|
kusano |
2b45e8 |
IX = KX
|
|
kusano |
2b45e8 |
L = KPLUS1 - J
|
|
kusano |
2b45e8 |
DO 110 I = MAX(1,J-K),J - 1
|
|
kusano |
2b45e8 |
TEMP = TEMP - A(L+I,J)*X(IX)
|
|
kusano |
2b45e8 |
IX = IX + INCX
|
|
kusano |
2b45e8 |
110 CONTINUE
|
|
kusano |
2b45e8 |
IF (NOUNIT) TEMP = TEMP/A(KPLUS1,J)
|
|
kusano |
2b45e8 |
X(JX) = TEMP
|
|
kusano |
2b45e8 |
JX = JX + INCX
|
|
kusano |
2b45e8 |
IF (J.GT.K) KX = KX + INCX
|
|
kusano |
2b45e8 |
120 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
IF (INCX.EQ.1) THEN
|
|
kusano |
2b45e8 |
DO 140 J = N,1,-1
|
|
kusano |
2b45e8 |
TEMP = X(J)
|
|
kusano |
2b45e8 |
L = 1 - J
|
|
kusano |
2b45e8 |
DO 130 I = MIN(N,J+K),J + 1,-1
|
|
kusano |
2b45e8 |
TEMP = TEMP - A(L+I,J)*X(I)
|
|
kusano |
2b45e8 |
130 CONTINUE
|
|
kusano |
2b45e8 |
IF (NOUNIT) TEMP = TEMP/A(1,J)
|
|
kusano |
2b45e8 |
X(J) = TEMP
|
|
kusano |
2b45e8 |
140 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
KX = KX + (N-1)*INCX
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 160 J = N,1,-1
|
|
kusano |
2b45e8 |
TEMP = X(JX)
|
|
kusano |
2b45e8 |
IX = KX
|
|
kusano |
2b45e8 |
L = 1 - J
|
|
kusano |
2b45e8 |
DO 150 I = MIN(N,J+K),J + 1,-1
|
|
kusano |
2b45e8 |
TEMP = TEMP - A(L+I,J)*X(IX)
|
|
kusano |
2b45e8 |
IX = IX - INCX
|
|
kusano |
2b45e8 |
150 CONTINUE
|
|
kusano |
2b45e8 |
IF (NOUNIT) TEMP = TEMP/A(1,J)
|
|
kusano |
2b45e8 |
X(JX) = TEMP
|
|
kusano |
2b45e8 |
JX = JX - INCX
|
|
kusano |
2b45e8 |
IF ((N-J).GE.K) KX = KX - INCX
|
|
kusano |
2b45e8 |
160 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of DTBSV .
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|