dpotrf.c 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* dpotrf.f -- translated by f2c (version 20061008).
  2. You must link the resulting object file with libf2c:
  3. on Microsoft Windows system, link with libf2c.lib;
  4. on Linux or Unix systems, link with .../path/to/libf2c.a -lm
  5. or, if you install libf2c.a in a standard place, with -lf2c -lm
  6. -- in that order, at the end of the command line, as in
  7. cc *.o -lf2c -lm
  8. Source for libf2c is in /netlib/f2c/libf2c.zip, e.g.,
  9. http://www.netlib.org/f2c/libf2c.zip
  10. */
  11. #include "f2c.h"
  12. #include "blaswrap.h"
  13. /* Table of constant values */
  14. static integer c__1 = 1;
  15. static integer c_n1 = -1;
  16. static doublereal c_b15 = 1.;
  17. static doublereal c_b18 = -1.;
  18. /* Subroutine */ int _starpu_dpotrf_(char *uplo, integer *n, doublereal *a, integer *
  19. lda, integer *info)
  20. {
  21. /* System generated locals */
  22. integer a_dim1, a_offset, i__1, i__2, i__3, i__4;
  23. /* Local variables */
  24. integer j, jb, nb;
  25. extern logical _starpu_lsame_(char *, char *);
  26. extern /* Subroutine */ int _starpu_dtrsm_(char *, char *, char *, char *,
  27. integer *, integer *, doublereal *, doublereal *, integer *,
  28. doublereal *, integer *);
  29. logical upper;
  30. extern /* Subroutine */ int _starpu_dsyrk_(char *, char *, integer *, integer *,
  31. doublereal *, doublereal *, integer *, doublereal *, doublereal *,
  32. integer *), _starpu_dpotf2_(char *, integer *,
  33. doublereal *, integer *, integer *), _starpu_xerbla_(char *,
  34. integer *);
  35. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  36. integer *, integer *);
  37. /* -- LAPACK routine (version 3.1) -- */
  38. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  39. /* March 2008 */
  40. /* .. Scalar Arguments .. */
  41. /* .. */
  42. /* .. Array Arguments .. */
  43. /* .. */
  44. /* Purpose */
  45. /* ======= */
  46. /* DPOTRF computes the Cholesky factorization of a real symmetric */
  47. /* 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. */
  52. /* This is the top-looking block version of the algorithm, calling Level 3 BLAS. */
  53. /* Arguments */
  54. /* ========= */
  55. /* UPLO (input) CHARACTER*1 */
  56. /* = 'U': Upper triangle of A is stored; */
  57. /* = 'L': Lower triangle of A is stored. */
  58. /* N (input) INTEGER */
  59. /* The order of the matrix A. N >= 0. */
  60. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  61. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  62. /* N-by-N upper triangular part of A contains the upper */
  63. /* triangular part of the matrix A, and the strictly lower */
  64. /* triangular part of A is not referenced. If UPLO = 'L', the */
  65. /* leading N-by-N lower triangular part of A contains the lower */
  66. /* triangular part of the matrix A, and the strictly upper */
  67. /* triangular part of A is not referenced. */
  68. /* On exit, if INFO = 0, the factor U or L from the Cholesky */
  69. /* factorization A = U**T*U or A = L*L**T. */
  70. /* LDA (input) INTEGER */
  71. /* The leading dimension of the array A. LDA >= max(1,N). */
  72. /* INFO (output) INTEGER */
  73. /* = 0: successful exit */
  74. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  75. /* > 0: if INFO = i, the leading minor of order i is not */
  76. /* positive definite, and the factorization could not be */
  77. /* completed. */
  78. /* ===================================================================== */
  79. /* .. Parameters .. */
  80. /* .. */
  81. /* .. Local Scalars .. */
  82. /* .. */
  83. /* .. External Functions .. */
  84. /* .. */
  85. /* .. External Subroutines .. */
  86. /* .. */
  87. /* .. Intrinsic Functions .. */
  88. /* .. */
  89. /* .. Executable Statements .. */
  90. /* Test the input parameters. */
  91. /* Parameter adjustments */
  92. a_dim1 = *lda;
  93. a_offset = 1 + a_dim1;
  94. a -= a_offset;
  95. /* Function Body */
  96. *info = 0;
  97. upper = _starpu_lsame_(uplo, "U");
  98. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  99. *info = -1;
  100. } else if (*n < 0) {
  101. *info = -2;
  102. } else if (*lda < max(1,*n)) {
  103. *info = -4;
  104. }
  105. if (*info != 0) {
  106. i__1 = -(*info);
  107. _starpu_xerbla_("DPOTRF", &i__1);
  108. return 0;
  109. }
  110. /* Quick return if possible */
  111. if (*n == 0) {
  112. return 0;
  113. }
  114. /* Determine the block size for this environment. */
  115. nb = _starpu_ilaenv_(&c__1, "DPOTRF", uplo, n, &c_n1, &c_n1, &c_n1);
  116. if (nb <= 1 || nb >= *n) {
  117. /* Use unblocked code. */
  118. _starpu_dpotf2_(uplo, n, &a[a_offset], lda, info);
  119. } else {
  120. /* Use blocked code. */
  121. if (upper) {
  122. /* Compute the Cholesky factorization A = U'*U. */
  123. i__1 = *n;
  124. i__2 = nb;
  125. for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  126. /* Computing MIN */
  127. i__3 = nb, i__4 = *n - j + 1;
  128. jb = min(i__3,i__4);
  129. /* Compute the current block. */
  130. i__3 = j - 1;
  131. _starpu_dtrsm_("Left", "Upper", "Transpose", "Non-unit", &i__3, &jb, &
  132. c_b15, &a[a_dim1 + 1], lda, &a[j * a_dim1 + 1], lda);
  133. i__3 = j - 1;
  134. _starpu_dsyrk_("Upper", "Transpose", &jb, &i__3, &c_b18, &a[j *
  135. a_dim1 + 1], lda, &c_b15, &a[j + j * a_dim1], lda);
  136. /* Update and factorize the current diagonal block and test */
  137. /* for non-positive-definiteness. */
  138. _starpu_dpotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info);
  139. if (*info != 0) {
  140. goto L30;
  141. }
  142. /* L10: */
  143. }
  144. } else {
  145. /* Compute the Cholesky factorization A = L*L'. */
  146. i__2 = *n;
  147. i__1 = nb;
  148. for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  149. /* Computing MIN */
  150. i__3 = nb, i__4 = *n - j + 1;
  151. jb = min(i__3,i__4);
  152. /* Compute the current block. */
  153. i__3 = j - 1;
  154. _starpu_dtrsm_("Right", "Lower", "Transpose", "Non-unit", &jb, &i__3,
  155. &c_b15, &a[a_dim1 + 1], lda, &a[j + a_dim1], lda);
  156. i__3 = j - 1;
  157. _starpu_dsyrk_("Lower", "No Transpose", &jb, &i__3, &c_b18, &a[j +
  158. a_dim1], lda, &c_b15, &a[j + j * a_dim1], lda);
  159. /* Update and factorize the current diagonal block and test */
  160. /* for non-positive-definiteness. */
  161. _starpu_dpotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info);
  162. if (*info != 0) {
  163. goto L30;
  164. }
  165. /* L20: */
  166. }
  167. }
  168. }
  169. goto L40;
  170. L30:
  171. *info = *info + j - 1;
  172. L40:
  173. return 0;
  174. /* End of DPOTRF */
  175. } /* _starpu_dpotrf_ */