kusano 2b45e8
      SUBROUTINE SGBMVF( TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX,
kusano 2b45e8
     $                   BETA, Y, INCY )
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      REAL               ALPHA, BETA
kusano 2b45e8
      INTEGER            INCX, INCY, KL, KU, LDA, M, N
kusano 2b45e8
      CHARACTER*1        TRANS
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      REAL               A( LDA, * ), X( * ), Y( * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  Purpose
kusano 2b45e8
*  =======
kusano 2b45e8
*
kusano 2b45e8
*  SGBMV  performs one of the matrix-vector operations
kusano 2b45e8
*
kusano 2b45e8
*     y := alpha*A*x + beta*y,   or   y := alpha*A'*x + beta*y,
kusano 2b45e8
*
kusano 2b45e8
*  where alpha and beta are scalars, x and y are vectors and A is an
kusano 2b45e8
*  m by n band matrix, with kl sub-diagonals and ku super-diagonals.
kusano 2b45e8
*
kusano 2b45e8
*  Parameters
kusano 2b45e8
*  ==========
kusano 2b45e8
*
kusano 2b45e8
*  TRANS  - CHARACTER*1.
kusano 2b45e8
*           On entry, TRANS specifies the operation to be performed as
kusano 2b45e8
*           follows:
kusano 2b45e8
*
kusano 2b45e8
*              TRANS = 'N' or 'n'   y := alpha*A*x + beta*y.
kusano 2b45e8
*
kusano 2b45e8
*              TRANS = 'T' or 't'   y := alpha*A'*x + beta*y.
kusano 2b45e8
*
kusano 2b45e8
*              TRANS = 'C' or 'c'   y := alpha*A'*x + beta*y.
kusano 2b45e8
*
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  M      - INTEGER.
kusano 2b45e8
*           On entry, M specifies the number of rows of the matrix A.
kusano 2b45e8
*           M must be at least zero.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  N      - INTEGER.
kusano 2b45e8
*           On entry, N specifies the number of columns of the matrix A.
kusano 2b45e8
*           N must be at least zero.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  KL     - INTEGER.
kusano 2b45e8
*           On entry, KL specifies the number of sub-diagonals of the
kusano 2b45e8
*           matrix A. KL must satisfy  0 .le. KL.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  KU     - INTEGER.
kusano 2b45e8
*           On entry, KU specifies the number of super-diagonals of the
kusano 2b45e8
*           matrix A. KU must satisfy  0 .le. KU.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  ALPHA  - REAL            .
kusano 2b45e8
*           On entry, ALPHA specifies the scalar alpha.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  A      - REAL             array of DIMENSION ( LDA, n ).
kusano 2b45e8
*           Before entry, the leading ( kl + ku + 1 ) by n part of the
kusano 2b45e8
*           array A must contain the matrix of coefficients, supplied
kusano 2b45e8
*           column by column, with the leading diagonal of the matrix in
kusano 2b45e8
*           row ( ku + 1 ) of the array, the first super-diagonal
kusano 2b45e8
*           starting at position 2 in row ku, the first sub-diagonal
kusano 2b45e8
*           starting at position 1 in row ( ku + 2 ), and so on.
kusano 2b45e8
*           Elements in the array A that do not correspond to elements
kusano 2b45e8
*           in the band matrix (such as the top left ku by ku triangle)
kusano 2b45e8
*           are not referenced.
kusano 2b45e8
*           The following program segment will transfer a band matrix
kusano 2b45e8
*           from conventional full matrix storage to band storage:
kusano 2b45e8
*
kusano 2b45e8
*                 DO 20, J = 1, N
kusano 2b45e8
*                    K = KU + 1 - J
kusano 2b45e8
*                    DO 10, I = MAX( 1, J - KU ), MIN( M, J + KL )
kusano 2b45e8
*                       A( K + I, J ) = matrix( I, J )
kusano 2b45e8
*              10    CONTINUE
kusano 2b45e8
*              20 CONTINUE
kusano 2b45e8
*
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
*           ( kl + ku + 1 ).
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  X      - REAL             array of DIMENSION at least
kusano 2b45e8
*           ( 1 + ( n - 1 )*abs( INCX ) ) when TRANS = 'N' or 'n'
kusano 2b45e8
*           and at least
kusano 2b45e8
*           ( 1 + ( m - 1 )*abs( INCX ) ) otherwise.
kusano 2b45e8
*           Before entry, the incremented array X must contain the
kusano 2b45e8
*           vector x.
kusano 2b45e8
*           Unchanged on exit.
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
*  BETA   - REAL            .
kusano 2b45e8
*           On entry, BETA specifies the scalar beta. When BETA is
kusano 2b45e8
*           supplied as zero then Y need not be set on input.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  Y      - REAL             array of DIMENSION at least
kusano 2b45e8
*           ( 1 + ( m - 1 )*abs( INCY ) ) when TRANS = 'N' or 'n'
kusano 2b45e8
*           and at least
kusano 2b45e8
*           ( 1 + ( n - 1 )*abs( INCY ) ) otherwise.
kusano 2b45e8
*           Before entry, the incremented array Y must contain the
kusano 2b45e8
*           vector y. On exit, Y is overwritten by the updated vector y.
kusano 2b45e8
*
kusano 2b45e8
*  INCY   - INTEGER.
kusano 2b45e8
*           On entry, INCY specifies the increment for the elements of
kusano 2b45e8
*           Y. INCY 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
*     .. Parameters ..
kusano 2b45e8
      REAL               ONE         , ZERO
kusano 2b45e8
      PARAMETER        ( ONE = 1.0E+0, ZERO = 0.0E+0 )
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      REAL               TEMP
kusano 2b45e8
      INTEGER            I, INFO, IX, IY, J, JX, JY, K, KUP1, KX, KY,
kusano 2b45e8
     $                   LENX, LENY
kusano 2b45e8
*     .. External Functions ..
kusano 2b45e8
      LOGICAL            LSAME
kusano 2b45e8
      EXTERNAL           LSAME
kusano 2b45e8
*     .. External Subroutines ..
kusano 2b45e8
      EXTERNAL           XERBLA
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC          MAX, MIN
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
*
kusano 2b45e8
*     Test the input parameters.
kusano 2b45e8
*
kusano 2b45e8
      INFO = 0
kusano 2b45e8
      IF     ( .NOT.LSAME( TRANS, 'N' ).AND.
kusano 2b45e8
     $         .NOT.LSAME( TRANS, 'T' ).AND.
kusano 2b45e8
     $         .NOT.LSAME( TRANS, 'C' )      )THEN
kusano 2b45e8
         INFO = 1
kusano 2b45e8
      ELSE IF( M.LT.0 )THEN
kusano 2b45e8
         INFO = 2
kusano 2b45e8
      ELSE IF( N.LT.0 )THEN
kusano 2b45e8
         INFO = 3
kusano 2b45e8
      ELSE IF( KL.LT.0 )THEN
kusano 2b45e8
         INFO = 4
kusano 2b45e8
      ELSE IF( KU.LT.0 )THEN
kusano 2b45e8
         INFO = 5
kusano 2b45e8
      ELSE IF( LDA.LT.( KL + KU + 1 ) )THEN
kusano 2b45e8
         INFO = 8
kusano 2b45e8
      ELSE IF( INCX.EQ.0 )THEN
kusano 2b45e8
         INFO = 10
kusano 2b45e8
      ELSE IF( INCY.EQ.0 )THEN
kusano 2b45e8
         INFO = 13
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INFO.NE.0 )THEN
kusano 2b45e8
         CALL XERBLA( 'SGBMV ', INFO )
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Quick return if possible.
kusano 2b45e8
*
kusano 2b45e8
      IF( ( M.EQ.0 ).OR.( N.EQ.0 ).OR.
kusano 2b45e8
     $    ( ( ALPHA.EQ.ZERO ).AND.( BETA.EQ.ONE ) ) )
