dpbtrs.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. /* dpbtrs.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_dpbtrs_(char *uplo, integer *n, integer *kd, integer *
  16. nrhs, doublereal *ab, integer *ldab, doublereal *b, integer *ldb,
  17. 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. /* -- LAPACK routine (version 3.2) -- */
  29. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  30. /* November 2006 */
  31. /* .. Scalar Arguments .. */
  32. /* .. */
  33. /* .. Array Arguments .. */
  34. /* .. */
  35. /* Purpose */
  36. /* ======= */
  37. /* DPBTRS solves a system of linear equations A*X = B with a symmetric */
  38. /* positive definite band matrix A using the Cholesky factorization */
  39. /* A = U**T*U or A = L*L**T computed by DPBTRF. */
  40. /* Arguments */
  41. /* ========= */
  42. /* UPLO (input) CHARACTER*1 */
  43. /* = 'U': Upper triangular factor stored in AB; */
  44. /* = 'L': Lower triangular factor stored in AB. */
  45. /* N (input) INTEGER */
  46. /* The order of the matrix A. N >= 0. */
  47. /* KD (input) INTEGER */
  48. /* The number of superdiagonals of the matrix A if UPLO = 'U', */
  49. /* or the number of subdiagonals if UPLO = 'L'. KD >= 0. */
  50. /* NRHS (input) INTEGER */
  51. /* The number of right hand sides, i.e., the number of columns */
  52. /* of the matrix B. NRHS >= 0. */
  53. /* AB (input) DOUBLE PRECISION array, dimension (LDAB,N) */
  54. /* The triangular factor U or L from the Cholesky factorization */
  55. /* A = U**T*U or A = L*L**T of the band matrix A, stored in the */
  56. /* first KD+1 rows of the array. The j-th column of U or L is */
  57. /* stored in the j-th column of the array AB as follows: */
  58. /* if UPLO ='U', AB(kd+1+i-j,j) = U(i,j) for max(1,j-kd)<=i<=j; */
  59. /* if UPLO ='L', AB(1+i-j,j) = L(i,j) for j<=i<=min(n,j+kd). */
  60. /* LDAB (input) INTEGER */
  61. /* The leading dimension of the array AB. LDAB >= KD+1. */
  62. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  63. /* On entry, the right hand side matrix B. */
  64. /* On exit, the solution matrix X. */
  65. /* LDB (input) INTEGER */
  66. /* The leading dimension of the array B. LDB >= max(1,N). */
  67. /* INFO (output) INTEGER */
  68. /* = 0: successful exit */
  69. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  70. /* ===================================================================== */
  71. /* .. Local Scalars .. */
  72. /* .. */
  73. /* .. External Functions .. */
  74. /* .. */
  75. /* .. External Subroutines .. */
  76. /* .. */
  77. /* .. Intrinsic Functions .. */
  78. /* .. */
  79. /* .. Executable Statements .. */
  80. /* Test the input parameters. */
  81. /* Parameter adjustments */
  82. ab_dim1 = *ldab;
  83. ab_offset = 1 + ab_dim1;
  84. ab -= ab_offset;
  85. b_dim1 = *ldb;
  86. b_offset = 1 + b_dim1;
  87. b -= b_offset;
  88. /* Function Body */
  89. *info = 0;
  90. upper = _starpu_lsame_(uplo, "U");
  91. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  92. *info = -1;
  93. } else if (*n < 0) {
  94. *info = -2;
  95. } else if (*kd < 0) {
  96. *info = -3;
  97. } else if (*nrhs < 0) {
  98. *info = -4;
  99. } else if (*ldab < *kd + 1) {
  100. *info = -6;
  101. } else if (*ldb < max(1,*n)) {
  102. *info = -8;
  103. }
  104. if (*info != 0) {
  105. i__1 = -(*info);
  106. _starpu_xerbla_("DPBTRS", &i__1);
  107. return 0;
  108. }
  109. /* Quick return if possible */
  110. if (*n == 0 || *nrhs == 0) {
  111. return 0;
  112. }
  113. if (upper) {
  114. /* Solve A*X = B where A = U'*U. */
  115. i__1 = *nrhs;
  116. for (j = 1; j <= i__1; ++j) {
  117. /* Solve U'*X = B, overwriting B with X. */
  118. _starpu_dtbsv_("Upper", "Transpose", "Non-unit", n, kd, &ab[ab_offset],
  119. ldab, &b[j * b_dim1 + 1], &c__1);
  120. /* Solve U*X = B, overwriting B with X. */
  121. _starpu_dtbsv_("Upper", "No transpose", "Non-unit", n, kd, &ab[ab_offset],
  122. ldab, &b[j * b_dim1 + 1], &c__1);
  123. /* L10: */
  124. }
  125. } else {
  126. /* Solve A*X = B where A = L*L'. */
  127. i__1 = *nrhs;
  128. for (j = 1; j <= i__1; ++j) {
  129. /* Solve L*X = B, overwriting B with X. */
  130. _starpu_dtbsv_("Lower", "No transpose", "Non-unit", n, kd, &ab[ab_offset],
  131. ldab, &b[j * b_dim1 + 1], &c__1);
  132. /* Solve L'*X = B, overwriting B with X. */
  133. _starpu_dtbsv_("Lower", "Transpose", "Non-unit", n, kd, &ab[ab_offset],
  134. ldab, &b[j * b_dim1 + 1], &c__1);
  135. /* L20: */
  136. }
  137. }
  138. return 0;
  139. /* End of DPBTRS */
  140. } /* _starpu_dpbtrs_ */