dgbsv.c 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /* dgbsv.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_dgbsv_(integer *n, integer *kl, integer *ku, integer *
  14. nrhs, doublereal *ab, integer *ldab, integer *ipiv, doublereal *b,
  15. integer *ldb, integer *info)
  16. {
  17. /* System generated locals */
  18. integer ab_dim1, ab_offset, b_dim1, b_offset, i__1;
  19. /* Local variables */
  20. extern /* Subroutine */ int _starpu_dgbtrf_(integer *, integer *, integer *,
  21. integer *, doublereal *, integer *, integer *, integer *),
  22. _starpu_xerbla_(char *, integer *), _starpu_dgbtrs_(char *, integer *,
  23. integer *, integer *, integer *, doublereal *, integer *, integer
  24. *, doublereal *, integer *, integer *);
  25. /* -- LAPACK driver routine (version 3.2) -- */
  26. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  27. /* November 2006 */
  28. /* .. Scalar Arguments .. */
  29. /* .. */
  30. /* .. Array Arguments .. */
  31. /* .. */
  32. /* Purpose */
  33. /* ======= */
  34. /* DGBSV computes the solution to a real system of linear equations */
  35. /* A * X = B, where A is a band matrix of order N with KL subdiagonals */
  36. /* and KU superdiagonals, and X and B are N-by-NRHS matrices. */
  37. /* The LU decomposition with partial pivoting and row interchanges is */
  38. /* used to factor A as A = L * U, where L is a product of permutation */
  39. /* and unit lower triangular matrices with KL subdiagonals, and U is */
  40. /* upper triangular with KL+KU superdiagonals. The factored form of A */
  41. /* is then used to solve the system of equations A * X = B. */
  42. /* Arguments */
  43. /* ========= */
  44. /* N (input) INTEGER */
  45. /* The number of linear equations, i.e., the order of the */
  46. /* matrix A. N >= 0. */
  47. /* KL (input) INTEGER */
  48. /* The number of subdiagonals within the band of A. KL >= 0. */
  49. /* KU (input) INTEGER */
  50. /* The number of superdiagonals within the band of A. KU >= 0. */
  51. /* NRHS (input) INTEGER */
  52. /* The number of right hand sides, i.e., the number of columns */
  53. /* of the matrix B. NRHS >= 0. */
  54. /* AB (input/output) DOUBLE PRECISION array, dimension (LDAB,N) */
  55. /* On entry, the matrix A in band storage, in rows KL+1 to */
  56. /* 2*KL+KU+1; rows 1 to KL of the array need not be set. */
  57. /* The j-th column of A is stored in the j-th column of the */
  58. /* array AB as follows: */
  59. /* AB(KL+KU+1+i-j,j) = A(i,j) for max(1,j-KU)<=i<=min(N,j+KL) */
  60. /* On exit, details of the factorization: U is stored as an */
  61. /* upper triangular band matrix with KL+KU superdiagonals in */
  62. /* rows 1 to KL+KU+1, and the multipliers used during the */
  63. /* factorization are stored in rows KL+KU+2 to 2*KL+KU+1. */
  64. /* See below for further details. */
  65. /* LDAB (input) INTEGER */
  66. /* The leading dimension of the array AB. LDAB >= 2*KL+KU+1. */
  67. /* IPIV (output) INTEGER array, dimension (N) */
  68. /* The pivot indices that define the permutation matrix P; */
  69. /* row i of the matrix was interchanged with row IPIV(i). */
  70. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  71. /* On entry, the N-by-NRHS right hand side matrix B. */
  72. /* On exit, if INFO = 0, the N-by-NRHS solution matrix X. */
  73. /* LDB (input) INTEGER */
  74. /* The leading dimension of the array B. LDB >= 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, U(i,i) is exactly zero. The factorization */
  79. /* has been completed, but the factor U is exactly */
  80. /* singular, and the solution has not been computed. */
  81. /* Further Details */
  82. /* =============== */
  83. /* The band storage scheme is illustrated by the following example, when */
  84. /* M = N = 6, KL = 2, KU = 1: */
  85. /* On entry: On exit: */
  86. /* * * * + + + * * * u14 u25 u36 */
  87. /* * * + + + + * * u13 u24 u35 u46 */
  88. /* * a12 a23 a34 a45 a56 * u12 u23 u34 u45 u56 */
  89. /* a11 a22 a33 a44 a55 a66 u11 u22 u33 u44 u55 u66 */
  90. /* a21 a32 a43 a54 a65 * m21 m32 m43 m54 m65 * */
  91. /* a31 a42 a53 a64 * * m31 m42 m53 m64 * * */
  92. /* Array elements marked * are not used by the routine; elements marked */
  93. /* + need not be set on entry, but are required by the routine to store */
  94. /* elements of U because of fill-in resulting from the row interchanges. */
  95. /* ===================================================================== */
  96. /* .. External Subroutines .. */
  97. /* .. */
  98. /* .. Intrinsic Functions .. */
  99. /* .. */
  100. /* .. Executable Statements .. */
  101. /* Test the input parameters. */
  102. /* Parameter adjustments */
  103. ab_dim1 = *ldab;
  104. ab_offset = 1 + ab_dim1;
  105. ab -= ab_offset;
  106. --ipiv;
  107. b_dim1 = *ldb;
  108. b_offset = 1 + b_dim1;
  109. b -= b_offset;
  110. /* Function Body */
  111. *info = 0;
  112. if (*n < 0) {
  113. *info = -1;
  114. } else if (*kl < 0) {
  115. *info = -2;
  116. } else if (*ku < 0) {
  117. *info = -3;
  118. } else if (*nrhs < 0) {
  119. *info = -4;
  120. } else if (*ldab < (*kl << 1) + *ku + 1) {
  121. *info = -6;
  122. } else if (*ldb < max(*n,1)) {
  123. *info = -9;
  124. }
  125. if (*info != 0) {
  126. i__1 = -(*info);
  127. _starpu_xerbla_("DGBSV ", &i__1);
  128. return 0;
  129. }
  130. /* Compute the LU factorization of the band matrix A. */
  131. _starpu_dgbtrf_(n, n, kl, ku, &ab[ab_offset], ldab, &ipiv[1], info);
  132. if (*info == 0) {
  133. /* Solve the system A*X = B, overwriting B with X. */
  134. _starpu_dgbtrs_("No transpose", n, kl, ku, nrhs, &ab[ab_offset], ldab, &ipiv[
  135. 1], &b[b_offset], ldb, info);
  136. }
  137. return 0;
  138. /* End of DGBSV */
  139. } /* _starpu_dgbsv_ */