File:  [local] / rpl / lapack / blas / dtbmv.f
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Fri Jul 22 07:38:02 2011 UTC (12 years, 9 months ago) by bertrand
Branches: MAIN
CVS tags: rpl-4_1_3, rpl-4_1_2, rpl-4_1_1, HEAD
En route vers la 4.4.1.

    1:       SUBROUTINE DTBMV(UPLO,TRANS,DIAG,N,K,A,LDA,X,INCX)
    2: *     .. Scalar Arguments ..
    3:       INTEGER INCX,K,LDA,N
    4:       CHARACTER DIAG,TRANS,UPLO
    5: *     ..
    6: *     .. Array Arguments ..
    7:       DOUBLE PRECISION A(LDA,*),X(*)
    8: *     ..
    9: *
   10: *  Purpose
   11: *  =======
   12: *
   13: *  DTBMV  performs one of the matrix-vector operations
   14: *
   15: *     x := A*x,   or   x := A**T*x,
   16: *
   17: *  where x is an n element vector and  A is an n by n unit, or non-unit,
   18: *  upper or lower triangular band matrix, with ( k + 1 ) diagonals.
   19: *
   20: *  Arguments
   21: *  ==========
   22: *
   23: *  UPLO   - CHARACTER*1.
   24: *           On entry, UPLO specifies whether the matrix is an upper or
   25: *           lower triangular matrix as follows:
   26: *
   27: *              UPLO = 'U' or 'u'   A is an upper triangular matrix.
   28: *
   29: *              UPLO = 'L' or 'l'   A is a lower triangular matrix.
   30: *
   31: *           Unchanged on exit.
   32: *
   33: *  TRANS  - CHARACTER*1.
   34: *           On entry, TRANS specifies the operation to be performed as
   35: *           follows:
   36: *
   37: *              TRANS = 'N' or 'n'   x := A*x.
   38: *
   39: *              TRANS = 'T' or 't'   x := A**T*x.
   40: *
   41: *              TRANS = 'C' or 'c'   x := A**T*x.
   42: *
   43: *           Unchanged on exit.
   44: *
   45: *  DIAG   - CHARACTER*1.
   46: *           On entry, DIAG specifies whether or not A is unit
   47: *           triangular as follows:
   48: *
   49: *              DIAG = 'U' or 'u'   A is assumed to be unit triangular.
   50: *
   51: *              DIAG = 'N' or 'n'   A is not assumed to be unit
   52: *                                  triangular.
   53: *
   54: *           Unchanged on exit.
   55: *
   56: *  N      - INTEGER.
   57: *           On entry, N specifies the order of the matrix A.
   58: *           N must be at least zero.
   59: *           Unchanged on exit.
   60: *
   61: *  K      - INTEGER.
   62: *           On entry with UPLO = 'U' or 'u', K specifies the number of
   63: *           super-diagonals of the matrix A.
   64: *           On entry with UPLO = 'L' or 'l', K specifies the number of
   65: *           sub-diagonals of the matrix A.
   66: *           K must satisfy  0 .le. K.
   67: *           Unchanged on exit.
   68: *
   69: *  A      - DOUBLE PRECISION array of DIMENSION ( LDA, n ).
   70: *           Before entry with UPLO = 'U' or 'u', the leading ( k + 1 )
   71: *           by n part of the array A must contain the upper triangular
   72: *           band part of the matrix of coefficients, supplied column by
   73: *           column, with the leading diagonal of the matrix in row
   74: *           ( k + 1 ) of the array, the first super-diagonal starting at
   75: *           position 2 in row k, and so on. The top left k by k triangle
   76: *           of the array A is not referenced.
   77: *           The following program segment will transfer an upper
   78: *           triangular band matrix from conventional full matrix storage
   79: *           to band storage:
   80: *
   81: *                 DO 20, J = 1, N
   82: *                    M = K + 1 - J
   83: *                    DO 10, I = MAX( 1, J - K ), J
   84: *                       A( M + I, J ) = matrix( I, J )
   85: *              10    CONTINUE
   86: *              20 CONTINUE
   87: *
   88: *           Before entry with UPLO = 'L' or 'l', the leading ( k + 1 )
   89: *           by n part of the array A must contain the lower triangular
   90: *           band part of the matrix of coefficients, supplied column by
   91: *           column, with the leading diagonal of the matrix in row 1 of
   92: *           the array, the first sub-diagonal starting at position 1 in
   93: *           row 2, and so on. The bottom right k by k triangle of the
   94: *           array A is not referenced.
   95: *           The following program segment will transfer a lower
   96: *           triangular band matrix from conventional full matrix storage
   97: *           to band storage:
   98: *
   99: *                 DO 20, J = 1, N
  100: *                    M = 1 - J
  101: *                    DO 10, I = J, MIN( N, J + K )
  102: *                       A( M + I, J ) = matrix( I, J )
  103: *              10    CONTINUE
  104: *              20 CONTINUE
  105: *
  106: *           Note that when DIAG = 'U' or 'u' the elements of the array A
  107: *           corresponding to the diagonal elements of the matrix are not
  108: *           referenced, but are assumed to be unity.
  109: *           Unchanged on exit.
  110: *
  111: *  LDA    - INTEGER.
  112: *           On entry, LDA specifies the first dimension of A as declared
  113: *           in the calling (sub) program. LDA must be at least
  114: *           ( k + 1 ).
  115: *           Unchanged on exit.
  116: *
  117: *  X      - DOUBLE PRECISION array of dimension at least
  118: *           ( 1 + ( n - 1 )*abs( INCX ) ).
  119: *           Before entry, the incremented array X must contain the n
  120: *           element vector x. On exit, X is overwritten with the
  121: *           tranformed vector x.
  122: *
  123: *  INCX   - INTEGER.
  124: *           On entry, INCX specifies the increment for the elements of
  125: *           X. INCX must not be zero.
  126: *           Unchanged on exit.
  127: *
  128: *  Further Details
  129: *  ===============
  130: *
  131: *  Level 2 Blas routine.
  132: *  The vector and matrix arguments are not referenced when N = 0, or M = 0
  133: *
  134: *  -- Written on 22-October-1986.
  135: *     Jack Dongarra, Argonne National Lab.
  136: *     Jeremy Du Croz, Nag Central Office.
  137: *     Sven Hammarling, Nag Central Office.
  138: *     Richard Hanson, Sandia National Labs.
  139: *
  140: *  =====================================================================
  141: *
  142: *     .. Parameters ..
  143:       DOUBLE PRECISION ZERO
  144:       PARAMETER (ZERO=0.0D+0)
  145: *     ..
  146: *     .. Local Scalars ..
  147:       DOUBLE PRECISION TEMP
  148:       INTEGER I,INFO,IX,J,JX,KPLUS1,KX,L
  149:       LOGICAL NOUNIT
  150: *     ..
  151: *     .. External Functions ..
  152:       LOGICAL LSAME
  153:       EXTERNAL LSAME
  154: *     ..
  155: *     .. External Subroutines ..
  156:       EXTERNAL XERBLA
  157: *     ..
  158: *     .. Intrinsic Functions ..
  159:       INTRINSIC MAX,MIN
  160: *     ..
  161: *
  162: *     Test the input parameters.
  163: *
  164:       INFO = 0
  165:       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
  166:           INFO = 1
  167:       ELSE IF (.NOT.LSAME(TRANS,'N') .AND. .NOT.LSAME(TRANS,'T') .AND.
  168:      +         .NOT.LSAME(TRANS,'C')) THEN
  169:           INFO = 2
  170:       ELSE IF (.NOT.LSAME(DIAG,'U') .AND. .NOT.LSAME(DIAG,'N')) THEN
  171:           INFO = 3
  172:       ELSE IF (N.LT.0) THEN
  173:           INFO = 4
  174:       ELSE IF (K.LT.0) THEN
  175:           INFO = 5
  176:       ELSE IF (LDA.LT. (K+1)) THEN
  177:           INFO = 7
  178:       ELSE IF (INCX.EQ.0) THEN
  179:           INFO = 9
  180:       END IF
  181:       IF (INFO.NE.0) THEN
  182:           CALL XERBLA('DTBMV ',INFO)
  183:           RETURN
  184:       END IF
  185: *
  186: *     Quick return if possible.
  187: *
  188:       IF (N.EQ.0) RETURN
  189: *
  190:       NOUNIT = LSAME(DIAG,'N')
  191: *
  192: *     Set up the start point in X if the increment is not unity. This
  193: *     will be  ( N - 1 )*INCX   too small for descending loops.
  194: *
  195:       IF (INCX.LE.0) THEN
  196:           KX = 1 - (N-1)*INCX
  197:       ELSE IF (INCX.NE.1) THEN
  198:           KX = 1
  199:       END IF
  200: *
  201: *     Start the operations. In this version the elements of A are
  202: *     accessed sequentially with one pass through A.
  203: *
  204:       IF (LSAME(TRANS,'N')) THEN
  205: *
  206: *         Form  x := A*x.
  207: *
  208:           IF (LSAME(UPLO,'U')) THEN
  209:               KPLUS1 = K + 1
  210:               IF (INCX.EQ.1) THEN
  211:                   DO 20 J = 1,N
  212:                       IF (X(J).NE.ZERO) THEN
  213:                           TEMP = X(J)
  214:                           L = KPLUS1 - J
  215:                           DO 10 I = MAX(1,J-K),J - 1
  216:                               X(I) = X(I) + TEMP*A(L+I,J)
  217:    10                     CONTINUE
  218:                           IF (NOUNIT) X(J) = X(J)*A(KPLUS1,J)
  219:                       END IF
  220:    20             CONTINUE
  221:               ELSE
  222:                   JX = KX
  223:                   DO 40 J = 1,N
  224:                       IF (X(JX).NE.ZERO) THEN
  225:                           TEMP = X(JX)
  226:                           IX = KX
  227:                           L = KPLUS1 - J
  228:                           DO 30 I = MAX(1,J-K),J - 1
  229:                               X(IX) = X(IX) + TEMP*A(L+I,J)
  230:                               IX = IX + INCX
  231:    30                     CONTINUE
  232:                           IF (NOUNIT) X(JX) = X(JX)*A(KPLUS1,J)
  233:                       END IF
  234:                       JX = JX + INCX
  235:                       IF (J.GT.K) KX = KX + INCX
  236:    40             CONTINUE
  237:               END IF
  238:           ELSE
  239:               IF (INCX.EQ.1) THEN
  240:                   DO 60 J = N,1,-1
  241:                       IF (X(J).NE.ZERO) THEN
  242:                           TEMP = X(J)
  243:                           L = 1 - J
  244:                           DO 50 I = MIN(N,J+K),J + 1,-1
  245:                               X(I) = X(I) + TEMP*A(L+I,J)
  246:    50                     CONTINUE
  247:                           IF (NOUNIT) X(J) = X(J)*A(1,J)
  248:                       END IF
  249:    60             CONTINUE
  250:               ELSE
  251:                   KX = KX + (N-1)*INCX
  252:                   JX = KX
  253:                   DO 80 J = N,1,-1
  254:                       IF (X(JX).NE.ZERO) THEN
  255:                           TEMP = X(JX)
  256:                           IX = KX
  257:                           L = 1 - J
  258:                           DO 70 I = MIN(N,J+K),J + 1,-1
  259:                               X(IX) = X(IX) + TEMP*A(L+I,J)
  260:                               IX = IX - INCX
  261:    70                     CONTINUE
  262:                           IF (NOUNIT) X(JX) = X(JX)*A(1,J)
  263:                       END IF
  264:                       JX = JX - INCX
  265:                       IF ((N-J).GE.K) KX = KX - INCX
  266:    80             CONTINUE
  267:               END IF
  268:           END IF
  269:       ELSE
  270: *
  271: *        Form  x := A**T*x.
  272: *
  273:           IF (LSAME(UPLO,'U')) THEN
  274:               KPLUS1 = K + 1
  275:               IF (INCX.EQ.1) THEN
  276:                   DO 100 J = N,1,-1
  277:                       TEMP = X(J)
  278:                       L = KPLUS1 - J
  279:                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
  280:                       DO 90 I = J - 1,MAX(1,J-K),-1
  281:                           TEMP = TEMP + A(L+I,J)*X(I)
  282:    90                 CONTINUE
  283:                       X(J) = TEMP
  284:   100             CONTINUE
  285:               ELSE
  286:                   KX = KX + (N-1)*INCX
  287:                   JX = KX
  288:                   DO 120 J = N,1,-1
  289:                       TEMP = X(JX)
  290:                       KX = KX - INCX
  291:                       IX = KX
  292:                       L = KPLUS1 - J
  293:                       IF (NOUNIT) TEMP = TEMP*A(KPLUS1,J)
  294:                       DO 110 I = J - 1,MAX(1,J-K),-1
  295:                           TEMP = TEMP + A(L+I,J)*X(IX)
  296:                           IX = IX - INCX
  297:   110                 CONTINUE
  298:                       X(JX) = TEMP
  299:                       JX = JX - INCX
  300:   120             CONTINUE
  301:               END IF
  302:           ELSE
  303:               IF (INCX.EQ.1) THEN
  304:                   DO 140 J = 1,N
  305:                       TEMP = X(J)
  306:                       L = 1 - J
  307:                       IF (NOUNIT) TEMP = TEMP*A(1,J)
  308:                       DO 130 I = J + 1,MIN(N,J+K)
  309:                           TEMP = TEMP + A(L+I,J)*X(I)
  310:   130                 CONTINUE
  311:                       X(J) = TEMP
  312:   140             CONTINUE
  313:               ELSE
  314:                   JX = KX
  315:                   DO 160 J = 1,N
  316:                       TEMP = X(JX)
  317:                       KX = KX + INCX
  318:                       IX = KX
  319:                       L = 1 - J
  320:                       IF (NOUNIT) TEMP = TEMP*A(1,J)
  321:                       DO 150 I = J + 1,MIN(N,J+K)
  322:                           TEMP = TEMP + A(L+I,J)*X(IX)
  323:                           IX = IX + INCX
  324:   150                 CONTINUE
  325:                       X(JX) = TEMP
  326:                       JX = JX + INCX
  327:   160             CONTINUE
  328:               END IF
  329:           END IF
  330:       END IF
  331: *
  332:       RETURN
  333: *
  334: *     End of DTBMV .
  335: *
  336:       END

CVSweb interface <joel.bertrand@systella.fr>