3 /* Table of constant values */
5 static integer c__1 = 1;
6 static integer c_n1 = -1;
7 static real c_b13 = -1.f;
8 static real c_b14 = 1.f;
10 /* Subroutine */ int spotrf_(char *uplo, integer *n, real *a, integer *lda,
13 /* System generated locals */
14 integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
18 extern logical lsame_(char *, char *);
19 extern /* Subroutine */ int sgemm_(char *, char *, integer *, integer *,
20 integer *, real *, real *, integer *, real *, integer *, real *,
23 extern /* Subroutine */ int strsm_(char *, char *, char *, char *,
24 integer *, integer *, real *, real *, integer *, real *, integer *
25 ), ssyrk_(char *, char *, integer
26 *, integer *, real *, real *, integer *, real *, real *, integer *
27 ), spotf2_(char *, integer *, real *, integer *,
28 integer *), xerbla_(char *, integer *);
29 extern integer ilaenv_(integer *, char *, char *, integer *, integer *,
30 integer *, integer *);
33 /* -- LAPACK routine (version 3.1) -- */
34 /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
37 /* .. Scalar Arguments .. */
39 /* .. Array Arguments .. */
45 /* SPOTRF computes the Cholesky factorization of a real symmetric */
46 /* positive definite matrix A. */
48 /* The factorization has the form */
49 /* A = U**T * U, if UPLO = 'U', or */
50 /* A = L * L**T, if UPLO = 'L', */
51 /* where U is an upper triangular matrix and L is lower triangular. */
53 /* This is the block version of the algorithm, calling Level 3 BLAS. */
58 /* UPLO (input) CHARACTER*1 */
59 /* = 'U': Upper triangle of A is stored; */
60 /* = 'L': Lower triangle of A is stored. */
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**T*U or A = L*L**T. */
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 = -i, the i-th argument had an illegal value */
83 /* > 0: if INFO = i, the leading minor of order i 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_("SPOTRF", &i__1);
124 /* Quick return if possible */
130 /* Determine the block size for this environment. */
132 nb = ilaenv_(&c__1, "SPOTRF", uplo, n, &c_n1, &c_n1, &c_n1);
133 if (nb <= 1 || nb >= *n) {
135 /* Use unblocked code. */
137 spotf2_(uplo, n, &a[a_offset], lda, info);
140 /* Use blocked code. */
144 /* Compute the Cholesky factorization A = U'*U. */
148 for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
150 /* Update and factorize the current diagonal block and test */
151 /* for non-positive-definiteness. */
154 i__3 = nb, i__4 = *n - j + 1;
157 ssyrk_("Upper", "Transpose", &jb, &i__3, &c_b13, &a[j *
158 a_dim1 + 1], lda, &c_b14, &a[j + j * a_dim1], lda);
159 spotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info);
165 /* Compute the current block row. */
167 i__3 = *n - j - jb + 1;
169 sgemm_("Transpose", "No transpose", &jb, &i__3, &i__4, &
170 c_b13, &a[j * a_dim1 + 1], lda, &a[(j + jb) *
171 a_dim1 + 1], lda, &c_b14, &a[j + (j + jb) *
173 i__3 = *n - j - jb + 1;
174 strsm_("Left", "Upper", "Transpose", "Non-unit", &jb, &
175 i__3, &c_b14, &a[j + j * a_dim1], lda, &a[j + (j
176 + jb) * a_dim1], lda);
183 /* Compute the Cholesky factorization A = L*L'. */
187 for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
189 /* Update and factorize the current diagonal block and test */
190 /* for non-positive-definiteness. */
193 i__3 = nb, i__4 = *n - j + 1;
196 ssyrk_("Lower", "No transpose", &jb, &i__3, &c_b13, &a[j +
197 a_dim1], lda, &c_b14, &a[j + j * a_dim1], lda);
198 spotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info);
204 /* Compute the current block column. */
206 i__3 = *n - j - jb + 1;
208 sgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &
209 c_b13, &a[j + jb + a_dim1], lda, &a[j + a_dim1],
210 lda, &c_b14, &a[j + jb + j * a_dim1], lda);
211 i__3 = *n - j - jb + 1;
212 strsm_("Right", "Lower", "Transpose", "Non-unit", &i__3, &
213 jb, &c_b14, &a[j + j * a_dim1], lda, &a[j + jb +
223 *info = *info + j - 1;