dpttrf.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /* dpttrf.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. /* Subroutine */ int _starpu_dpttrf_(integer *n, doublereal *d__, doublereal *e,
  14. integer *info)
  15. {
  16. /* System generated locals */
  17. integer i__1;
  18. /* Local variables */
  19. integer i__, i4;
  20. doublereal ei;
  21. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  22. /* -- LAPACK routine (version 3.2) -- */
  23. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  24. /* November 2006 */
  25. /* .. Scalar Arguments .. */
  26. /* .. */
  27. /* .. Array Arguments .. */
  28. /* .. */
  29. /* Purpose */
  30. /* ======= */
  31. /* DPTTRF computes the L*D*L' factorization of a real symmetric */
  32. /* positive definite tridiagonal matrix A. The factorization may also */
  33. /* be regarded as having the form A = U'*D*U. */
  34. /* Arguments */
  35. /* ========= */
  36. /* N (input) INTEGER */
  37. /* The order of the matrix A. N >= 0. */
  38. /* D (input/output) DOUBLE PRECISION array, dimension (N) */
  39. /* On entry, the n diagonal elements of the tridiagonal matrix */
  40. /* A. On exit, the n diagonal elements of the diagonal matrix */
  41. /* D from the L*D*L' factorization of A. */
  42. /* E (input/output) DOUBLE PRECISION array, dimension (N-1) */
  43. /* On entry, the (n-1) subdiagonal elements of the tridiagonal */
  44. /* matrix A. On exit, the (n-1) subdiagonal elements of the */
  45. /* unit bidiagonal factor L from the L*D*L' factorization of A. */
  46. /* E can also be regarded as the superdiagonal of the unit */
  47. /* bidiagonal factor U from the U'*D*U factorization of A. */
  48. /* INFO (output) INTEGER */
  49. /* = 0: successful exit */
  50. /* < 0: if INFO = -k, the k-th argument had an illegal value */
  51. /* > 0: if INFO = k, the leading minor of order k is not */
  52. /* positive definite; if k < N, the factorization could not */
  53. /* be completed, while if k = N, the factorization was */
  54. /* completed, but D(N) <= 0. */
  55. /* ===================================================================== */
  56. /* .. Parameters .. */
  57. /* .. */
  58. /* .. Local Scalars .. */
  59. /* .. */
  60. /* .. External Subroutines .. */
  61. /* .. */
  62. /* .. Intrinsic Functions .. */
  63. /* .. */
  64. /* .. Executable Statements .. */
  65. /* Test the input parameters. */
  66. /* Parameter adjustments */
  67. --e;
  68. --d__;
  69. /* Function Body */
  70. *info = 0;
  71. if (*n < 0) {
  72. *info = -1;
  73. i__1 = -(*info);
  74. _starpu_xerbla_("DPTTRF", &i__1);
  75. return 0;
  76. }
  77. /* Quick return if possible */
  78. if (*n == 0) {
  79. return 0;
  80. }
  81. /* Compute the L*D*L' (or U'*D*U) factorization of A. */
  82. i4 = (*n - 1) % 4;
  83. i__1 = i4;
  84. for (i__ = 1; i__ <= i__1; ++i__) {
  85. if (d__[i__] <= 0.) {
  86. *info = i__;
  87. goto L30;
  88. }
  89. ei = e[i__];
  90. e[i__] = ei / d__[i__];
  91. d__[i__ + 1] -= e[i__] * ei;
  92. /* L10: */
  93. }
  94. i__1 = *n - 4;
  95. for (i__ = i4 + 1; i__ <= i__1; i__ += 4) {
  96. /* Drop out of the loop if d(i) <= 0: the matrix is not positive */
  97. /* definite. */
  98. if (d__[i__] <= 0.) {
  99. *info = i__;
  100. goto L30;
  101. }
  102. /* Solve for e(i) and d(i+1). */
  103. ei = e[i__];
  104. e[i__] = ei / d__[i__];
  105. d__[i__ + 1] -= e[i__] * ei;
  106. if (d__[i__ + 1] <= 0.) {
  107. *info = i__ + 1;
  108. goto L30;
  109. }
  110. /* Solve for e(i+1) and d(i+2). */
  111. ei = e[i__ + 1];
  112. e[i__ + 1] = ei / d__[i__ + 1];
  113. d__[i__ + 2] -= e[i__ + 1] * ei;
  114. if (d__[i__ + 2] <= 0.) {
  115. *info = i__ + 2;
  116. goto L30;
  117. }
  118. /* Solve for e(i+2) and d(i+3). */
  119. ei = e[i__ + 2];
  120. e[i__ + 2] = ei / d__[i__ + 2];
  121. d__[i__ + 3] -= e[i__ + 2] * ei;
  122. if (d__[i__ + 3] <= 0.) {
  123. *info = i__ + 3;
  124. goto L30;
  125. }
  126. /* Solve for e(i+3) and d(i+4). */
  127. ei = e[i__ + 3];
  128. e[i__ + 3] = ei / d__[i__ + 3];
  129. d__[i__ + 4] -= e[i__ + 3] * ei;
  130. /* L20: */
  131. }
  132. /* Check d(n) for positive definiteness. */
  133. if (d__[*n] <= 0.) {
  134. *info = *n;
  135. }
  136. L30:
  137. return 0;
  138. /* End of DPTTRF */
  139. } /* _starpu_dpttrf_ */