dpotrf.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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_b13 = -1.;
  17. static doublereal c_b14 = 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 /* Subroutine */ int _starpu_dgemm_(char *, char *, integer *, integer *,
  26. integer *, doublereal *, doublereal *, integer *, doublereal *,
  27. integer *, doublereal *, doublereal *, integer *);
  28. extern logical _starpu_lsame_(char *, char *);
  29. extern /* Subroutine */ int _starpu_dtrsm_(char *, char *, char *, char *,
  30. integer *, integer *, doublereal *, doublereal *, integer *,
  31. doublereal *, integer *);
  32. logical upper;
  33. extern /* Subroutine */ int _starpu_dsyrk_(char *, char *, integer *, integer *,
  34. doublereal *, doublereal *, integer *, doublereal *, doublereal *,
  35. integer *), _starpu_dpotf2_(char *, integer *,
  36. doublereal *, integer *, integer *), _starpu_xerbla_(char *,
  37. integer *);
  38. extern integer _starpu_ilaenv_(integer *, char *, char *, integer *, integer *,
  39. integer *, integer *);
  40. /* -- LAPACK routine (version 3.2) -- */
  41. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  42. /* November 2006 */
  43. /* .. Scalar Arguments .. */
  44. /* .. */
  45. /* .. Array Arguments .. */
  46. /* .. */
  47. /* Purpose */
  48. /* ======= */
  49. /* DPOTRF computes the Cholesky factorization of a real symmetric */
  50. /* positive definite matrix A. */
  51. /* The factorization has the form */
  52. /* A = U**T * U, if UPLO = 'U', or */
  53. /* A = L * L**T, if UPLO = 'L', */
  54. /* where U is an upper triangular matrix and L is lower triangular. */
  55. /* This is the block version of the algorithm, calling Level 3 BLAS. */
  56. /* Arguments */
  57. /* ========= */
  58. /* UPLO (input) CHARACTER*1 */
  59. /* = 'U': Upper triangle of A is stored; */
  60. /* = 'L': Lower triangle of A is stored. */
  61. /* N (input) INTEGER */
  62. /* The order of the matrix A. N >= 0. */
  63. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  64. /* On entry, the symmetric matrix A. If UPLO = 'U', the leading */
  65. /* N-by-N upper triangular part of A contains the upper */
  66. /* triangular part of the matrix A, and the strictly lower */
  67. /* triangular part of A is not referenced. If UPLO = 'L', the */
  68. /* leading N-by-N lower triangular part of A contains the lower */
  69. /* triangular part of the matrix A, and the strictly upper */
  70. /* triangular part of A is not referenced. */
  71. /* On exit, if INFO = 0, the factor U or L from the Cholesky */
  72. /* factorization A = U**T*U or A = L*L**T. */
  73. /* LDA (input) INTEGER */
  74. /* The leading dimension of the array A. LDA >= max(1,N). */
  75. /* INFO (output) INTEGER */
  76. /* = 0: successful exit */
  77. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  78. /* > 0: if INFO = i, the leading minor of order i is not */
  79. /* positive definite, and the factorization could not be */
  80. /* completed. */
  81. /* ===================================================================== */
  82. /* .. Parameters .. */
  83. /* .. */
  84. /* .. Local Scalars .. */
  85. /* .. */
  86. /* .. External Functions .. */
  87. /* .. */
  88. /* .. External Subroutines .. */
  89. /* .. */
  90. /* .. Intrinsic Functions .. */
  91. /* .. */
  92. /* .. Executable Statements .. */
  93. /* Test the input parameters. */
  94. /* Parameter adjustments */
  95. a_dim1 = *lda;
  96. a_offset = 1 + a_dim1;
  97. a -= a_offset;
  98. /* Function Body */
  99. *info = 0;
  100. upper = _starpu_lsame_(uplo, "U");
  101. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  102. *info = -1;
  103. } else if (*n < 0) {
  104. *info = -2;
  105. } else if (*lda < max(1,*n)) {
  106. *info = -4;
  107. }
  108. if (*info != 0) {
  109. i__1 = -(*info);
  110. _starpu_xerbla_("DPOTRF", &i__1);
  111. return 0;
  112. }
  113. /* Quick return if possible */
  114. if (*n == 0) {
  115. return 0;
  116. }
  117. /* Determine the block size for this environment. */
  118. nb = _starpu_ilaenv_(&c__1, "DPOTRF", uplo, n, &c_n1, &c_n1, &c_n1);
  119. if (nb <= 1 || nb >= *n) {
  120. /* Use unblocked code. */
  121. _starpu_dpotf2_(uplo, n, &a[a_offset], lda, info);
  122. } else {
  123. /* Use blocked code. */
  124. if (upper) {
  125. /* Compute the Cholesky factorization A = U'*U. */
  126. i__1 = *n;
  127. i__2 = nb;
  128. for (j = 1; i__2 < 0 ? j >= i__1 : j <= i__1; j += i__2) {
  129. /* Update and factorize the current diagonal block and test */
  130. /* for non-positive-definiteness. */
  131. /* Computing MIN */
  132. i__3 = nb, i__4 = *n - j + 1;
  133. jb = min(i__3,i__4);
  134. i__3 = j - 1;
  135. _starpu_dsyrk_("Upper", "Transpose", &jb, &i__3, &c_b13, &a[j *
  136. a_dim1 + 1], lda, &c_b14, &a[j + j * a_dim1], lda);
  137. _starpu_dpotf2_("Upper", &jb, &a[j + j * a_dim1], lda, info);
  138. if (*info != 0) {
  139. goto L30;
  140. }
  141. if (j + jb <= *n) {
  142. /* Compute the current block row. */
  143. i__3 = *n - j - jb + 1;
  144. i__4 = j - 1;
  145. _starpu_dgemm_("Transpose", "No transpose", &jb, &i__3, &i__4, &
  146. c_b13, &a[j * a_dim1 + 1], lda, &a[(j + jb) *
  147. a_dim1 + 1], lda, &c_b14, &a[j + (j + jb) *
  148. a_dim1], lda);
  149. i__3 = *n - j - jb + 1;
  150. _starpu_dtrsm_("Left", "Upper", "Transpose", "Non-unit", &jb, &
  151. i__3, &c_b14, &a[j + j * a_dim1], lda, &a[j + (j
  152. + jb) * a_dim1], lda);
  153. }
  154. /* L10: */
  155. }
  156. } else {
  157. /* Compute the Cholesky factorization A = L*L'. */
  158. i__2 = *n;
  159. i__1 = nb;
  160. for (j = 1; i__1 < 0 ? j >= i__2 : j <= i__2; j += i__1) {
  161. /* Update and factorize the current diagonal block and test */
  162. /* for non-positive-definiteness. */
  163. /* Computing MIN */
  164. i__3 = nb, i__4 = *n - j + 1;
  165. jb = min(i__3,i__4);
  166. i__3 = j - 1;
  167. _starpu_dsyrk_("Lower", "No transpose", &jb, &i__3, &c_b13, &a[j +
  168. a_dim1], lda, &c_b14, &a[j + j * a_dim1], lda);
  169. _starpu_dpotf2_("Lower", &jb, &a[j + j * a_dim1], lda, info);
  170. if (*info != 0) {
  171. goto L30;
  172. }
  173. if (j + jb <= *n) {
  174. /* Compute the current block column. */
  175. i__3 = *n - j - jb + 1;
  176. i__4 = j - 1;
  177. _starpu_dgemm_("No transpose", "Transpose", &i__3, &jb, &i__4, &
  178. c_b13, &a[j + jb + a_dim1], lda, &a[j + a_dim1],
  179. lda, &c_b14, &a[j + jb + j * a_dim1], lda);
  180. i__3 = *n - j - jb + 1;
  181. _starpu_dtrsm_("Right", "Lower", "Transpose", "Non-unit", &i__3, &
  182. jb, &c_b14, &a[j + j * a_dim1], lda, &a[j + jb +
  183. j * a_dim1], lda);
  184. }
  185. /* L20: */
  186. }
  187. }
  188. }
  189. goto L40;
  190. L30:
  191. *info = *info + j - 1;
  192. L40:
  193. return 0;
  194. /* End of DPOTRF */
  195. } /* _starpu_dpotrf_ */