dptts2.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /* dptts2.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_dptts2_(integer *n, integer *nrhs, doublereal *d__,
  14. doublereal *e, doublereal *b, integer *ldb)
  15. {
  16. /* System generated locals */
  17. integer b_dim1, b_offset, i__1, i__2;
  18. doublereal d__1;
  19. /* Local variables */
  20. integer i__, j;
  21. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  22. integer *);
  23. /* -- LAPACK routine (version 3.2) -- */
  24. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  25. /* November 2006 */
  26. /* .. Scalar Arguments .. */
  27. /* .. */
  28. /* .. Array Arguments .. */
  29. /* .. */
  30. /* Purpose */
  31. /* ======= */
  32. /* DPTTS2 solves a tridiagonal system of the form */
  33. /* A * X = B */
  34. /* using the L*D*L' factorization of A computed by DPTTRF. D is a */
  35. /* diagonal matrix specified in the vector D, L is a unit bidiagonal */
  36. /* matrix whose subdiagonal is specified in the vector E, and X and B */
  37. /* are N by NRHS matrices. */
  38. /* Arguments */
  39. /* ========= */
  40. /* N (input) INTEGER */
  41. /* The order of the tridiagonal matrix A. N >= 0. */
  42. /* NRHS (input) INTEGER */
  43. /* The number of right hand sides, i.e., the number of columns */
  44. /* of the matrix B. NRHS >= 0. */
  45. /* D (input) DOUBLE PRECISION array, dimension (N) */
  46. /* The n diagonal elements of the diagonal matrix D from the */
  47. /* L*D*L' factorization of A. */
  48. /* E (input) DOUBLE PRECISION array, dimension (N-1) */
  49. /* The (n-1) subdiagonal elements of the unit bidiagonal factor */
  50. /* L from the L*D*L' factorization of A. E can also be regarded */
  51. /* as the superdiagonal of the unit bidiagonal factor U from the */
  52. /* factorization A = U'*D*U. */
  53. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  54. /* On entry, the right hand side vectors B for the system of */
  55. /* linear equations. */
  56. /* On exit, the solution vectors, X. */
  57. /* LDB (input) INTEGER */
  58. /* The leading dimension of the array B. LDB >= max(1,N). */
  59. /* ===================================================================== */
  60. /* .. Local Scalars .. */
  61. /* .. */
  62. /* .. External Subroutines .. */
  63. /* .. */
  64. /* .. Executable Statements .. */
  65. /* Quick return if possible */
  66. /* Parameter adjustments */
  67. --d__;
  68. --e;
  69. b_dim1 = *ldb;
  70. b_offset = 1 + b_dim1;
  71. b -= b_offset;
  72. /* Function Body */
  73. if (*n <= 1) {
  74. if (*n == 1) {
  75. d__1 = 1. / d__[1];
  76. _starpu_dscal_(nrhs, &d__1, &b[b_offset], ldb);
  77. }
  78. return 0;
  79. }
  80. /* Solve A * X = B using the factorization A = L*D*L', */
  81. /* overwriting each right hand side vector with its solution. */
  82. i__1 = *nrhs;
  83. for (j = 1; j <= i__1; ++j) {
  84. /* Solve L * x = b. */
  85. i__2 = *n;
  86. for (i__ = 2; i__ <= i__2; ++i__) {
  87. b[i__ + j * b_dim1] -= b[i__ - 1 + j * b_dim1] * e[i__ - 1];
  88. /* L10: */
  89. }
  90. /* Solve D * L' * x = b. */
  91. b[*n + j * b_dim1] /= d__[*n];
  92. for (i__ = *n - 1; i__ >= 1; --i__) {
  93. b[i__ + j * b_dim1] = b[i__ + j * b_dim1] / d__[i__] - b[i__ + 1
  94. + j * b_dim1] * e[i__];
  95. /* L20: */
  96. }
  97. /* L30: */
  98. }
  99. return 0;
  100. /* End of DPTTS2 */
  101. } /* _starpu_dptts2_ */