kusano 2b45e8
      SUBROUTINE CSYRKF ( UPLO, TRANS, N, K, ALPHA, A, LDA,
kusano 2b45e8
     $                   BETA, C, LDC )
kusano 2b45e8
*     .. Scalar Arguments ..
kusano 2b45e8
      CHARACTER*1        UPLO, TRANS
kusano 2b45e8
      INTEGER            N, K, LDA, LDC
kusano 2b45e8
      COMPLEX            ALPHA, BETA
kusano 2b45e8
*     .. Array Arguments ..
kusano 2b45e8
      COMPLEX            A( LDA, * ), C( LDC, * )
kusano 2b45e8
*     ..
kusano 2b45e8
*
kusano 2b45e8
*  Purpose
kusano 2b45e8
*  =======
kusano 2b45e8
*
kusano 2b45e8
*  CSYRK  performs one of the symmetric rank k operations
kusano 2b45e8
*
kusano 2b45e8
*     C := alpha*A*A' + beta*C,
kusano 2b45e8
*
kusano 2b45e8
*  or
kusano 2b45e8
*
kusano 2b45e8
*     C := alpha*A'*A + beta*C,
kusano 2b45e8
*
kusano 2b45e8
*  where  alpha and beta  are scalars,  C is an  n by n symmetric matrix
kusano 2b45e8
*  and  A  is an  n by k  matrix in the first case and a  k by n  matrix
kusano 2b45e8
*  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*A' + beta*C.
kusano 2b45e8
*
kusano 2b45e8
*              TRANS = 'T' or 't'   C := alpha*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 = 'T' or 't',  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  - COMPLEX         .
kusano 2b45e8
*           On entry, ALPHA specifies the scalar alpha.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  A      - COMPLEX          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   - COMPLEX         .
kusano 2b45e8
*           On entry, BETA specifies the scalar beta.
kusano 2b45e8
*           Unchanged on exit.
kusano 2b45e8
*
kusano 2b45e8
*  C      - COMPLEX          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  symmetric 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  symmetric 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
*
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
*
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
kusano 2b45e8
*     .. Local Scalars ..
kusano 2b45e8
      LOGICAL            UPPER
kusano 2b45e8
      INTEGER            I, INFO, J, L, NROWA
kusano 2b45e8
      COMPLEX            TEMP
kusano 2b45e8
*     .. Parameters ..
kusano 2b45e8
      COMPLEX            ONE
kusano 2b45e8
      PARAMETER        ( ONE  = ( 1.0E+0, 0.0E+0 ) )
kusano 2b45e8
      COMPLEX            ZERO
kusano 2b45e8
      PARAMETER        ( ZERO = ( 0.0E+0, 0.0E+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.
kusano 2b45e8
     $         ( .NOT.LSAME( UPLO , 'L' ) )      )THEN
kusano 2b45e8
         INFO = 1
kusano 2b45e8
      ELSE IF( ( .NOT.LSAME( TRANS, 'N' ) ).AND.
kusano 2b45e8
     $         ( .NOT.LSAME( TRANS, 'T' ) )      )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( 'CSYRK ', 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.
kusano 2b45e8
     $    ( ( ( ALPHA.EQ.ZERO ).OR.( K.EQ.0 ) ).AND.( BETA.EQ.ONE ) ) )
kusano 2b45e8
     $   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
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
   30             CONTINUE
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
                  DO 70, I = J, 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*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
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
  100             CONTINUE
kusano 2b45e8
               END IF
kusano 2b45e8
               DO 120, L = 1, K
kusano 2b45e8
                  IF( A( J, L ).NE.ZERO )THEN
kusano 2b45e8
                     TEMP = ALPHA*A( J, L )
kusano 2b45e8
                     DO 110, I = 1, J
kusano 2b45e8
                        C( I, J ) = C( I, J ) + TEMP*A( I, L )
kusano 2b45e8
  110                CONTINUE
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
                  DO 150, I = J, N
kusano 2b45e8
                     C( I, J ) = BETA*C( I, J )
kusano 2b45e8
  150             CONTINUE
kusano 2b45e8
               END IF
kusano 2b45e8
               DO 170, L = 1, K
kusano 2b45e8
                  IF( A( J, L ).NE.ZERO )THEN
kusano 2b45e8
                     TEMP      = ALPHA*A( J, L )
kusano 2b45e8
                     DO 160, I = J, 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*A'*A + beta*C.
kusano 2b45e8
*
kusano 2b45e8
         IF( UPPER )THEN
kusano 2b45e8
            DO 210, J = 1, N
kusano 2b45e8
               DO 200, I = 1, J
kusano 2b45e8
                  TEMP = ZERO
kusano 2b45e8
                  DO 190, L = 1, K
kusano 2b45e8
                     TEMP = TEMP + 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
  210       CONTINUE
kusano 2b45e8
         ELSE
kusano 2b45e8
            DO 240, J = 1, N
kusano 2b45e8
               DO 230, I = J, N
kusano 2b45e8
                  TEMP = ZERO
kusano 2b45e8
                  DO 220, L = 1, K
kusano 2b45e8
                     TEMP = TEMP + A( L, I )*A( L, J )
kusano 2b45e8
  220             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
  230          CONTINUE
kusano 2b45e8
  240       CONTINUE
kusano 2b45e8
         END IF
kusano 2b45e8
      END IF
kusano 2b45e8
*
kusano 2b45e8
      RETURN
kusano 2b45e8
*
kusano 2b45e8
*     End of CSYRK .
kusano 2b45e8
*
kusano 2b45e8
      END