kusano 2b45e8
     $   RETURN
kusano 2b45e8
*
kusano 2b45e8
*     Set  LENX  and  LENY, the lengths of the vectors x and y, and set
kusano 2b45e8
*     up the start points in  X  and  Y.
kusano 2b45e8
*
kusano 2b45e8
      IF( LSAME( TRANS, 'N' ) )THEN
kusano 2b45e8
         LENX = N
kusano 2b45e8
         LENY = M
kusano 2b45e8
      ELSE
kusano 2b45e8
         LENX = M
kusano 2b45e8
         LENY = N
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INCX.GT.0 )THEN
kusano 2b45e8
         KX = 1
kusano 2b45e8
      ELSE
kusano 2b45e8
         KX = 1 - ( LENX - 1 )*INCX
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INCY.GT.0 )THEN
kusano 2b45e8
         KY = 1
kusano 2b45e8
      ELSE
kusano 2b45e8
         KY = 1 - ( LENY - 1 )*INCY
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Start the operations. In this version the elements of A are
kusano 2b45e8
*     accessed sequentially with one pass through the band part of A.
kusano 2b45e8
*
kusano 2b45e8
*     First form  y := beta*y.
kusano 2b45e8
*
kusano 2b45e8
      IF( BETA.NE.ONE )THEN
kusano 2b45e8
         IF( INCY.EQ.1 )THEN
kusano 2b45e8
            IF( BETA.EQ.ZERO )THEN
kusano 2b45e8
               DO 10, I = 1, LENY
kusano 2b45e8
                  Y( I ) = ZERO
kusano 2b45e8
   10          CONTINUE
kusano 2b45e8
            ELSE
kusano 2b45e8
               DO 20, I = 1, LENY
