File:  [local] / rpl / lapack / blas / dspmv.f
Revision 1.7: download - view: text, annotated - select for diffs - revision graph
Fri Jul 22 07:38:01 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 DSPMV(UPLO,N,ALPHA,AP,X,INCX,BETA,Y,INCY)
    2: *     .. Scalar Arguments ..
    3:       DOUBLE PRECISION ALPHA,BETA
    4:       INTEGER INCX,INCY,N
    5:       CHARACTER UPLO
    6: *     ..
    7: *     .. Array Arguments ..
    8:       DOUBLE PRECISION AP(*),X(*),Y(*)
    9: *     ..
   10: *
   11: *  Purpose
   12: *  =======
   13: *
   14: *  DSPMV  performs the matrix-vector operation
   15: *
   16: *     y := alpha*A*x + beta*y,
   17: *
   18: *  where alpha and beta are scalars, x and y are n element vectors and
   19: *  A is an n by n symmetric matrix, supplied in packed form.
   20: *
   21: *  Arguments
   22: *  ==========
   23: *
   24: *  UPLO   - CHARACTER*1.
   25: *           On entry, UPLO specifies whether the upper or lower
   26: *           triangular part of the matrix A is supplied in the packed
   27: *           array AP as follows:
   28: *
   29: *              UPLO = 'U' or 'u'   The upper triangular part of A is
   30: *                                  supplied in AP.
   31: *
   32: *              UPLO = 'L' or 'l'   The lower triangular part of A is
   33: *                                  supplied in AP.
   34: *
   35: *           Unchanged on exit.
   36: *
   37: *  N      - INTEGER.
   38: *           On entry, N specifies the order of the matrix A.
   39: *           N must be at least zero.
   40: *           Unchanged on exit.
   41: *
   42: *  ALPHA  - DOUBLE PRECISION.
   43: *           On entry, ALPHA specifies the scalar alpha.
   44: *           Unchanged on exit.
   45: *
   46: *  AP     - DOUBLE PRECISION array of DIMENSION at least
   47: *           ( ( n*( n + 1 ) )/2 ).
   48: *           Before entry with UPLO = 'U' or 'u', the array AP must
   49: *           contain the upper triangular part of the symmetric matrix
   50: *           packed sequentially, column by column, so that AP( 1 )
   51: *           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
   52: *           and a( 2, 2 ) respectively, and so on.
   53: *           Before entry with UPLO = 'L' or 'l', the array AP must
   54: *           contain the lower triangular part of the symmetric matrix
   55: *           packed sequentially, column by column, so that AP( 1 )
   56: *           contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
   57: *           and a( 3, 1 ) respectively, and so on.
   58: *           Unchanged on exit.
   59: *
   60: *  X      - DOUBLE PRECISION array of dimension at least
   61: *           ( 1 + ( n - 1 )*abs( INCX ) ).
   62: *           Before entry, the incremented array X must contain the n
   63: *           element vector x.
   64: *           Unchanged on exit.
   65: *
   66: *  INCX   - INTEGER.
   67: *           On entry, INCX specifies the increment for the elements of
   68: *           X. INCX must not be zero.
   69: *           Unchanged on exit.
   70: *
   71: *  BETA   - DOUBLE PRECISION.
   72: *           On entry, BETA specifies the scalar beta. When BETA is
   73: *           supplied as zero then Y need not be set on input.
   74: *           Unchanged on exit.
   75: *
   76: *  Y      - DOUBLE PRECISION array of dimension at least
   77: *           ( 1 + ( n - 1 )*abs( INCY ) ).
   78: *           Before entry, the incremented array Y must contain the n
   79: *           element vector y. On exit, Y is overwritten by the updated
   80: *           vector y.
   81: *
   82: *  INCY   - INTEGER.
   83: *           On entry, INCY specifies the increment for the elements of
   84: *           Y. INCY must not be zero.
   85: *           Unchanged on exit.
   86: *
   87: *  Further Details
   88: *  ===============
   89: *
   90: *  Level 2 Blas routine.
   91: *  The vector and matrix arguments are not referenced when N = 0, or M = 0
   92: *
   93: *  -- Written on 22-October-1986.
   94: *     Jack Dongarra, Argonne National Lab.
   95: *     Jeremy Du Croz, Nag Central Office.
   96: *     Sven Hammarling, Nag Central Office.
   97: *     Richard Hanson, Sandia National Labs.
   98: *
   99: *  =====================================================================
  100: *
  101: *     .. Parameters ..
  102:       DOUBLE PRECISION ONE,ZERO
  103:       PARAMETER (ONE=1.0D+0,ZERO=0.0D+0)
  104: *     ..
  105: *     .. Local Scalars ..
  106:       DOUBLE PRECISION TEMP1,TEMP2
  107:       INTEGER I,INFO,IX,IY,J,JX,JY,K,KK,KX,KY
  108: *     ..
  109: *     .. External Functions ..
  110:       LOGICAL LSAME
  111:       EXTERNAL LSAME
  112: *     ..
  113: *     .. External Subroutines ..
  114:       EXTERNAL XERBLA
  115: *     ..
  116: *
  117: *     Test the input parameters.
  118: *
  119:       INFO = 0
  120:       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
  121:           INFO = 1
  122:       ELSE IF (N.LT.0) THEN
  123:           INFO = 2
  124:       ELSE IF (INCX.EQ.0) THEN
  125:           INFO = 6
  126:       ELSE IF (INCY.EQ.0) THEN
  127:           INFO = 9
  128:       END IF
  129:       IF (INFO.NE.0) THEN
  130:           CALL XERBLA('DSPMV ',INFO)
  131:           RETURN
  132:       END IF
  133: *
  134: *     Quick return if possible.
  135: *
  136:       IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
  137: *
  138: *     Set up the start points in  X  and  Y.
  139: *
  140:       IF (INCX.GT.0) THEN
  141:           KX = 1
  142:       ELSE
  143:           KX = 1 - (N-1)*INCX
  144:       END IF
  145:       IF (INCY.GT.0) THEN
  146:           KY = 1
  147:       ELSE
  148:           KY = 1 - (N-1)*INCY
  149:       END IF
  150: *
  151: *     Start the operations. In this version the elements of the array AP
  152: *     are accessed sequentially with one pass through AP.
  153: *
  154: *     First form  y := beta*y.
  155: *
  156:       IF (BETA.NE.ONE) THEN
  157:           IF (INCY.EQ.1) THEN
  158:               IF (BETA.EQ.ZERO) THEN
  159:                   DO 10 I = 1,N
  160:                       Y(I) = ZERO
  161:    10             CONTINUE
  162:               ELSE
  163:                   DO 20 I = 1,N
  164:                       Y(I) = BETA*Y(I)
  165:    20             CONTINUE
  166:               END IF
  167:           ELSE
  168:               IY = KY
  169:               IF (BETA.EQ.ZERO) THEN
  170:                   DO 30 I = 1,N
  171:                       Y(IY) = ZERO
  172:                       IY = IY + INCY
  173:    30             CONTINUE
  174:               ELSE
  175:                   DO 40 I = 1,N
  176:                       Y(IY) = BETA*Y(IY)
  177:                       IY = IY + INCY
  178:    40             CONTINUE
  179:               END IF
  180:           END IF
  181:       END IF
  182:       IF (ALPHA.EQ.ZERO) RETURN
  183:       KK = 1
  184:       IF (LSAME(UPLO,'U')) THEN
  185: *
  186: *        Form  y  when AP contains the upper triangle.
  187: *
  188:           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
  189:               DO 60 J = 1,N
  190:                   TEMP1 = ALPHA*X(J)
  191:                   TEMP2 = ZERO
  192:                   K = KK
  193:                   DO 50 I = 1,J - 1
  194:                       Y(I) = Y(I) + TEMP1*AP(K)
  195:                       TEMP2 = TEMP2 + AP(K)*X(I)
  196:                       K = K + 1
  197:    50             CONTINUE
  198:                   Y(J) = Y(J) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
  199:                   KK = KK + J
  200:    60         CONTINUE
  201:           ELSE
  202:               JX = KX
  203:               JY = KY
  204:               DO 80 J = 1,N
  205:                   TEMP1 = ALPHA*X(JX)
  206:                   TEMP2 = ZERO
  207:                   IX = KX
  208:                   IY = KY
  209:                   DO 70 K = KK,KK + J - 2
  210:                       Y(IY) = Y(IY) + TEMP1*AP(K)
  211:                       TEMP2 = TEMP2 + AP(K)*X(IX)
  212:                       IX = IX + INCX
  213:                       IY = IY + INCY
  214:    70             CONTINUE
  215:                   Y(JY) = Y(JY) + TEMP1*AP(KK+J-1) + ALPHA*TEMP2
  216:                   JX = JX + INCX
  217:                   JY = JY + INCY
  218:                   KK = KK + J
  219:    80         CONTINUE
  220:           END IF
  221:       ELSE
  222: *
  223: *        Form  y  when AP contains the lower triangle.
  224: *
  225:           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
  226:               DO 100 J = 1,N
  227:                   TEMP1 = ALPHA*X(J)
  228:                   TEMP2 = ZERO
  229:                   Y(J) = Y(J) + TEMP1*AP(KK)
  230:                   K = KK + 1
  231:                   DO 90 I = J + 1,N
  232:                       Y(I) = Y(I) + TEMP1*AP(K)
  233:                       TEMP2 = TEMP2 + AP(K)*X(I)
  234:                       K = K + 1
  235:    90             CONTINUE
  236:                   Y(J) = Y(J) + ALPHA*TEMP2
  237:                   KK = KK + (N-J+1)
  238:   100         CONTINUE
  239:           ELSE
  240:               JX = KX
  241:               JY = KY
  242:               DO 120 J = 1,N
  243:                   TEMP1 = ALPHA*X(JX)
  244:                   TEMP2 = ZERO
  245:                   Y(JY) = Y(JY) + TEMP1*AP(KK)
  246:                   IX = JX
  247:                   IY = JY
  248:                   DO 110 K = KK + 1,KK + N - J
  249:                       IX = IX + INCX
  250:                       IY = IY + INCY
  251:                       Y(IY) = Y(IY) + TEMP1*AP(K)
  252:                       TEMP2 = TEMP2 + AP(K)*X(IX)
  253:   110             CONTINUE
  254:                   Y(JY) = Y(JY) + ALPHA*TEMP2
  255:                   JX = JX + INCX
  256:                   JY = JY + INCY
  257:                   KK = KK + (N-J+1)
  258:   120         CONTINUE
  259:           END IF
  260:       END IF
  261: *
  262:       RETURN
  263: *
  264: *     End of DSPMV .
  265: *
  266:       END

CVSweb interface <joel.bertrand@systella.fr>