You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

strtrif.f 5.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. SUBROUTINE STRTRIF( UPLO, DIAG, N, A, LDA, INFO )
  2. *
  3. * -- LAPACK routine (version 3.0) --
  4. * Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  5. * Courant Institute, Argonne National Lab, and Rice University
  6. * March 31, 1993
  7. *
  8. * .. Scalar Arguments ..
  9. CHARACTER DIAG, UPLO
  10. INTEGER INFO, LDA, N
  11. * ..
  12. * .. Array Arguments ..
  13. REAL A( LDA, * )
  14. * ..
  15. *
  16. * Purpose
  17. * =======
  18. *
  19. * STRTRI computes the inverse of a real upper or lower triangular
  20. * matrix A.
  21. *
  22. * This is the Level 3 BLAS version of the algorithm.
  23. *
  24. * Arguments
  25. * =========
  26. *
  27. * UPLO (input) CHARACTER*1
  28. * = 'U': A is upper triangular;
  29. * = 'L': A is lower triangular.
  30. *
  31. * DIAG (input) CHARACTER*1
  32. * = 'N': A is non-unit triangular;
  33. * = 'U': A is unit triangular.
  34. *
  35. * N (input) INTEGER
  36. * The order of the matrix A. N >= 0.
  37. *
  38. * A (input/output) REAL array, dimension (LDA,N)
  39. * On entry, the triangular matrix A. If UPLO = 'U', the
  40. * leading N-by-N upper triangular part of the array A contains
  41. * the upper triangular matrix, and the strictly lower
  42. * triangular part of A is not referenced. If UPLO = 'L', the
  43. * leading N-by-N lower triangular part of the array A contains
  44. * the lower triangular matrix, and the strictly upper
  45. * triangular part of A is not referenced. If DIAG = 'U', the
  46. * diagonal elements of A are also not referenced and are
  47. * assumed to be 1.
  48. * On exit, the (triangular) inverse of the original matrix, in
  49. * the same storage format.
  50. *
  51. * LDA (input) INTEGER
  52. * The leading dimension of the array A. LDA >= max(1,N).
  53. *
  54. * INFO (output) INTEGER
  55. * = 0: successful exit
  56. * < 0: if INFO = -i, the i-th argument had an illegal value
  57. * > 0: if INFO = i, A(i,i) is exactly zero. The triangular
  58. * matrix is singular and its inverse can not be computed.
  59. *
  60. * =====================================================================
  61. *
  62. * .. Parameters ..
  63. REAL ONE, ZERO
  64. PARAMETER ( ONE = 1.0E+0, ZERO = 0.0E+0 )
  65. * ..
  66. * .. Local Scalars ..
  67. LOGICAL NOUNIT, UPPER
  68. INTEGER J, JB, NB, NN
  69. * ..
  70. * .. External Functions ..
  71. LOGICAL LSAME
  72. EXTERNAL LSAME
  73. * ..
  74. * .. External Subroutines ..
  75. EXTERNAL STRMM, STRSM, STRTI2, XERBLA
  76. * ..
  77. * .. Intrinsic Functions ..
  78. INTRINSIC MAX, MIN
  79. * ..
  80. * .. Executable Statements ..
  81. *
  82. * Test the input parameters.
  83. *
  84. INFO = 0
  85. UPPER = LSAME( UPLO, 'U' )
  86. NOUNIT = LSAME( DIAG, 'N' )
  87. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  88. INFO = -1
  89. ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
  90. INFO = -2
  91. ELSE IF( N.LT.0 ) THEN
  92. INFO = -3
  93. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  94. INFO = -5
  95. END IF
  96. IF( INFO.NE.0 ) THEN
  97. CALL XERBLA( 'STRTRI', -INFO )
  98. RETURN
  99. END IF
  100. *
  101. * Quick return if possible
  102. *
  103. IF( N.EQ.0 )
  104. $ RETURN
  105. *
  106. * Check for singularity if non-unit.
  107. *
  108. IF( NOUNIT ) THEN
  109. DO 10 INFO = 1, N
  110. IF( A( INFO, INFO ).EQ.ZERO )
  111. $ RETURN
  112. 10 CONTINUE
  113. INFO = 0
  114. END IF
  115. *
  116. * Determine the block size for this environment.
  117. *
  118. NB = 128
  119. IF( NB.LE.1 .OR. NB.GE.N ) THEN
  120. *
  121. * Use unblocked code
  122. *
  123. CALL STRTI2( UPLO, DIAG, N, A, LDA, INFO )
  124. ELSE
  125. *
  126. * Use blocked code
  127. *
  128. IF( UPPER ) THEN
  129. *
  130. * Compute inverse of upper triangular matrix
  131. *
  132. DO 20 J = 1, N, NB
  133. JB = MIN( NB, N-J+1 )
  134. *
  135. * Compute rows 1:j-1 of current block column
  136. *
  137. CALL STRMM( 'Left', 'Upper', 'No transpose', DIAG, J-1,
  138. $ JB, ONE, A, LDA, A( 1, J ), LDA )
  139. CALL STRSM( 'Right', 'Upper', 'No transpose', DIAG, J-1,
  140. $ JB, -ONE, A( J, J ), LDA, A( 1, J ), LDA )
  141. *
  142. * Compute inverse of current diagonal block
  143. *
  144. CALL STRTI2( 'Upper', DIAG, JB, A( J, J ), LDA, INFO )
  145. 20 CONTINUE
  146. ELSE
  147. *
  148. * Compute inverse of lower triangular matrix
  149. *
  150. NN = ( ( N-1 ) / NB )*NB + 1
  151. DO 30 J = NN, 1, -NB
  152. JB = MIN( NB, N-J+1 )
  153. IF( J+JB.LE.N ) THEN
  154. *
  155. * Compute rows j+jb:n of current block column
  156. *
  157. CALL STRMM( 'Left', 'Lower', 'No transpose', DIAG,
  158. $ N-J-JB+1, JB, ONE, A( J+JB, J+JB ), LDA,
  159. $ A( J+JB, J ), LDA )
  160. CALL STRSM( 'Right', 'Lower', 'No transpose', DIAG,
  161. $ N-J-JB+1, JB, -ONE, A( J, J ), LDA,
  162. $ A( J+JB, J ), LDA )
  163. END IF
  164. *
  165. * Compute inverse of current diagonal block
  166. *
  167. CALL STRTI2( 'Lower', DIAG, JB, A( J, J ), LDA, INFO )
  168. 30 CONTINUE
  169. END IF
  170. END IF
  171. *
  172. RETURN
  173. *
  174. * End of STRTRI
  175. *
  176. END