kusano 2b45e8
                  Y( I ) = BETA*Y( I )
kusano 2b45e8
   20          CONTINUE
kusano 2b45e8
            END IF
kusano 2b45e8
         ELSE
kusano 2b45e8
            IY = KY
kusano 2b45e8
            IF( BETA.EQ.ZERO )THEN
kusano 2b45e8
               DO 30, I = 1, LENY
kusano 2b45e8
                  Y( IY ) = ZERO
kusano 2b45e8
                  IY      = IY   + INCY
kusano 2b45e8
   30          CONTINUE
kusano 2b45e8
            ELSE
kusano 2b45e8
               DO 40, I = 1, LENY
kusano 2b45e8
                  Y( IY ) = BETA*Y( IY )
kusano 2b45e8
                  IY      = IY           + INCY
kusano 2b45e8
   40          CONTINUE
kusano 2b45e8
            END IF
kusano 2b45e8
         END IF
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( ALPHA.EQ.ZERO )
kusano 2b45e8
     $   RETURN
kusano 2b45e8
      KUP1 = KU + 1
kusano 2b45e8
      IF( LSAME( TRANS, 'N' ) )THEN
kusano 2b45e8
*
kusano 2b45e8
*        Form  y := alpha*A*x + y.
kusano 2b45e8
*
kusano 2b45e8
         JX = KX
kusano 2b45e8
         IF( INCY.EQ.1 )THEN
kusano 2b45e8
            DO 60, J = 1, N
kusano 2b45e8
               IF( X( JX ).NE.ZERO )THEN
kusano 2b45e8
                  TEMP = ALPHA*X( JX )
kusano 2b45e8
                  K    = KUP1 - J
kusano 2b45e8
                  DO 50, I = MAX( 1, J - KU ), MIN( M, J + KL )
kusano 2b45e8
                     Y( I ) = Y( I ) + TEMP*A( K + I, J )
kusano 2b45e8
   50             CONTINUE
kusano 2b45e8
               END IF
kusano 2b45e8
               JX = JX + INCX
kusano 2b45e8
   60       CONTINUE
kusano 2b45e8
         ELSE
kusano 2b45e8
            DO 80, J = 1, N
kusano 2b45e8
               IF( X( JX ).NE.ZERO )THEN
kusano 2b45e8
                  TEMP = ALPHA*X( JX )
kusano 2b45e8
                  IY   = KY
kusano 2b45e8
                  K    = KUP1 - J
kusano 2b45e8
                  DO 70, I = MAX( 1, J - KU ), MIN( M, J + KL )
kusano 2b45e8
                     Y( IY ) = Y( IY ) + TEMP*A( K + I, J )
kusano 2b45e8
                     IY      = IY      + INCY
kusano 2b45e8
   70             CONTINUE
kusano 2b45e8
               END IF
kusano 2b45e8
               JX = JX + INCX
kusano 2b45e8
               IF( J.GT.KU )
kusano 2b45e8
     $            KY = KY + INCY
kusano 2b45e8
   80       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      ELSE
kusano 2b45e8
*
kusano 2b45e8
*        Form  y := alpha*A'*x + y.
kusano 2b45e8
*
kusano 2b45e8
         JY = KY
kusano 2b45e8
         IF( INCX.EQ.1 )THEN
kusano 2b45e8
            DO 100, J = 1, N
kusano 2b45e8
               TEMP = ZERO
kusano 2b45e8
               K    = KUP1 - J
kusano 2b45e8
               DO 90, I = MAX( 1, J - KU ), MIN( M, J + KL )
kusano 2b45e8
                  TEMP = TEMP + A( K + I, J )*X( I )
kusano 2b45e8
   90          CONTINUE
kusano 2b45e8
               Y( JY ) = Y( JY ) + ALPHA*TEMP
kusano 2b45e8
               JY      = JY      + INCY
kusano 2b45e8
  100       CONTINUE
kusano 2b45e8
         ELSE
kusano 2b45e8
            DO 120, J = 1, N
kusano 2b45e8
               TEMP = ZERO
kusano 2b45e8
               IX   = KX
kusano 2b45e8
               K    = KUP1 - J
kusano 2b45e8
               DO 110, I = MAX( 1, J - KU ), MIN( M, J + KL )
kusano 2b45e8
                  TEMP = TEMP + A( K + I, J )*X( IX )
kusano 2b45e8
                  IX   = IX   + INCX
kusano 2b45e8
  110          CONTINUE
kusano 2b45e8
               Y( JY ) = Y( JY ) + ALPHA*TEMP
kusano 2b45e8
               JY      = JY      + INCY
kusano 2b45e8
               IF( J.GT.KU )
kusano 2b45e8
     $            KX = KX + INCX
kusano 2b45e8
  120       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of SGBMV .
kusano 2b45e8
*
kusano 2b45e8
      END