|
kusano |
2b45e8 |
SUBROUTINE SPOTRFF( UPLO, N, A, LDA, INFO )
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* -- LAPACK routine (version 3.0) --
|
|
kusano |
2b45e8 |
* Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
|
|
kusano |
2b45e8 |
* Courant Institute, Argonne National Lab, and Rice University
|
|
kusano |
2b45e8 |
* March 31, 1993
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Scalar Arguments ..
|
|
kusano |
2b45e8 |
CHARACTER UPLO
|
|
kusano |
2b45e8 |
INTEGER INFO, LDA, N
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Array Arguments ..
|
|
kusano |
2b45e8 |
REAL A( LDA, * )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Purpose
|
|
kusano |
2b45e8 |
* =======
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* SPOTRF computes the Cholesky factorization of a real symmetric
|
|
kusano |
2b45e8 |
* positive definite matrix A.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* The factorization has the form
|
|
kusano |
2b45e8 |
* A = U**T * U, if UPLO = 'U', or
|
|
kusano |
2b45e8 |
* A = L * L**T, if UPLO = 'L',
|
|
kusano |
2b45e8 |
* where U is an upper triangular matrix and L is lower triangular.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* This is the block version of the algorithm, calling Level 3 BLAS.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Arguments
|
|
kusano |
2b45e8 |
* =========
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* UPLO (input) CHARACTER*1
|
|
kusano |
2b45e8 |
* = 'U': Upper triangle of A is stored;
|
|
kusano |
2b45e8 |
* = 'L': Lower triangle of A is stored.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* N (input) INTEGER
|
|
kusano |
2b45e8 |
* The order of the matrix A. N >= 0.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* A (input/output) REAL array, dimension (LDA,N)
|
|
kusano |
2b45e8 |
* On entry, the symmetric matrix A. If UPLO = 'U', the leading
|
|
kusano |
2b45e8 |
* N-by-N upper triangular part of A contains the upper
|
|
kusano |
2b45e8 |
* triangular part of the matrix A, and the strictly lower
|
|
kusano |
2b45e8 |
* triangular part of A is not referenced. If UPLO = 'L', the
|
|
kusano |
2b45e8 |
* leading N-by-N lower triangular part of A contains the lower
|
|
kusano |
2b45e8 |
* triangular part of the matrix A, and the strictly upper
|
|
kusano |
2b45e8 |
* triangular part of A is not referenced.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* On exit, if INFO = 0, the factor U or L from the Cholesky
|
|
kusano |
2b45e8 |
* factorization A = U**T*U or A = L*L**T.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* LDA (input) INTEGER
|
|
kusano |
2b45e8 |
* The leading dimension of the array A. LDA >= max(1,N).
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* INFO (output) INTEGER
|
|
kusano |
2b45e8 |
* = 0: successful exit
|
|
kusano |
2b45e8 |
* < 0: if INFO = -i, the i-th argument had an illegal value
|
|
kusano |
2b45e8 |
* > 0: if INFO = i, the leading minor of order i is not
|
|
kusano |
2b45e8 |
* positive definite, and the factorization could not be
|
|
kusano |
2b45e8 |
* completed.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* =====================================================================
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* .. Parameters ..
|
|
kusano |
2b45e8 |
REAL ONE
|
|
kusano |
2b45e8 |
PARAMETER ( ONE = 1.0E+0 )
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Local Scalars ..
|
|
kusano |
2b45e8 |
LOGICAL UPPER
|
|
kusano |
2b45e8 |
INTEGER J, JB, NB
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Functions ..
|
|
kusano |
2b45e8 |
LOGICAL LSAME
|
|
kusano |
2b45e8 |
EXTERNAL LSAME
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. External Subroutines ..
|
|
kusano |
2b45e8 |
EXTERNAL SGEMM, SPOTF2, SSYRK, STRSM, XERBLA
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Intrinsic Functions ..
|
|
kusano |
2b45e8 |
INTRINSIC MAX, MIN
|
|
kusano |
2b45e8 |
* ..
|
|
kusano |
2b45e8 |
* .. Executable Statements ..
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Test the input parameters.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
INFO = 0
|
|
kusano |
2b45e8 |
UPPER = LSAME( UPLO, 'U' )
|
|
kusano |
2b45e8 |
IF( .NOT.UPPER .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( LDA.LT.MAX( 1, N ) ) THEN
|
|
kusano |
2b45e8 |
INFO = -4
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 ) THEN
|
|
kusano |
2b45e8 |
CALL XERBLA( 'SPOTRF', -INFO )
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Quick return if possible
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( N.EQ.0 )
|
|
kusano |
2b45e8 |
$ RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Determine the block size for this environment.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
NB = 56
|
|
kusano |
2b45e8 |
|
|
kusano |
2b45e8 |
IF( NB.LE.1 .OR. NB.GE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use unblocked code.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL SPOTF2( UPLO, N, A, LDA, INFO )
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Use blocked code.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
IF( UPPER ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute the Cholesky factorization A = U'*U.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 10 J = 1, N, NB
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Update and factorize the current diagonal block and test
|
|
kusano |
2b45e8 |
* for non-positive-definiteness.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
JB = MIN( NB, N-J+1 )
|
|
kusano |
2b45e8 |
CALL SSYRK( 'Upper', 'Transpose', JB, J-1, -ONE,
|
|
kusano |
2b45e8 |
$ A( 1, J ), LDA, ONE, A( J, J ), LDA )
|
|
kusano |
2b45e8 |
CALL SPOTF2( 'Upper', JB, A( J, J ), LDA, INFO )
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 )
|
|
kusano |
2b45e8 |
$ GO TO 30
|
|
kusano |
2b45e8 |
IF( J+JB.LE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute the current block row.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL SGEMM( 'Transpose', 'No transpose', JB, N-J-JB+1,
|
|
kusano |
2b45e8 |
$ J-1, -ONE, A( 1, J ), LDA, A( 1, J+JB ),
|
|
kusano |
2b45e8 |
$ LDA, ONE, A( J, J+JB ), LDA )
|
|
kusano |
2b45e8 |
CALL STRSM( 'Left', 'Upper', 'Transpose', 'Non-unit',
|
|
kusano |
2b45e8 |
$ JB, N-J-JB+1, ONE, A( J, J ), LDA,
|
|
kusano |
2b45e8 |
$ A( J, J+JB ), LDA )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
10 CONTINUE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
ELSE
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute the Cholesky factorization A = L*L'.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
DO 20 J = 1, N, NB
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Update and factorize the current diagonal block and test
|
|
kusano |
2b45e8 |
* for non-positive-definiteness.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
JB = MIN( NB, N-J+1 )
|
|
kusano |
2b45e8 |
CALL SSYRK( 'Lower', 'No transpose', JB, J-1, -ONE,
|
|
kusano |
2b45e8 |
$ A( J, 1 ), LDA, ONE, A( J, J ), LDA )
|
|
kusano |
2b45e8 |
CALL SPOTF2( 'Lower', JB, A( J, J ), LDA, INFO )
|
|
kusano |
2b45e8 |
IF( INFO.NE.0 )
|
|
kusano |
2b45e8 |
$ GO TO 30
|
|
kusano |
2b45e8 |
IF( J+JB.LE.N ) THEN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* Compute the current block column.
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
CALL SGEMM( 'No transpose', 'Transpose', N-J-JB+1, JB,
|
|
kusano |
2b45e8 |
$ J-1, -ONE, A( J+JB, 1 ), LDA, A( J, 1 ),
|
|
kusano |
2b45e8 |
$ LDA, ONE, A( J+JB, J ), LDA )
|
|
kusano |
2b45e8 |
CALL STRSM( 'Right', 'Lower', 'Transpose', 'Non-unit',
|
|
kusano |
2b45e8 |
$ N-J-JB+1, JB, ONE, A( J, J ), LDA,
|
|
kusano |
2b45e8 |
$ A( J+JB, J ), LDA )
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
20 CONTINUE
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
END IF
|
|
kusano |
2b45e8 |
GO TO 40
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
30 CONTINUE
|
|
kusano |
2b45e8 |
INFO = INFO + J - 1
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
40 CONTINUE
|
|
kusano |
2b45e8 |
RETURN
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
* End of SPOTRF
|
|
kusano |
2b45e8 |
*
|
|
kusano |
2b45e8 |
END
|