dtbtrs.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. /* dtbtrs.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. /* Subroutine */ int _starpu_dtbtrs_(char *uplo, char *trans, char *diag, integer *n,
  16. integer *kd, integer *nrhs, doublereal *ab, integer *ldab, doublereal
  17. *b, integer *ldb, integer *info)
  18. {
  19. /* System generated locals */
  20. integer ab_dim1, ab_offset, b_dim1, b_offset, i__1;
  21. /* Local variables */
  22. integer j;
  23. extern logical _starpu_lsame_(char *, char *);
  24. extern /* Subroutine */ int _starpu_dtbsv_(char *, char *, char *, integer *,
  25. integer *, doublereal *, integer *, doublereal *, integer *);
  26. logical upper;
  27. extern /* Subroutine */ int _starpu_xerbla_(char *, integer *);
  28. logical nounit;
  29. /* -- LAPACK routine (version 3.2) -- */
  30. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  31. /* November 2006 */
  32. /* .. Scalar Arguments .. */
  33. /* .. */
  34. /* .. Array Arguments .. */
  35. /* .. */
  36. /* Purpose */
  37. /* ======= */
  38. /* DTBTRS solves a triangular system of the form */
  39. /* A * X = B or A**T * X = B, */
  40. /* where A is a triangular band matrix of order N, and B is an */
  41. /* N-by NRHS matrix. A check is made to verify that A is nonsingular. */
  42. /* Arguments */
  43. /* ========= */
  44. /* UPLO (input) CHARACTER*1 */
  45. /* = 'U': A is upper triangular; */
  46. /* = 'L': A is lower triangular. */
  47. /* TRANS (input) CHARACTER*1 */
  48. /* Specifies the form the system of equations: */
  49. /* = 'N': A * X = B (No transpose) */
  50. /* = 'T': A**T * X = B (Transpose) */
  51. /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */
  52. /* DIAG (input) CHARACTER*1 */
  53. /* = 'N': A is non-unit triangular; */
  54. /* = 'U': A is unit triangular. */
  55. /* N (input) INTEGER */
  56. /* The order of the matrix A. N >= 0. */
  57. /* KD (input) INTEGER */
  58. /* The number of superdiagonals or subdiagonals of the */
  59. /* triangular band matrix A. KD >= 0. */
  60. /* NRHS (input) INTEGER */
  61. /* The number of right hand sides, i.e., the number of columns */
  62. /* of the matrix B. NRHS >= 0. */
  63. /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */
  64. /* The upper or lower triangular band matrix A, stored in the */
  65. /* first kd+1 rows of AB. The j-th column of A is stored */
  66. /* in the j-th column of the array AB as follows: */
  67. /* if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j; */
  68. /* if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd). */
  69. /* If DIAG = 'U', the diagonal elements of A are not referenced */
  70. /* and are assumed to be 1. */
  71. /* LDAB (input) INTEGER */
  72. /* The leading dimension of the array AB. LDAB >= KD+1. */
  73. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  74. /* On entry, the right hand side matrix B. */
  75. /* On exit, if INFO = 0, the solution matrix X. */
  76. /* LDB (input) INTEGER */
  77. /* The leading dimension of the array B. LDB >= max(1,N). */
  78. /* INFO (output) INTEGER */
  79. /* = 0: successful exit */
  80. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  81. /* > 0: if INFO = i, the i-th diagonal element of A is zero, */
  82. /* indicating that the matrix is singular and the */
  83. /* solutions X have not been computed. */
  84. /* ===================================================================== */
  85. /* .. Parameters .. */
  86. /* .. */
  87. /* .. Local Scalars .. */
  88. /* .. */
  89. /* .. External Functions .. */
  90. /* .. */
  91. /* .. External Subroutines .. */
  92. /* .. */
  93. /* .. Intrinsic Functions .. */
  94. /* .. */
  95. /* .. Executable Statements .. */
  96. /* Test the input parameters. */
  97. /* Parameter adjustments */
  98. ab_dim1 = *ldab;
  99. ab_offset = 1 + ab_dim1;
  100. ab -= ab_offset;
  101. b_dim1 = *ldb;
  102. b_offset = 1 + b_dim1;
  103. b -= b_offset;
  104. /* Function Body */
  105. *info = 0;
  106. nounit = _starpu_lsame_(diag, "N");
  107. upper = _starpu_lsame_(uplo, "U");
  108. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  109. *info = -1;
  110. } else if (! _starpu_lsame_(trans, "N") && ! _starpu_lsame_(trans,
  111. "T") && ! _starpu_lsame_(trans, "C")) {
  112. *info = -2;
  113. } else if (! nounit && ! _starpu_lsame_(diag, "U")) {
  114. *info = -3;
  115. } else if (*n < 0) {
  116. *info = -4;
  117. } else if (*kd < 0) {
  118. *info = -5;
  119. } else if (*nrhs < 0) {
  120. *info = -6;
  121. } else if (*ldab < *kd + 1) {
  122. *info = -8;
  123. } else if (*ldb < max(1,*n)) {
  124. *info = -10;
  125. }
  126. if (*info != 0) {
  127. i__1 = -(*info);
  128. _starpu_xerbla_("DTBTRS", &i__1);
  129. return 0;
  130. }
  131. /* Quick return if possible */
  132. if (*n == 0) {
  133. return 0;
  134. }
  135. /* Check for singularity. */
  136. if (nounit) {
  137. if (upper) {
  138. i__1 = *n;
  139. for (*info = 1; *info <= i__1; ++(*info)) {
  140. if (ab[*kd + 1 + *info * ab_dim1] == 0.) {
  141. return 0;
  142. }
  143. /* L10: */
  144. }
  145. } else {
  146. i__1 = *n;
  147. for (*info = 1; *info <= i__1; ++(*info)) {
  148. if (ab[*info * ab_dim1 + 1] == 0.) {
  149. return 0;
  150. }
  151. /* L20: */
  152. }
  153. }
  154. }
  155. *info = 0;
  156. /* Solve A * X = B or A' * X = B. */
  157. i__1 = *nrhs;
  158. for (j = 1; j <= i__1; ++j) {
  159. _starpu_dtbsv_(uplo, trans, diag, n, kd, &ab[ab_offset], ldab, &b[j * b_dim1
  160. + 1], &c__1);
  161. /* L30: */
  162. }
  163. return 0;
  164. /* End of DTBTRS */
  165. } /* _starpu_dtbtrs_ */