|
kusano |
2b45e8 |
SUBROUTINE ZSPRF( UPLO, N, ALPHA, X, INCX, AP )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- LAPACK auxiliary routine (version 3.1) --
|
|
kusano |
2b45e8 |
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
|
|
kusano |
2b45e8 |
* November 2006
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
CHARACTER UPLO
|
|
kusano |
2b45e8 |
INTEGER INCX, N
|
|
kusano |
2b45e8 |
COMPLEX*16 ALPHA
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
COMPLEX*16 AP( * ), X( * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* ZSPR performs the symmetric rank 1 operation
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A := alpha*x*conjg( x' ) + A,
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* where alpha is a complex scalar, x is an n element vector and A is an
|
|
kusano |
2b45e8 |
* n by n symmetric matrix, supplied in packed form.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* ==========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* On entry, UPLO specifies whether the upper or lower
|
|
kusano |
2b45e8 |
* triangular part of the matrix A is supplied in the packed
|
|
kusano |
2b45e8 |
* array AP as follows:
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'U' or 'u' The upper triangular part of A is
|
|
kusano |
2b45e8 |
* supplied in AP.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO = 'L' or 'l' The lower triangular part of A is
|
|
kusano |
2b45e8 |
* supplied in AP.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N (input) INTEGER
|
|
kusano |
2b45e8 |
* On entry, N specifies the order of the matrix A.
|
|
kusano |
2b45e8 |
* N must be at least zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* ALPHA (input) COMPLEX*16
|
|
kusano |
2b45e8 |
* On entry, ALPHA specifies the scalar alpha.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* X (input) COMPLEX*16 array, dimension at least
|
|
kusano |
2b45e8 |
* ( 1 + ( N - 1 )*abs( INCX ) ).
|
|
kusano |
2b45e8 |
* Before entry, the incremented array X must contain the N-
|
|
kusano |
2b45e8 |
* element vector x.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* INCX (input) INTEGER
|
|
kusano |
2b45e8 |
* On entry, INCX specifies the increment for the elements of
|
|
kusano |
2b45e8 |
* X. INCX must not be zero.
|
|
kusano |
2b45e8 |
* Unchanged on exit.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* AP (input/output) COMPLEX*16 array, dimension at least
|
|
kusano |
2b45e8 |
* ( ( N*( N + 1 ) )/2 ).
|
|
kusano |
2b45e8 |
* Before entry, with UPLO = 'U' or 'u', the array AP must
|
|
kusano |
2b45e8 |
* contain the upper triangular part of the symmetric matrix
|
|
kusano |
2b45e8 |
* packed sequentially, column by column, so that AP( 1 )
|
|
kusano |
2b45e8 |
* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 1, 2 )
|
|
kusano |
2b45e8 |
* and a( 2, 2 ) respectively, and so on. On exit, the array
|
|
kusano |
2b45e8 |
* AP is overwritten by the upper triangular part of the
|
|
kusano |
2b45e8 |
* updated matrix.
|
|
kusano |
2b45e8 |
* Before entry, with UPLO = 'L' or 'l', the array AP must
|
|
kusano |
2b45e8 |
* contain the lower triangular part of the symmetric matrix
|
|
kusano |
2b45e8 |
* packed sequentially, column by column, so that AP( 1 )
|
|
kusano |
2b45e8 |
* contains a( 1, 1 ), AP( 2 ) and AP( 3 ) contain a( 2, 1 )
|
|
kusano |
2b45e8 |
* and a( 3, 1 ) respectively, and so on. On exit, the array
|
|
kusano |
2b45e8 |
* AP is overwritten by the lower triangular part of the
|
|
kusano |
2b45e8 |
* 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 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
COMPLEX*16 ZERO
|
|
kusano |
2b45e8 |
PARAMETER ( ZERO = ( 0.0D+0, 0.0D+0 ) )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
INTEGER I, INFO, IX, J, JX, K, KK, KX
|
|
kusano |
2b45e8 |
COMPLEX*16 TEMP
|
|
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 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
IF( .NOT.LSAME( UPLO, 'U' ) .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
|
|
kusano |
2b45e8 |
INFO = 1
|
|
kusano |
2b45e8 |
ELSE IF( N.LT.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = 2
|
|
kusano |
2b45e8 |
ELSE IF( INCX.EQ.0 ) THEN
|
|
kusano |
2b45e8 |
INFO = 5
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 ) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'ZSPR ', 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 ) )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Set the start point in X if the increment is not unity.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( INCX.LE.0 ) THEN
|
|
kusano |
2b45e8 |
KX = 1 - ( N-1 )*INCX
|
|
kusano |
2b45e8 |
ELSE IF( INCX.NE.1 ) THEN
|
|
kusano |
2b45e8 |
KX = 1
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Start the operations. In this version the elements of the array AP
|
|
kusano |
2b45e8 |
* are accessed sequentially with one pass through AP.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
KK = 1
|
|
kusano |
2b45e8 |
IF( LSAME( UPLO, 'U' ) ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form A when upper triangle is stored in AP.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( INCX.EQ.1 ) THEN
|
|
kusano |
2b45e8 |
DO 20 J = 1, N
|
|
kusano |
2b45e8 |
IF( X( J ).NE.ZERO ) THEN
|
|
kusano |
2b45e8 |
TEMP = ALPHA*X( J )
|
|
kusano |
2b45e8 |
K = KK
|
|
kusano |
2b45e8 |
DO 10 I = 1, J - 1
|
|
kusano |
2b45e8 |
AP( K ) = AP( K ) + X( I )*TEMP
|
|
kusano |
2b45e8 |
K = K + 1
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
AP( KK+J-1 ) = AP( KK+J-1 ) + X( J )*TEMP
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AP( KK+J-1 ) = AP( KK+J-1 )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
KK = KK + J
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 40 J = 1, N
|
|
kusano |
2b45e8 |
IF( X( JX ).NE.ZERO ) THEN
|
|
kusano |
2b45e8 |
TEMP = ALPHA*X( JX )
|
|
kusano |
2b45e8 |
IX = KX
|
|
kusano |
2b45e8 |
DO 30 K = KK, KK + J - 2
|
|
kusano |
2b45e8 |
AP( K ) = AP( K ) + X( IX )*TEMP
|
|
kusano |
2b45e8 |
IX = IX + INCX
|
|
kusano |
2b45e8 |
30 CONTINUE
|
|
kusano |
2b45e8 |
AP( KK+J-1 ) = AP( KK+J-1 ) + X( JX )*TEMP
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AP( KK+J-1 ) = AP( KK+J-1 )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
JX = JX + INCX
|
|
kusano |
2b45e8 |
KK = KK + J
|
|
kusano |
2b45e8 |
40 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Form A when lower triangle is stored in AP.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( INCX.EQ.1 ) THEN
|
|
kusano |
2b45e8 |
DO 60 J = 1, N
|
|
kusano |
2b45e8 |
IF( X( J ).NE.ZERO ) THEN
|
|
kusano |
2b45e8 |
TEMP = ALPHA*X( J )
|
|
kusano |
2b45e8 |
AP( KK ) = AP( KK ) + TEMP*X( J )
|
|
kusano |
2b45e8 |
K = KK + 1
|
|
kusano |
2b45e8 |
DO 50 I = J + 1, N
|
|
kusano |
2b45e8 |
AP( K ) = AP( K ) + X( I )*TEMP
|
|
kusano |
2b45e8 |
K = K + 1
|
|
kusano |
2b45e8 |
50 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AP( KK ) = AP( KK )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
KK = KK + N - J + 1
|
|
kusano |
2b45e8 |
60 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
JX = KX
|
|
kusano |
2b45e8 |
DO 80 J = 1, N
|
|
kusano |
2b45e8 |
IF( X( JX ).NE.ZERO ) THEN
|
|
kusano |
2b45e8 |
TEMP = ALPHA*X( JX )
|
|
kusano |
2b45e8 |
AP( KK ) = AP( KK ) + TEMP*X( JX )
|
|
kusano |
2b45e8 |
IX = JX
|
|
kusano |
2b45e8 |
DO 70 K = KK + 1, KK + N - J
|
|
kusano |
2b45e8 |
IX = IX + INCX
|
|
kusano |
2b45e8 |
AP( K ) = AP( K ) + X( IX )*TEMP
|
|
kusano |
2b45e8 |
70 CONTINUE
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
AP( KK ) = AP( KK )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
JX = JX + INCX
|
|
kusano |
2b45e8 |
KK = KK + N - J + 1
|
|
kusano |
2b45e8 |
80 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of ZSPR
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|