kusano 2b45e8
      SUBROUTINE ZHERKF( UPLO,TRANS, N, K, ALPHA, A, LDA, BETA, C, LDC )
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      CHARACTER          TRANS, UPLO
kusano 2b45e8
      INTEGER            K, LDA, LDC, N
kusano 2b45e8
      DOUBLE PRECISION   ALPHA, BETA
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      COMPLEX*16         A( LDA, * ), C( LDC, * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  Purpose
kusano 2b45e8
*  =======
kusano 2b45e8
*
kusano 2b45e8
*  ZHERK  performs one of the hermitian rank k operations
kusano 2b45e8
*
kusano 2b45e8
*     C := alpha*A*conjg( A' ) + beta*C,
kusano 2b45e8
*
kusano 2b45e8
*  or
kusano 2b45e8
*
kusano 2b45e8
*     C := alpha*conjg( A' )*A + beta*C,
kusano 2b45e8
*
kusano 2b45e8
*  where  alpha and beta  are  real scalars,  C is an  n by n  hermitian
kusano 2b45e8
*  matrix and  A  is an  n by k  matrix in the  first case and a  k by n
kusano 2b45e8
*  matrix in the second case.
kusano 2b45e8
*
kusano 2b45e8
*  Parameters
kusano 2b45e8
*  ==========
kusano 2b45e8
*
kusano 2b45e8
*  UPLO   - CHARACTER*1.
kusano 2b45e8
*           On  entry,   UPLO  specifies  whether  the  upper  or  lower
kusano 2b45e8
*           triangular  part  of the  array  C  is to be  referenced  as
kusano 2b45e8
*           follows:
kusano 2b45e8
*
kusano 2b45e8
*              UPLO = 'U' or 'u'   Only the  upper triangular part of  C
kusano 2b45e8
*                                  is to be referenced.
kusano 2b45e8
*
kusano 2b45e8
*              UPLO = 'L' or 'l'   Only the  lower triangular part of  C
kusano 2b45e8
*                                  is to be referenced.
kusano 2b45e8
*
kusano 2b45e8
*           Unchanged on exit.
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'   C := alpha*A*conjg( A' ) + beta*C.
kusano 2b45e8
*
kusano 2b45e8
*              TRANS = 'C' or 'c'   C := alpha*conjg( A' )*A + beta*C.
kusano 2b45e8
*
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  N      - INTEGER.
kusano 2b45e8
*           On entry,  N specifies the order of the matrix C.  N must be
kusano 2b45e8
*           at least zero.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  K      - INTEGER.
kusano 2b45e8
*           On entry with  TRANS = 'N' or 'n',  K  specifies  the number
kusano 2b45e8
*           of  columns   of  the   matrix   A,   and  on   entry   with
kusano 2b45e8
*           TRANS = 'C' or 'c',  K  specifies  the number of rows of the
kusano 2b45e8
*           matrix A.  K must be at least zero.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  ALPHA  - DOUBLE PRECISION            .
kusano 2b45e8
*           On entry, ALPHA specifies the scalar alpha.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  A      - COMPLEX*16       array of DIMENSION ( LDA, ka ), where ka is
kusano 2b45e8
*           k  when  TRANS = 'N' or 'n',  and is  n  otherwise.
kusano 2b45e8
*           Before entry with  TRANS = 'N' or 'n',  the  leading  n by k
kusano 2b45e8
*           part of the array  A  must contain the matrix  A,  otherwise
kusano 2b45e8
*           the leading  k by n  part of the array  A  must contain  the
kusano 2b45e8
*           matrix A.
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.   When  TRANS = 'N' or 'n'
kusano 2b45e8
*           then  LDA must be at least  max( 1, n ), otherwise  LDA must
kusano 2b45e8
*           be at least  max( 1, k ).
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  BETA   - DOUBLE PRECISION.
kusano 2b45e8
*           On entry, BETA specifies the scalar beta.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  C      - COMPLEX*16          array of DIMENSION ( LDC, n ).
kusano 2b45e8
*           Before entry  with  UPLO = 'U' or 'u',  the leading  n by n
kusano 2b45e8
*           upper triangular part of the array C must contain the upper
kusano 2b45e8
*           triangular part  of the  hermitian matrix  and the strictly
kusano 2b45e8
*           lower triangular part of C is not referenced.  On exit, the
kusano 2b45e8
*           upper triangular part of the array  C is overwritten by the
kusano 2b45e8
*           upper triangular part of the updated matrix.
kusano 2b45e8
*           Before entry  with  UPLO = 'L' or 'l',  the leading  n by n
kusano 2b45e8
*           lower triangular part of the array C must contain the lower
kusano 2b45e8
*           triangular part  of the  hermitian matrix  and the strictly
kusano 2b45e8
*           upper triangular part of C is not referenced.  On exit, the
kusano 2b45e8
*           lower triangular part of the array  C is overwritten by the
kusano 2b45e8
*           lower triangular part of the updated matrix.
kusano 2b45e8
*           Note that the imaginary parts of the diagonal elements need
kusano 2b45e8
*           not be set,  they are assumed to be zero,  and on exit they
kusano 2b45e8
*           are set to zero.
kusano 2b45e8
*
kusano 2b45e8
*  LDC    - INTEGER.
kusano 2b45e8
*           On entry, LDC specifies the first dimension of C as declared
kusano 2b45e8
*           in  the  calling  (sub)  program.   LDC  must  be  at  least
kusano 2b45e8
*           max( 1, n ).
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*  Level 3 Blas routine.
kusano 2b45e8
*
kusano 2b45e8
*  -- Written on 8-February-1989.
kusano 2b45e8
*     Jack Dongarra, Argonne National Laboratory.
kusano 2b45e8
*     Iain Duff, AERE Harwell.
kusano 2b45e8
*     Jeremy Du Croz, Numerical Algorithms Group Ltd.
kusano 2b45e8
*     Sven Hammarling, Numerical Algorithms Group Ltd.
kusano 2b45e8
*
kusano 2b45e8
*  -- Modified 8-Nov-93 to set C(J,J) to DBLE( C(J,J) ) when BETA = 1.
kusano 2b45e8
*     Ed Anderson, Cray Research Inc.
kusano 2b45e8
*
kusano 2b45e8
*
kusano 2b45e8
*     .. External Functions ..
kusano 2b45e8
      LOGICAL            LSAME
kusano 2b45e8
      EXTERNAL           LSAME
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. External Subroutines ..
kusano 2b45e8
      EXTERNAL           XERBLA
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Intrinsic Functions ..
kusano 2b45e8
      INTRINSIC          DBLE, DCMPLX, DCONJG, MAX
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      LOGICAL            UPPER
kusano 2b45e8
      INTEGER            I, INFO, J, L, NROWA
kusano 2b45e8
      DOUBLE PRECISION   RTEMP
kusano 2b45e8
      COMPLEX*16         TEMP
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      DOUBLE PRECISION   ONE, ZERO
kusano 2b45e8
      PARAMETER          ( ONE = 1.0D+0, ZERO = 0.0D+0 )
kusano 2b45e8
*     ..
kusano 2b45e8
*     .. Executable Statements ..
kusano 2b45e8
*
kusano 2b45e8
*     Test the input parameters.
kusano 2b45e8
*
kusano 2b45e8
      IF( LSAME( TRANS, 'N' ) ) THEN
kusano 2b45e8
         NROWA = N
kusano 2b45e8
      ELSE
kusano 2b45e8
         NROWA = K
kusano 2b45e8
      END IF
kusano 2b45e8
      UPPER = LSAME( UPLO, 'U' )
kusano 2b45e8
*
kusano 2b45e8
      INFO = 0
kusano 2b45e8
      IF( ( .NOT.UPPER ) .AND. ( .NOT.LSAME( UPLO, 'L' ) ) ) THEN
kusano 2b45e8
         INFO = 1
kusano 2b45e8
      ELSE IF( ( .NOT.LSAME( TRANS, 'N' ) ) .AND.
kusano 2b45e8
     $         ( .NOT.LSAME( TRANS, 'C' ) ) ) THEN
kusano 2b45e8
         INFO = 2
kusano 2b45e8
      ELSE IF( N.LT.0 ) THEN
kusano 2b45e8
         INFO = 3
kusano 2b45e8
      ELSE IF( K.LT.0 ) THEN
kusano 2b45e8
         INFO = 4
kusano 2b45e8
      ELSE IF( LDA.LT.MAX( 1, NROWA ) ) THEN
kusano 2b45e8
         INFO = 7
kusano 2b45e8
      ELSE IF( LDC.LT.MAX( 1, N ) ) THEN
kusano 2b45e8
         INFO = 10
kusano 2b45e8
      END IF
kusano 2b45e8
      IF( INFO.NE.0 ) THEN
kusano 2b45e8
         CALL XERBLA( 'ZHERK ', INFO )
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Quick return if possible.
kusano 2b45e8
*
kusano 2b45e8
      IF( ( N.EQ.0 ) .OR. ( ( ( ALPHA.EQ.ZERO ) .OR. ( K.EQ.0 ) ) .AND.
kusano 2b45e8
     $    ( BETA.EQ.ONE ) ) )RETURN
kusano 2b45e8
*
kusano 2b45e8
*     And when  alpha.eq.zero.
kusano 2b45e8
*
kusano 2b45e8
      IF( ALPHA.EQ.ZERO ) THEN
kusano 2b45e8
         IF( UPPER ) THEN
kusano 2b45e8
            IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
               DO 20 J = 1, N
kusano 2b45e8
                  DO 10 I = 1, J
kusano 2b45e8
                     C( I, J ) = ZERO
kusano 2b45e8
   10             CONTINUE
kusano 2b45e8
   20          CONTINUE
kusano 2b45e8
            ELSE
kusano 2b45e8
               DO 40 J = 1, N
kusano 2b45e8
                  DO 30 I = 1, J - 1
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
   30             CONTINUE
kusano 2b45e8
                  C( J, J ) = BETA*DBLE( C( J, J ) )
kusano 2b45e8
   40          CONTINUE
kusano 2b45e8
            END IF
kusano 2b45e8
         ELSE
kusano 2b45e8
            IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
               DO 60 J = 1, N
kusano 2b45e8
                  DO 50 I = J, N
kusano 2b45e8
                     C( I, J ) = ZERO
kusano 2b45e8
   50             CONTINUE
kusano 2b45e8
   60          CONTINUE
kusano 2b45e8
            ELSE
kusano 2b45e8
               DO 80 J = 1, N
kusano 2b45e8
                  C( J, J ) = BETA*DBLE( C( J, J ) )
kusano 2b45e8
                  DO 70 I = J + 1, N
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
   70             CONTINUE
kusano 2b45e8
   80          CONTINUE
kusano 2b45e8
            END IF
kusano 2b45e8
         END IF
kusano 2b45e8
         RETURN
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
*     Start the operations.
kusano 2b45e8
*
kusano 2b45e8
      IF( LSAME( TRANS, 'N' ) ) THEN
kusano 2b45e8
*
kusano 2b45e8
*        Form  C := alpha*A*conjg( A' ) + beta*C.
kusano 2b45e8
*
kusano 2b45e8
         IF( UPPER ) THEN
kusano 2b45e8
            DO 130 J = 1, N
kusano 2b45e8
               IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                  DO 90 I = 1, J
kusano 2b45e8
                     C( I, J ) = ZERO
kusano 2b45e8
   90             CONTINUE
kusano 2b45e8
               ELSE IF( BETA.NE.ONE ) THEN
kusano 2b45e8
                  DO 100 I = 1, J - 1
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
  100             CONTINUE
kusano 2b45e8
                  C( J, J ) = BETA*DBLE( C( J, J ) )
kusano 2b45e8
               ELSE
kusano 2b45e8
                  C( J, J ) = DBLE( C( J, J ) )
kusano 2b45e8
               END IF
kusano 2b45e8
               DO 120 L = 1, K
kusano 2b45e8
                  IF( A( J, L ).NE.DCMPLX( ZERO ) ) THEN
kusano 2b45e8
                     TEMP = ALPHA*DCONJG( A( J, L ) )
kusano 2b45e8
                     DO 110 I = 1, J - 1
kusano 2b45e8
                        C( I, J ) = C( I, J ) + TEMP*A( I, L )
kusano 2b45e8
  110                CONTINUE
kusano 2b45e8
                     C( J, J ) = DBLE( C( J, J ) ) +
kusano 2b45e8
     $                           DBLE( TEMP*A( I, L ) )
kusano 2b45e8
                  END IF
kusano 2b45e8
  120          CONTINUE
kusano 2b45e8
  130       CONTINUE
kusano 2b45e8
         ELSE
kusano 2b45e8
            DO 180 J = 1, N
kusano 2b45e8
               IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                  DO 140 I = J, N
kusano 2b45e8
                     C( I, J ) = ZERO
kusano 2b45e8
  140             CONTINUE
kusano 2b45e8
               ELSE IF( BETA.NE.ONE ) THEN
kusano 2b45e8
                  C( J, J ) = BETA*DBLE( C( J, J ) )
kusano 2b45e8
                  DO 150 I = J + 1, N
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
  150             CONTINUE
kusano 2b45e8
               ELSE
kusano 2b45e8
                  C( J, J ) = DBLE( C( J, J ) )
kusano 2b45e8
               END IF
kusano 2b45e8
               DO 170 L = 1, K
kusano 2b45e8
                  IF( A( J, L ).NE.DCMPLX( ZERO ) ) THEN
kusano 2b45e8
                     TEMP = ALPHA*DCONJG( A( J, L ) )
kusano 2b45e8
                     C( J, J ) = DBLE( C( J, J ) ) +
kusano 2b45e8
     $                           DBLE( TEMP*A( J, L ) )
kusano 2b45e8
                     DO 160 I = J + 1, N
kusano 2b45e8
                        C( I, J ) = C( I, J ) + TEMP*A( I, L )
kusano 2b45e8
  160                CONTINUE
kusano 2b45e8
                  END IF
kusano 2b45e8
  170          CONTINUE
kusano 2b45e8
  180       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      ELSE
kusano 2b45e8
*
kusano 2b45e8
*        Form  C := alpha*conjg( A' )*A + beta*C.
kusano 2b45e8
*
kusano 2b45e8
         IF( UPPER ) THEN
kusano 2b45e8
            DO 220 J = 1, N
kusano 2b45e8
               DO 200 I = 1, J - 1
kusano 2b45e8
                  TEMP = ZERO
kusano 2b45e8
                  DO 190 L = 1, K
kusano 2b45e8
                     TEMP = TEMP + DCONJG( A( L, I ) )*A( L, J )
kusano 2b45e8
  190             CONTINUE
kusano 2b45e8
                  IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                     C( I, J ) = ALPHA*TEMP
kusano 2b45e8
                  ELSE
kusano 2b45e8
                     C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
kusano 2b45e8
                  END IF
kusano 2b45e8
  200          CONTINUE
kusano 2b45e8
               RTEMP = ZERO
kusano 2b45e8
               DO 210 L = 1, K
kusano 2b45e8
                  RTEMP = RTEMP + DCONJG( A( L, J ) )*A( L, J )
kusano 2b45e8
  210          CONTINUE
kusano 2b45e8
               IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                  C( J, J ) = ALPHA*RTEMP
kusano 2b45e8
               ELSE
kusano 2b45e8
                  C( J, J ) = ALPHA*RTEMP + BETA*DBLE( C( J, J ) )
kusano 2b45e8
               END IF
kusano 2b45e8
  220       CONTINUE
kusano 2b45e8
         ELSE
kusano 2b45e8
            DO 260 J = 1, N
kusano 2b45e8
               RTEMP = ZERO
kusano 2b45e8
               DO 230 L = 1, K
kusano 2b45e8
                  RTEMP = RTEMP + DCONJG( A( L, J ) )*A( L, J )
kusano 2b45e8
  230          CONTINUE
kusano 2b45e8
               IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                  C( J, J ) = ALPHA*RTEMP
kusano 2b45e8
               ELSE
kusano 2b45e8
                  C( J, J ) = ALPHA*RTEMP + BETA*DBLE( C( J, J ) )
kusano 2b45e8
               END IF
kusano 2b45e8
               DO 250 I = J + 1, N
kusano 2b45e8
                  TEMP = ZERO
kusano 2b45e8
                  DO 240 L = 1, K
kusano 2b45e8
                     TEMP = TEMP + DCONJG( A( L, I ) )*A( L, J )
kusano 2b45e8
  240             CONTINUE
kusano 2b45e8
                  IF( BETA.EQ.ZERO ) THEN
kusano 2b45e8
                     C( I, J ) = ALPHA*TEMP
kusano 2b45e8
                  ELSE
kusano 2b45e8
                     C( I, J ) = ALPHA*TEMP + BETA*C( I, J )
kusano 2b45e8
                  END IF
kusano 2b45e8
  250          CONTINUE
kusano 2b45e8
  260       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of ZHERK .
kusano 2b45e8
*
kusano 2b45e8
      END