1
SUBROUTINE SPOTF2( UPLO, N, A, LDA, INFO )
3
* -- LAPACK routine (version 3.1) --
4
* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
7
* .. Scalar Arguments ..
11
* .. Array Arguments ..
18
* SPOTF2 computes the Cholesky factorization of a real symmetric
19
* positive definite matrix A.
21
* The factorization has the form
22
* A = U' * U , if UPLO = 'U', or
23
* A = L * L', if UPLO = 'L',
24
* where U is an upper triangular matrix and L is lower triangular.
26
* This is the unblocked version of the algorithm, calling Level 2 BLAS.
31
* UPLO (input) CHARACTER*1
32
* Specifies whether the upper or lower triangular part of the
33
* symmetric matrix A is stored.
34
* = 'U': Upper triangular
35
* = 'L': Lower triangular
38
* The order of the matrix A. N >= 0.
40
* A (input/output) REAL array, dimension (LDA,N)
41
* On entry, the symmetric matrix A. If UPLO = 'U', the leading
42
* n by n upper triangular part of A contains the upper
43
* triangular part of the matrix A, and the strictly lower
44
* triangular part of A is not referenced. If UPLO = 'L', the
45
* leading n by n lower triangular part of A contains the lower
46
* triangular part of the matrix A, and the strictly upper
47
* triangular part of A is not referenced.
49
* On exit, if INFO = 0, the factor U or L from the Cholesky
50
* factorization A = U'*U or A = L*L'.
53
* The leading dimension of the array A. LDA >= max(1,N).
55
* INFO (output) INTEGER
56
* = 0: successful exit
57
* < 0: if INFO = -k, the k-th argument had an illegal value
58
* > 0: if INFO = k, the leading minor of order k is not
59
* positive definite, and the factorization could not be
62
* =====================================================================
66
PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
73
* .. External Functions ..
78
* .. External Subroutines ..
79
EXTERNAL SGEMV, SSCAL, XERBLA
81
* .. Intrinsic Functions ..
84
* .. Executable Statements ..
86
* Test the input parameters.
89
UPPER = LSAME( UPLO, 'U' )
90
IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
92
ELSE IF( N.LT.0 ) THEN
94
ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
98
CALL XERBLA( 'SPOTF2', -INFO )
102
* Quick return if possible
109
* Compute the Cholesky factorization A = U'*U.
113
* Compute U(J,J) and test for non-positive-definiteness.
115
AJJ = A( J, J ) - SDOT( J-1, A( 1, J ), 1, A( 1, J ), 1 )
116
IF( AJJ.LE.ZERO ) THEN
123
* Compute elements J+1:N of row J.
126
CALL SGEMV( 'Transpose', J-1, N-J, -ONE, A( 1, J+1 ),
127
$ LDA, A( 1, J ), 1, ONE, A( J, J+1 ), LDA )
128
CALL SSCAL( N-J, ONE / AJJ, A( J, J+1 ), LDA )
133
* Compute the Cholesky factorization A = L*L'.
137
* Compute L(J,J) and test for non-positive-definiteness.
139
AJJ = A( J, J ) - SDOT( J-1, A( J, 1 ), LDA, A( J, 1 ),
141
IF( AJJ.LE.ZERO ) THEN
148
* Compute elements J+1:N of column J.
151
CALL SGEMV( 'No transpose', N-J, J-1, -ONE, A( J+1, 1 ),
152
$ LDA, A( J, 1 ), LDA, ONE, A( J+1, J ), 1 )
153
CALL SSCAL( N-J, ONE / AJJ, A( J+1, J ), 1 )