LAPACK 3.3.1
Linear Algebra PACKage

cher.f

Go to the documentation of this file.
00001       SUBROUTINE CHER(UPLO,N,ALPHA,X,INCX,A,LDA)
00002 *     .. Scalar Arguments ..
00003       REAL ALPHA
00004       INTEGER INCX,LDA,N
00005       CHARACTER UPLO
00006 *     ..
00007 *     .. Array Arguments ..
00008       COMPLEX A(LDA,*),X(*)
00009 *     ..
00010 *
00011 *  Purpose
00012 *  =======
00013 *
00014 *  CHER   performs the hermitian rank 1 operation
00015 *
00016 *     A := alpha*x*x**H + A,
00017 *
00018 *  where alpha is a real scalar, x is an n element vector and A is an
00019 *  n by n hermitian 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 *  X      - COMPLEX          array of dimension at least
00047 *           ( 1 + ( n - 1 )*abs( INCX ) ).
00048 *           Before entry, the incremented array X must contain the n
00049 *           element vector x.
00050 *           Unchanged on exit.
00051 *
00052 *  INCX   - INTEGER.
00053 *           On entry, INCX specifies the increment for the elements of
00054 *           X. INCX must not be zero.
00055 *           Unchanged on exit.
00056 *
00057 *  A      - COMPLEX          array of DIMENSION ( LDA, n ).
00058 *           Before entry with  UPLO = 'U' or 'u', the leading n by n
00059 *           upper triangular part of the array A must contain the upper
00060 *           triangular part of the hermitian matrix and the strictly
00061 *           lower triangular part of A is not referenced. On exit, the
00062 *           upper triangular part of the array A is overwritten by the
00063 *           upper triangular part of the updated matrix.
00064 *           Before entry with UPLO = 'L' or 'l', the leading n by n
00065 *           lower triangular part of the array A must contain the lower
00066 *           triangular part of the hermitian matrix and the strictly
00067 *           upper triangular part of A is not referenced. On exit, the
00068 *           lower triangular part of the array A is overwritten by the
00069 *           lower triangular part of the updated matrix.
00070 *           Note that the imaginary parts of the diagonal elements need
00071 *           not be set, they are assumed to be zero, and on exit they
00072 *           are set to zero.
00073 *
00074 *  LDA    - INTEGER.
00075 *           On entry, LDA specifies the first dimension of A as declared
00076 *           in the calling (sub) program. LDA must be at least
00077 *           max( 1, n ).
00078 *           Unchanged on exit.
00079 *
00080 *  Further Details
00081 *  ===============
00082 *
00083 *  Level 2 Blas routine.
00084 *
00085 *  -- Written on 22-October-1986.
00086 *     Jack Dongarra, Argonne National Lab.
00087 *     Jeremy Du Croz, Nag Central Office.
00088 *     Sven Hammarling, Nag Central Office.
00089 *     Richard Hanson, Sandia National Labs.
00090 *
00091 *  =====================================================================
00092 *
00093 *     .. Parameters ..
00094       COMPLEX ZERO
00095       PARAMETER (ZERO= (0.0E+0,0.0E+0))
00096 *     ..
00097 *     .. Local Scalars ..
00098       COMPLEX TEMP
00099       INTEGER I,INFO,IX,J,JX,KX
00100 *     ..
00101 *     .. External Functions ..
00102       LOGICAL LSAME
00103       EXTERNAL LSAME
00104 *     ..
00105 *     .. External Subroutines ..
00106       EXTERNAL XERBLA
00107 *     ..
00108 *     .. Intrinsic Functions ..
00109       INTRINSIC CONJG,MAX,REAL
00110 *     ..
00111 *
00112 *     Test the input parameters.
00113 *
00114       INFO = 0
00115       IF (.NOT.LSAME(UPLO,'U') .AND. .NOT.LSAME(UPLO,'L')) THEN
00116           INFO = 1
00117       ELSE IF (N.LT.0) THEN
00118           INFO = 2
00119       ELSE IF (INCX.EQ.0) THEN
00120           INFO = 5
00121       ELSE IF (LDA.LT.MAX(1,N)) THEN
00122           INFO = 7
00123       END IF
00124       IF (INFO.NE.0) THEN
00125           CALL XERBLA('CHER  ',INFO)
00126           RETURN
00127       END IF
00128 *
00129 *     Quick return if possible.
00130 *
00131       IF ((N.EQ.0) .OR. (ALPHA.EQ.REAL(ZERO))) RETURN
00132 *
00133 *     Set the start point in X if the increment is not unity.
00134 *
00135       IF (INCX.LE.0) THEN
00136           KX = 1 - (N-1)*INCX
00137       ELSE IF (INCX.NE.1) THEN
00138           KX = 1
00139       END IF
00140 *
00141 *     Start the operations. In this version the elements of A are
00142 *     accessed sequentially with one pass through the triangular part
00143 *     of A.
00144 *
00145       IF (LSAME(UPLO,'U')) THEN
00146 *
00147 *        Form  A  when A is stored in upper triangle.
00148 *
00149           IF (INCX.EQ.1) THEN
00150               DO 20 J = 1,N
00151                   IF (X(J).NE.ZERO) THEN
00152                       TEMP = ALPHA*CONJG(X(J))
00153                       DO 10 I = 1,J - 1
00154                           A(I,J) = A(I,J) + X(I)*TEMP
00155    10                 CONTINUE
00156                       A(J,J) = REAL(A(J,J)) + REAL(X(J)*TEMP)
00157                   ELSE
00158                       A(J,J) = REAL(A(J,J))
00159                   END IF
00160    20         CONTINUE
00161           ELSE
00162               JX = KX
00163               DO 40 J = 1,N
00164                   IF (X(JX).NE.ZERO) THEN
00165                       TEMP = ALPHA*CONJG(X(JX))
00166                       IX = KX
00167                       DO 30 I = 1,J - 1
00168                           A(I,J) = A(I,J) + X(IX)*TEMP
00169                           IX = IX + INCX
00170    30                 CONTINUE
00171                       A(J,J) = REAL(A(J,J)) + REAL(X(JX)*TEMP)
00172                   ELSE
00173                       A(J,J) = REAL(A(J,J))
00174                   END IF
00175                   JX = JX + INCX
00176    40         CONTINUE
00177           END IF
00178       ELSE
00179 *
00180 *        Form  A  when A is stored in lower triangle.
00181 *
00182           IF (INCX.EQ.1) THEN
00183               DO 60 J = 1,N
00184                   IF (X(J).NE.ZERO) THEN
00185                       TEMP = ALPHA*CONJG(X(J))
00186                       A(J,J) = REAL(A(J,J)) + REAL(TEMP*X(J))
00187                       DO 50 I = J + 1,N
00188                           A(I,J) = A(I,J) + X(I)*TEMP
00189    50                 CONTINUE
00190                   ELSE
00191                       A(J,J) = REAL(A(J,J))
00192                   END IF
00193    60         CONTINUE
00194           ELSE
00195               JX = KX
00196               DO 80 J = 1,N
00197                   IF (X(JX).NE.ZERO) THEN
00198                       TEMP = ALPHA*CONJG(X(JX))
00199                       A(J,J) = REAL(A(J,J)) + REAL(TEMP*X(JX))
00200                       IX = JX
00201                       DO 70 I = J + 1,N
00202                           IX = IX + INCX
00203                           A(I,J) = A(I,J) + X(IX)*TEMP
00204    70                 CONTINUE
00205                   ELSE
00206                       A(J,J) = REAL(A(J,J))
00207                   END IF
00208                   JX = JX + INCX
00209    80         CONTINUE
00210           END IF
00211       END IF
00212 *
00213       RETURN
00214 *
00215 *     End of CHER  .
00216 *
00217       END
 All Files Functions