dgetrs.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /* dgetrs.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. static doublereal c_b12 = 1.;
  16. static integer c_n1 = -1;
  17. /* Subroutine */ int _starpu_dgetrs_(char *trans, integer *n, integer *nrhs,
  18. doublereal *a, integer *lda, integer *ipiv, doublereal *b, integer *
  19. ldb, integer *info)
  20. {
  21. /* System generated locals */
  22. integer a_dim1, a_offset, b_dim1, b_offset, i__1;
  23. /* Local variables */
  24. extern logical _starpu_lsame_(char *, char *);
  25. extern /* Subroutine */ int _starpu_dtrsm_(char *, char *, char *, char *,
  26. integer *, integer *, doublereal *, doublereal *, integer *,
  27. doublereal *, integer *), _starpu_xerbla_(
  28. char *, integer *), _starpu_dlaswp_(integer *, doublereal *,
  29. integer *, integer *, integer *, integer *, integer *);
  30. logical notran;
  31. /* -- LAPACK routine (version 3.2) -- */
  32. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  33. /* November 2006 */
  34. /* .. Scalar Arguments .. */
  35. /* .. */
  36. /* .. Array Arguments .. */
  37. /* .. */
  38. /* Purpose */
  39. /* ======= */
  40. /* DGETRS solves a system of linear equations */
  41. /* A * X = B or A' * X = B */
  42. /* with a general N-by-N matrix A using the LU factorization computed */
  43. /* by DGETRF. */
  44. /* Arguments */
  45. /* ========= */
  46. /* TRANS (input) CHARACTER*1 */
  47. /* Specifies the form of the system of equations: */
  48. /* = 'N': A * X = B (No transpose) */
  49. /* = 'T': A'* X = B (Transpose) */
  50. /* = 'C': A'* X = B (Conjugate transpose = Transpose) */
  51. /* N (input) INTEGER */
  52. /* The order of the matrix A. N >= 0. */
  53. /* NRHS (input) INTEGER */
  54. /* The number of right hand sides, i.e., the number of columns */
  55. /* of the matrix B. NRHS >= 0. */
  56. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  57. /* The factors L and U from the factorization A = P*L*U */
  58. /* as computed by DGETRF. */
  59. /* LDA (input) INTEGER */
  60. /* The leading dimension of the array A. LDA >= max(1,N). */
  61. /* IPIV (input) INTEGER array, dimension (N) */
  62. /* The pivot indices from DGETRF; for 1<=i<=N, row i of the */
  63. /* matrix was interchanged with row IPIV(i). */
  64. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  65. /* On entry, the right hand side matrix B. */
  66. /* On exit, the solution matrix X. */
  67. /* LDB (input) INTEGER */
  68. /* The leading dimension of the array B. LDB >= max(1,N). */
  69. /* INFO (output) INTEGER */
  70. /* = 0: successful exit */
  71. /* < 0: if INFO = -i, the i-th argument had an illegal value */
  72. /* ===================================================================== */
  73. /* .. Parameters .. */
  74. /* .. */
  75. /* .. Local Scalars .. */
  76. /* .. */
  77. /* .. External Functions .. */
  78. /* .. */
  79. /* .. External Subroutines .. */
  80. /* .. */
  81. /* .. Intrinsic Functions .. */
  82. /* .. */
  83. /* .. Executable Statements .. */
  84. /* Test the input parameters. */
  85. /* Parameter adjustments */
  86. a_dim1 = *lda;
  87. a_offset = 1 + a_dim1;
  88. a -= a_offset;
  89. --ipiv;
  90. b_dim1 = *ldb;
  91. b_offset = 1 + b_dim1;
  92. b -= b_offset;
  93. /* Function Body */
  94. *info = 0;
  95. notran = _starpu_lsame_(trans, "N");
  96. if (! notran && ! _starpu_lsame_(trans, "T") && ! _starpu_lsame_(
  97. trans, "C")) {
  98. *info = -1;
  99. } else if (*n < 0) {
  100. *info = -2;
  101. } else if (*nrhs < 0) {
  102. *info = -3;
  103. } else if (*lda < max(1,*n)) {
  104. *info = -5;
  105. } else if (*ldb < max(1,*n)) {
  106. *info = -8;
  107. }
  108. if (*info != 0) {
  109. i__1 = -(*info);
  110. _starpu_xerbla_("DGETRS", &i__1);
  111. return 0;
  112. }
  113. /* Quick return if possible */
  114. if (*n == 0 || *nrhs == 0) {
  115. return 0;
  116. }
  117. if (notran) {
  118. /* Solve A * X = B. */
  119. /* Apply row interchanges to the right hand sides. */
  120. _starpu_dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c__1);
  121. /* Solve L*X = B, overwriting B with X. */
  122. _starpu_dtrsm_("Left", "Lower", "No transpose", "Unit", n, nrhs, &c_b12, &a[
  123. a_offset], lda, &b[b_offset], ldb);
  124. /* Solve U*X = B, overwriting B with X. */
  125. _starpu_dtrsm_("Left", "Upper", "No transpose", "Non-unit", n, nrhs, &c_b12, &
  126. a[a_offset], lda, &b[b_offset], ldb);
  127. } else {
  128. /* Solve A' * X = B. */
  129. /* Solve U'*X = B, overwriting B with X. */
  130. _starpu_dtrsm_("Left", "Upper", "Transpose", "Non-unit", n, nrhs, &c_b12, &a[
  131. a_offset], lda, &b[b_offset], ldb);
  132. /* Solve L'*X = B, overwriting B with X. */
  133. _starpu_dtrsm_("Left", "Lower", "Transpose", "Unit", n, nrhs, &c_b12, &a[
  134. a_offset], lda, &b[b_offset], ldb);
  135. /* Apply row interchanges to the solution vectors. */
  136. _starpu_dlaswp_(nrhs, &b[b_offset], ldb, &c__1, n, &ipiv[1], &c_n1);
  137. }
  138. return 0;
  139. /* End of DGETRS */
  140. } /* _starpu_dgetrs_ */