dtrti2.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /* dtrti2.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_dtrti2_(char *uplo, char *diag, integer *n, doublereal *
  16. a, integer *lda, integer *info)
  17. {
  18. /* System generated locals */
  19. integer a_dim1, a_offset, i__1, i__2;
  20. /* Local variables */
  21. integer j;
  22. doublereal ajj;
  23. extern /* Subroutine */ int _starpu_dscal_(integer *, doublereal *, doublereal *,
  24. integer *);
  25. extern logical _starpu_lsame_(char *, char *);
  26. logical upper;
  27. extern /* Subroutine */ int _starpu_dtrmv_(char *, char *, char *, integer *,
  28. doublereal *, integer *, doublereal *, integer *), _starpu_xerbla_(char *, integer *);
  29. logical nounit;
  30. /* -- LAPACK routine (version 3.2) -- */
  31. /* Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. */
  32. /* November 2006 */
  33. /* .. Scalar Arguments .. */
  34. /* .. */
  35. /* .. Array Arguments .. */
  36. /* .. */
  37. /* Purpose */
  38. /* ======= */
  39. /* DTRTI2 computes the inverse of a real upper or lower triangular */
  40. /* matrix. */
  41. /* This is the Level 2 BLAS version of the algorithm. */
  42. /* Arguments */
  43. /* ========= */
  44. /* UPLO (input) CHARACTER*1 */
  45. /* Specifies whether the matrix A is upper or lower triangular. */
  46. /* = 'U': Upper triangular */
  47. /* = 'L': Lower triangular */
  48. /* DIAG (input) CHARACTER*1 */
  49. /* Specifies whether or not the matrix A is unit triangular. */
  50. /* = 'N': Non-unit triangular */
  51. /* = 'U': Unit triangular */
  52. /* N (input) INTEGER */
  53. /* The order of the matrix A. N >= 0. */
  54. /* A (input/output) DOUBLE PRECISION array, dimension (LDA,N) */
  55. /* On entry, the triangular matrix A. If UPLO = 'U', the */
  56. /* leading n by n upper triangular part of the array A contains */
  57. /* the upper triangular matrix, and the strictly lower */
  58. /* triangular part of A is not referenced. If UPLO = 'L', the */
  59. /* leading n by n lower triangular part of the array A contains */
  60. /* the lower triangular matrix, and the strictly upper */
  61. /* triangular part of A is not referenced. If DIAG = 'U', the */
  62. /* diagonal elements of A are also not referenced and are */
  63. /* assumed to be 1. */
  64. /* On exit, the (triangular) inverse of the original matrix, in */
  65. /* the same storage format. */
  66. /* LDA (input) INTEGER */
  67. /* The leading dimension of the array A. LDA >= max(1,N). */
  68. /* INFO (output) INTEGER */
  69. /* = 0: successful exit */
  70. /* < 0: if INFO = -k, the k-th argument had an illegal value */
  71. /* ===================================================================== */
  72. /* .. Parameters .. */
  73. /* .. */
  74. /* .. Local Scalars .. */
  75. /* .. */
  76. /* .. External Functions .. */
  77. /* .. */
  78. /* .. External Subroutines .. */
  79. /* .. */
  80. /* .. Intrinsic Functions .. */
  81. /* .. */
  82. /* .. Executable Statements .. */
  83. /* Test the input parameters. */
  84. /* Parameter adjustments */
  85. a_dim1 = *lda;
  86. a_offset = 1 + a_dim1;
  87. a -= a_offset;
  88. /* Function Body */
  89. *info = 0;
  90. upper = _starpu_lsame_(uplo, "U");
  91. nounit = _starpu_lsame_(diag, "N");
  92. if (! upper && ! _starpu_lsame_(uplo, "L")) {
  93. *info = -1;
  94. } else if (! nounit && ! _starpu_lsame_(diag, "U")) {
  95. *info = -2;
  96. } else if (*n < 0) {
  97. *info = -3;
  98. } else if (*lda < max(1,*n)) {
  99. *info = -5;
  100. }
  101. if (*info != 0) {
  102. i__1 = -(*info);
  103. _starpu_xerbla_("DTRTI2", &i__1);
  104. return 0;
  105. }
  106. if (upper) {
  107. /* Compute inverse of upper triangular matrix. */
  108. i__1 = *n;
  109. for (j = 1; j <= i__1; ++j) {
  110. if (nounit) {
  111. a[j + j * a_dim1] = 1. / a[j + j * a_dim1];
  112. ajj = -a[j + j * a_dim1];
  113. } else {
  114. ajj = -1.;
  115. }
  116. /* Compute elements 1:j-1 of j-th column. */
  117. i__2 = j - 1;
  118. _starpu_dtrmv_("Upper", "No transpose", diag, &i__2, &a[a_offset], lda, &
  119. a[j * a_dim1 + 1], &c__1);
  120. i__2 = j - 1;
  121. _starpu_dscal_(&i__2, &ajj, &a[j * a_dim1 + 1], &c__1);
  122. /* L10: */
  123. }
  124. } else {
  125. /* Compute inverse of lower triangular matrix. */
  126. for (j = *n; j >= 1; --j) {
  127. if (nounit) {
  128. a[j + j * a_dim1] = 1. / a[j + j * a_dim1];
  129. ajj = -a[j + j * a_dim1];
  130. } else {
  131. ajj = -1.;
  132. }
  133. if (j < *n) {
  134. /* Compute elements j+1:n of j-th column. */
  135. i__1 = *n - j;
  136. _starpu_dtrmv_("Lower", "No transpose", diag, &i__1, &a[j + 1 + (j +
  137. 1) * a_dim1], lda, &a[j + 1 + j * a_dim1], &c__1);
  138. i__1 = *n - j;
  139. _starpu_dscal_(&i__1, &ajj, &a[j + 1 + j * a_dim1], &c__1);
  140. }
  141. /* L20: */
  142. }
  143. }
  144. return 0;
  145. /* End of DTRTI2 */
  146. } /* _starpu_dtrti2_ */