LAPACK 3.3.0

ssymv.f

Go to the documentation of this file.
00001       SUBROUTINE SSYMV(UPLO,N,ALPHA,A,LDA,X,INCX,BETA,Y,INCY)
00002 *     .. Scalar Arguments ..
00003       REAL ALPHA,BETA
00004       INTEGER INCX,INCY,LDA,N
00005       CHARACTER UPLO
00006 *     ..
00007 *     .. Array Arguments ..
00008       REAL A(LDA,*),X(*),Y(*)
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  SSYMV  performs the matrix-vector  operation
00015 *
00016 *     y := alpha*A*x + beta*y,
00017 *
00018 *  where alpha and beta are scalars, x and y are n element vectors and
00019 *  A is an n by n symmetric matrix.
00020 *
00021 *  Arguments
00022 *  ==========
00023 *
00024 *  UPLO   - CHARACTER*1.
00025 *           On entry, UPLO specifies whether the upper or lower
00026 *           triangular part of the array A is to be referenced as
00027 *           follows:
00028 *
00029 *              UPLO = 'U' or 'u'   Only the upper triangular part of A
00030 *                                  is to be referenced.
00031 *
00032 *              UPLO = 'L' or 'l'   Only the lower triangular part of A
00033 *                                  is to be referenced.
00034 *
00035 *           Unchanged on exit.
00036 *
00037 *  N      - INTEGER.
00038 *           On entry, N specifies the order of the matrix A.
00039 *           N must be at least zero.
00040 *           Unchanged on exit.
00041 *
00042 *  ALPHA  - REAL            .
00043 *           On entry, ALPHA specifies the scalar alpha.
00044 *           Unchanged on exit.
00045 *
00046 *  A      - REAL             array of DIMENSION ( LDA, n ).
00047 *           Before entry with  UPLO = 'U' or 'u', the leading n by n
00048 *           upper triangular part of the array A must contain the upper
00049 *           triangular part of the symmetric matrix and the strictly
00050 *           lower triangular part of A is not referenced.
00051 *           Before entry with UPLO = 'L' or 'l', the leading n by n
00052 *           lower triangular part of the array A must contain the lower
00053 *           triangular part of the symmetric matrix and the strictly
00054 *           upper triangular part of A is not referenced.
00055 *           Unchanged on exit.
00056 *
00057 *  LDA    - INTEGER.
00058 *           On entry, LDA specifies the first dimension of A as declared
00059 *           in the calling (sub) program. LDA must be at least
00060 *           max( 1, n ).
00061 *           Unchanged on exit.
00062 *
00063 *  X      - REAL             array of dimension at least
00064 *           ( 1 + ( n - 1 )*abs( INCX ) ).
00065 *           Before entry, the incremented array X must contain the n
00066 *           element vector x.
00067 *           Unchanged on exit.
00068 *
00069 *  INCX   - INTEGER.
00070 *           On entry, INCX specifies the increment for the elements of
00071 *           X. INCX must not be zero.
00072 *           Unchanged on exit.
00073 *
00074 *  BETA   - REAL            .
00075 *           On entry, BETA specifies the scalar beta. When BETA is
00076 *           supplied as zero then Y need not be set on input.
00077 *           Unchanged on exit.
00078 *
00079 *  Y      - REAL             array of dimension at least
00080 *           ( 1 + ( n - 1 )*abs( INCY ) ).
00081 *           Before entry, the incremented array Y must contain the n
00082 *           element vector y. On exit, Y is overwritten by the updated
00083 *           vector y.
00084 *
00085 *  INCY   - INTEGER.
00086 *           On entry, INCY specifies the increment for the elements of
00087 *           Y. INCY must not be zero.
00088 *           Unchanged on exit.
00089 *
00090 *  Further Details
00091 *  ===============
00092 *
00093 *  Level 2 Blas routine.
00094 *
00095 *  -- Written on 22-October-1986.
00096 *     Jack Dongarra, Argonne National Lab.
00097 *     Jeremy Du Croz, Nag Central Office.
00098 *     Sven Hammarling, Nag Central Office.
00099 *     Richard Hanson, Sandia National Labs.
00100 *
00101 *  =====================================================================
00102 *
00103 *     .. Parameters ..
00104       REAL ONE,ZERO
00105       PARAMETER (ONE=1.0E+0,ZERO=0.0E+0)
00106 *     ..
00107 *     .. Local Scalars ..
00108       REAL TEMP1,TEMP2
00109       INTEGER I,INFO,IX,IY,J,JX,JY,KX,KY
00110 *     ..
00111 *     .. External Functions ..
00112       LOGICAL LSAME
00113       EXTERNAL LSAME
00114 *     ..
00115 *     .. External Subroutines ..
00116       EXTERNAL XERBLA
00117 *     ..
00118 *     .. Intrinsic Functions ..
00119       INTRINSIC MAX
00120 *     ..
00121 *
00122 *     Test the input parameters.
00123 *
00124       INFO = 0
00125       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00126           INFO = 1
00127       ELSE IF (N.LT.0) THEN
00128           INFO = 2
00129       ELSE IF (LDA.LT.MAX(1,N)) THEN
00130           INFO = 5
00131       ELSE IF (INCX.EQ.0) THEN
00132           INFO = 7
00133       ELSE IF (INCY.EQ.0) THEN
00134           INFO = 10
00135       END IF
00136       IF (INFO.NE.0) THEN
00137           CALL XERBLA('SSYMV ',INFO)
00138           RETURN
00139       END IF
00140 *
00141 *     Quick return if possible.
00142 *
00143       IF ((N.EQ.0) .OR. ((ALPHA.EQ.ZERO).AND. (BETA.EQ.ONE))) RETURN
00144 *
00145 *     Set up the start points in  X  and  Y.
00146 *
00147       IF (INCX.GT.0) THEN
00148           KX = 1
00149       ELSE
00150           KX = 1 - (N-1)*INCX
00151       END IF
00152       IF (INCY.GT.0) THEN
00153           KY = 1
00154       ELSE
00155           KY = 1 - (N-1)*INCY
00156       END IF
00157 *
00158 *     Start the operations. In this version the elements of A are
00159 *     accessed sequentially with one pass through the triangular part
00160 *     of A.
00161 *
00162 *     First form  y := beta*y.
00163 *
00164       IF (BETA.NE.ONE) THEN
00165           IF (INCY.EQ.1) THEN
00166               IF (BETA.EQ.ZERO) THEN
00167                   DO 10 I = 1,N
00168                       Y(I) = ZERO
00169    10             CONTINUE
00170               ELSE
00171                   DO 20 I = 1,N
00172                       Y(I) = BETA*Y(I)
00173    20             CONTINUE
00174               END IF
00175           ELSE
00176               IY = KY
00177               IF (BETA.EQ.ZERO) THEN
00178                   DO 30 I = 1,N
00179                       Y(IY) = ZERO
00180                       IY = IY + INCY
00181    30             CONTINUE
00182               ELSE
00183                   DO 40 I = 1,N
00184                       Y(IY) = BETA*Y(IY)
00185                       IY = IY + INCY
00186    40             CONTINUE
00187               END IF
00188           END IF
00189       END IF
00190       IF (ALPHA.EQ.ZERO) RETURN
00191       IF (LSAME(UPLO,'U')) THEN
00192 *
00193 *        Form  y  when A is stored in upper triangle.
00194 *
00195           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00196               DO 60 J = 1,N
00197                   TEMP1 = ALPHA*X(J)
00198                   TEMP2 = ZERO
00199                   DO 50 I = 1,J - 1
00200                       Y(I) = Y(I) + TEMP1*A(I,J)
00201                       TEMP2 = TEMP2 + A(I,J)*X(I)
00202    50             CONTINUE
00203                   Y(J) = Y(J) + TEMP1*A(J,J) + ALPHA*TEMP2
00204    60         CONTINUE
00205           ELSE
00206               JX = KX
00207               JY = KY
00208               DO 80 J = 1,N
00209                   TEMP1 = ALPHA*X(JX)
00210                   TEMP2 = ZERO
00211                   IX = KX
00212                   IY = KY
00213                   DO 70 I = 1,J - 1
00214                       Y(IY) = Y(IY) + TEMP1*A(I,J)
00215                       TEMP2 = TEMP2 + A(I,J)*X(IX)
00216                       IX = IX + INCX
00217                       IY = IY + INCY
00218    70             CONTINUE
00219                   Y(JY) = Y(JY) + TEMP1*A(J,J) + ALPHA*TEMP2
00220                   JX = JX + INCX
00221                   JY = JY + INCY
00222    80         CONTINUE
00223           END IF
00224       ELSE
00225 *
00226 *        Form  y  when A is stored in lower triangle.
00227 *
00228           IF ((INCX.EQ.1) .AND. (INCY.EQ.1)) THEN
00229               DO 100 J = 1,N
00230                   TEMP1 = ALPHA*X(J)
00231                   TEMP2 = ZERO
00232                   Y(J) = Y(J) + TEMP1*A(J,J)
00233                   DO 90 I = J + 1,N
00234                       Y(I) = Y(I) + TEMP1*A(I,J)
00235                       TEMP2 = TEMP2 + A(I,J)*X(I)
00236    90             CONTINUE
00237                   Y(J) = Y(J) + ALPHA*TEMP2
00238   100         CONTINUE
00239           ELSE
00240               JX = KX
00241               JY = KY
00242               DO 120 J = 1,N
00243                   TEMP1 = ALPHA*X(JX)
00244                   TEMP2 = ZERO
00245                   Y(JY) = Y(JY) + TEMP1*A(J,J)
00246                   IX = JX
00247                   IY = JY
00248                   DO 110 I = J + 1,N
00249                       IX = IX + INCX
00250                       IY = IY + INCY
00251                       Y(IY) = Y(IY) + TEMP1*A(I,J)
00252                       TEMP2 = TEMP2 + A(I,J)*X(IX)
00253   110             CONTINUE
00254                   Y(JY) = Y(JY) + ALPHA*TEMP2
00255                   JX = JX + INCX
00256                   JY = JY + INCY
00257   120         CONTINUE
00258           END IF
00259       END IF
00260 *
00261       RETURN
00262 *
00263 *     End of SSYMV .
00264 *
00265       END
 All Files Functions