dtrtrs.c 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* dtrtrs.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 doublereal c_b12 = 1.;
  15. /* Subroutine */ int _starpu_dtrtrs_(char *uplo, char *trans, char *diag, integer *n,
  16. integer *nrhs, doublereal *a, integer *lda, doublereal *b, integer *
  17. ldb, integer *info)
  18. {
  19. /* System generated locals */
  20. integer a_dim1, a_offset, b_dim1, b_offset, i__1;
  21. /* Local variables */
  22. extern logical _starpu_lsame_(char *, char *);
  23. extern /* Subroutine */ int _starpu_dtrsm_(char *, char *, char *, char *,
  24. integer *, integer *, doublereal *, doublereal *, integer *,
  25. doublereal *, integer *), _starpu_xerbla_(
  26. char *, integer *);
  27. logical nounit;
  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. /* DTRTRS solves a triangular system of the form */
  38. /* A * X = B or A**T * X = B, */
  39. /* where A is a triangular matrix of order N, and B is an N-by-NRHS */
  40. /* matrix. A check is made to verify that A is nonsingular. */
  41. /* Arguments */
  42. /* ========= */
  43. /* UPLO (input) CHARACTER*1 */
  44. /* = 'U': A is upper triangular; */
  45. /* = 'L': A is lower triangular. */
  46. /* TRANS (input) CHARACTER*1 */
  47. /* Specifies the form of the system of equations: */
  48. /* = 'N': A * X = B (No transpose) */
  49. /* = 'T': A**T * X = B (Transpose) */
  50. /* = 'C': A**H * X = B (Conjugate transpose = Transpose) */
  51. /* DIAG (input) CHARACTER*1 */
  52. /* = 'N': A is non-unit triangular; */
  53. /* = 'U': A is unit triangular. */
  54. /* N (input) INTEGER */
  55. /* The order of the matrix A. N >= 0. */
  56. /* NRHS (input) INTEGER */
  57. /* The number of right hand sides, i.e., the number of columns */
  58. /* of the matrix B. NRHS >= 0. */
  59. /* A (input) DOUBLE PRECISION array, dimension (LDA,N) */
  60. /* The triangular matrix A. If UPLO = 'U', the leading N-by-N */
  61. /* upper triangular part of the array A contains the upper */
  62. /* triangular matrix, and the strictly lower triangular part of */
  63. /* A is not referenced. If UPLO = 'L', the leading N-by-N lower */
  64. /* triangular part of the array A contains the lower triangular */
  65. /* matrix, and the strictly upper triangular part of A is not */
  66. /* referenced. If DIAG = 'U', the diagonal elements of A are */
  67. /* also not referenced and are assumed to be 1. */
  68. /* LDA (input) INTEGER */
  69. /* The leading dimension of the array A. LDA >= max(1,N). */
  70. /* B (input/output) DOUBLE PRECISION array, dimension (LDB,NRHS) */
  71. /* On entry, the right hand side matrix B. */
  72. /* On exit, if INFO = 0, the 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, the i-th diagonal element of A is zero, */
  79. /* indicating that the matrix is singular and the solutions */
  80. /* X have not been computed. */
  81. /* ===================================================================== */
  82. /* .. Parameters .. */
  83. /* .. */
  84. /* .. Local Scalars .. */
  85. /* .. */
  86. /* .. External Functions .. */
  87. /* .. */
  88. /* .. External Subroutines .. */
  89. /* .. */
  90. /* .. Intrinsic Functions .. */
  91. /* .. */
  92. /* .. Executable Statements .. */
  93. /* Test the input parameters. */
  94. /* Parameter adjustments */
  95. a_dim1 = *lda;
  96. a_offset = 1 + a_dim1;
  97. a -= a_offset;
  98. b_dim1 = *ldb;
  99. b_offset = 1 + b_dim1;
  100. b -= b_offset;
  101. /* Function Body */
  102. *info = 0;
  103. nounit = _starpu_lsame_(diag, "N");
  104. if (! _starpu_lsame_(uplo, "U") && ! _starpu_lsame_(uplo, "L")) {
  105. *info = -1;
  106. } else if (! _starpu_lsame_(trans, "N") && ! _starpu_lsame_(trans,
  107. "T") && ! _starpu_lsame_(trans, "C")) {
  108. *info = -2;
  109. } else if (! nounit && ! _starpu_lsame_(diag, "U")) {
  110. *info = -3;
  111. } else if (*n < 0) {
  112. *info = -4;
  113. } else if (*nrhs < 0) {
  114. *info = -5;
  115. } else if (*lda < max(1,*n)) {
  116. *info = -7;
  117. } else if (*ldb < max(1,*n)) {
  118. *info = -9;
  119. }
  120. if (*info != 0) {
  121. i__1 = -(*info);
  122. _starpu_xerbla_("DTRTRS", &i__1);
  123. return 0;
  124. }
  125. /* Quick return if possible */
  126. if (*n == 0) {
  127. return 0;
  128. }
  129. /* Check for singularity. */
  130. if (nounit) {
  131. i__1 = *n;
  132. for (*info = 1; *info <= i__1; ++(*info)) {
  133. if (a[*info + *info * a_dim1] == 0.) {
  134. return 0;
  135. }
  136. /* L10: */
  137. }
  138. }
  139. *info = 0;
  140. /* Solve A * x = b or A' * x = b. */
  141. _starpu_dtrsm_("Left", uplo, trans, diag, n, nrhs, &c_b12, &a[a_offset], lda, &b[
  142. b_offset], ldb);
  143. return 0;
  144. /* End of DTRTRS */
  145. } /* _starpu_dtrtrs_ */