3 /* Table of constant values */
5 static integer c__1 = 1;
6 static real c_b10 = -1.f;
7 static real c_b12 = 1.f;
9 /* Subroutine */ int spotf2_(char *uplo, integer *n, real *a, integer *lda,
12 /* System generated locals */
13 integer a_dim1, a_offset, i__1, i__2, i__3;
16 /* Builtin functions */
17 double sqrt(doublereal);
22 extern doublereal sdot_(integer *, real *, integer *, real *, integer *);
23 extern logical lsame_(char *, char *);
24 extern /* Subroutine */ int sscal_(integer *, real *, real *, integer *),
25 sgemv_(char *, integer *, integer *, real *, real *, integer *,
26 real *, integer *, real *, real *, integer *);
28 extern /* Subroutine */ int xerbla_(char *, integer *);
31 /* -- LAPACK routine (version 3.1) -- */
32 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
35 /* .. Scalar Arguments .. */
37 /* .. Array Arguments .. */
43 /* SPOTF2 computes the Cholesky factorization of a real symmetric */
44 /* positive definite matrix A. */
46 /* The factorization has the form */
47 /* A = U' * U , if UPLO = 'U', or */
48 /* A = L * L', if UPLO = 'L', */
49 /* where U is an upper triangular matrix and L is lower triangular. */
51 /* This is the unblocked version of the algorithm, calling Level 2 BLAS. */
56 /* UPLO (input) CHARACTER*1 */
57 /* Specifies whether the upper or lower triangular part of the */
58 /* symmetric matrix A is stored. */
59 /* = 'U': Upper triangular */
60 /* = 'L': Lower triangular */
62 /* N (input) INTEGER */
63 /* The order of the matrix A. N >= 0. */
65 /* A (input/output) REAL array, dimension (LDA,N) */
66 /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
67 /* n by n upper triangular part of A contains the upper */
68 /* triangular part of the matrix A, and the strictly lower */
69 /* triangular part of A is not referenced. If UPLO = 'L', the */
70 /* leading n by n lower triangular part of A contains the lower */
71 /* triangular part of the matrix A, and the strictly upper */
72 /* triangular part of A is not referenced. */
74 /* On exit, if INFO = 0, the factor U or L from the Cholesky */
75 /* factorization A = U'*U or A = L*L'. */
77 /* LDA (input) INTEGER */
78 /* The leading dimension of the array A. LDA >= max(1,N). */
80 /* INFO (output) INTEGER */
81 /* = 0: successful exit */
82 /* < 0: if INFO = -k, the k-th argument had an illegal value */
83 /* > 0: if INFO = k, the leading minor of order k is not */
84 /* positive definite, and the factorization could not be */
87 /* ===================================================================== */
89 /* .. Parameters .. */
91 /* .. Local Scalars .. */
93 /* .. External Functions .. */
95 /* .. External Subroutines .. */
97 /* .. Intrinsic Functions .. */
99 /* .. Executable Statements .. */
101 /* Test the input parameters. */
103 /* Parameter adjustments */
105 a_offset = 1 + a_dim1;
110 upper = lsame_(uplo, "U");
111 if (! upper && ! lsame_(uplo, "L")) {
115 } else if (*lda < max(1,*n)) {
120 xerbla_("SPOTF2", &i__1);
124 /* Quick return if possible */
132 /* Compute the Cholesky factorization A = U'*U. */
135 for (j = 1; j <= i__1; ++j) {
137 /* Compute U(J,J) and test for non-positive-definiteness. */
140 ajj = a[j + j * a_dim1] - sdot_(&i__2, &a[j * a_dim1 + 1], &c__1,
141 &a[j * a_dim1 + 1], &c__1);
143 a[j + j * a_dim1] = ajj;
147 a[j + j * a_dim1] = ajj;
149 /* Compute elements J+1:N of row J. */
154 sgemv_("Transpose", &i__2, &i__3, &c_b10, &a[(j + 1) * a_dim1
155 + 1], lda, &a[j * a_dim1 + 1], &c__1, &c_b12, &a[j + (
156 j + 1) * a_dim1], lda);
159 sscal_(&i__2, &r__1, &a[j + (j + 1) * a_dim1], lda);
165 /* Compute the Cholesky factorization A = L*L'. */
168 for (j = 1; j <= i__1; ++j) {
170 /* Compute L(J,J) and test for non-positive-definiteness. */
173 ajj = a[j + j * a_dim1] - sdot_(&i__2, &a[j + a_dim1], lda, &a[j
176 a[j + j * a_dim1] = ajj;
180 a[j + j * a_dim1] = ajj;
182 /* Compute elements J+1:N of column J. */
187 sgemv_("No transpose", &i__2, &i__3, &c_b10, &a[j + 1 +
188 a_dim1], lda, &a[j + a_dim1], lda, &c_b12, &a[j + 1 +
192 sscal_(&i__2, &r__1, &a[j + 1 + j * a_dim1], &c__1);