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.

ctrtrif.f 5.3 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. SUBROUTINE CTRTRIF( 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. * September 30, 1994
  7. *
  8. * .. Scalar Arguments ..
  9. CHARACTER DIAG, UPLO
  10. INTEGER INFO, LDA, N
  11. * ..
  12. * .. Array Arguments ..
  13. COMPLEX A( LDA, * )
  14. * ..
  15. *
  16. * Purpose
  17. * =======
  18. *
  19. * CTRTRI computes the inverse of a complex 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) COMPLEX 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. COMPLEX ONE, ZERO
  64. PARAMETER ( ONE = ( 1.0E+0, 0.0E+0 ),
  65. $ ZERO = ( 0.0E+0, 0.0E+0 ) )
  66. * ..
  67. * .. Local Scalars ..
  68. LOGICAL NOUNIT, UPPER
  69. INTEGER J, JB, NB, NN
  70. * ..
  71. * .. External Functions ..
  72. LOGICAL LSAME
  73. EXTERNAL LSAME
  74. * ..
  75. * .. External Subroutines ..
  76. EXTERNAL CTRMM, CTRSM, CTRTI2, XERBLA
  77. * ..
  78. * .. Intrinsic Functions ..
  79. INTRINSIC MAX, MIN
  80. * ..
  81. * .. Executable Statements ..
  82. *
  83. * Test the input parameters.
  84. *
  85. INFO = 0
  86. UPPER = LSAME( UPLO, 'U' )
  87. NOUNIT = LSAME( DIAG, 'N' )
  88. IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN
  89. INFO = -1
  90. ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN
  91. INFO = -2
  92. ELSE IF( N.LT.0 ) THEN
  93. INFO = -3
  94. ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  95. INFO = -5
  96. END IF
  97. IF( INFO.NE.0 ) THEN
  98. CALL XERBLA( 'CTRTRI', -INFO )
  99. RETURN
  100. END IF
  101. *
  102. * Quick return if possible
  103. *
  104. IF( N.EQ.0 )
  105. $ RETURN
  106. *
  107. * Check for singularity if non-unit.
  108. *
  109. IF( NOUNIT ) THEN
  110. DO 10 INFO = 1, N
  111. IF( A( INFO, INFO ).EQ.ZERO )
  112. $ RETURN
  113. 10 CONTINUE
  114. INFO = 0
  115. END IF
  116. *
  117. * Determine the block size for this environment.
  118. *
  119. NB = 128
  120. IF( NB.LE.1 .OR. NB.GE.N ) THEN
  121. *
  122. * Use unblocked code
  123. *
  124. CALL CTRTI2( UPLO, DIAG, N, A, LDA, INFO )
  125. ELSE
  126. *
  127. * Use blocked code
  128. *
  129. IF( UPPER ) THEN
  130. *
  131. * Compute inverse of upper triangular matrix
  132. *
  133. DO 20 J = 1, N, NB
  134. JB = MIN( NB, N-J+1 )
  135. *
  136. * Compute rows 1:j-1 of current block column
  137. *
  138. CALL CTRMM( 'Left', 'Upper', 'No transpose', DIAG, J-1,
  139. $ JB, ONE, A, LDA, A( 1, J ), LDA )
  140. CALL CTRSM( 'Right', 'Upper', 'No transpose', DIAG, J-1,
  141. $ JB, -ONE, A( J, J ), LDA, A( 1, J ), LDA )
  142. *
  143. * Compute inverse of current diagonal block
  144. *
  145. CALL CTRTI2( 'Upper', DIAG, JB, A( J, J ), LDA, INFO )
  146. 20 CONTINUE
  147. ELSE
  148. *
  149. * Compute inverse of lower triangular matrix
  150. *
  151. NN = ( ( N-1 ) / NB )*NB + 1
  152. DO 30 J = NN, 1, -NB
  153. JB = MIN( NB, N-J+1 )
  154. IF( J+JB.LE.N ) THEN
  155. *
  156. * Compute rows j+jb:n of current block column
  157. *
  158. CALL CTRMM( 'Left', 'Lower', 'No transpose', DIAG,
  159. $ N-J-JB+1, JB, ONE, A( J+JB, J+JB ), LDA,
  160. $ A( J+JB, J ), LDA )
  161. CALL CTRSM( 'Right', 'Lower', 'No transpose', DIAG,
  162. $ N-J-JB+1, JB, -ONE, A( J, J ), LDA,
  163. $ A( J+JB, J ), LDA )
  164. END IF
  165. *
  166. * Compute inverse of current diagonal block
  167. *
  168. CALL CTRTI2( 'Lower', DIAG, JB, A( J, J ), LDA, INFO )
  169. 30 CONTINUE
  170. END IF
  171. END IF
  172. *
  173. RETURN
  174. *
  175. * End of CTRTRI
  176. *
  177. END