5785
|
1 SUBROUTINE ZTRCON( NORM, UPLO, DIAG, N, A, LDA, RCOND, WORK, |
|
2 $ RWORK, INFO ) |
|
3 * |
7034
|
4 * -- LAPACK routine (version 3.1) -- |
|
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd.. |
|
6 * November 2006 |
|
7 * |
|
8 * Modified to call ZLACN2 in place of ZLACON, 10 Feb 03, SJH. |
5785
|
9 * |
|
10 * .. Scalar Arguments .. |
|
11 CHARACTER DIAG, NORM, UPLO |
|
12 INTEGER INFO, LDA, N |
|
13 DOUBLE PRECISION RCOND |
|
14 * .. |
|
15 * .. Array Arguments .. |
|
16 DOUBLE PRECISION RWORK( * ) |
|
17 COMPLEX*16 A( LDA, * ), WORK( * ) |
|
18 * .. |
|
19 * |
|
20 * Purpose |
|
21 * ======= |
|
22 * |
|
23 * ZTRCON estimates the reciprocal of the condition number of a |
|
24 * triangular matrix A, in either the 1-norm or the infinity-norm. |
|
25 * |
|
26 * The norm of A is computed and an estimate is obtained for |
|
27 * norm(inv(A)), then the reciprocal of the condition number is |
|
28 * computed as |
|
29 * RCOND = 1 / ( norm(A) * norm(inv(A)) ). |
|
30 * |
|
31 * Arguments |
|
32 * ========= |
|
33 * |
|
34 * NORM (input) CHARACTER*1 |
|
35 * Specifies whether the 1-norm condition number or the |
|
36 * infinity-norm condition number is required: |
|
37 * = '1' or 'O': 1-norm; |
|
38 * = 'I': Infinity-norm. |
|
39 * |
|
40 * UPLO (input) CHARACTER*1 |
|
41 * = 'U': A is upper triangular; |
|
42 * = 'L': A is lower triangular. |
|
43 * |
|
44 * DIAG (input) CHARACTER*1 |
|
45 * = 'N': A is non-unit triangular; |
|
46 * = 'U': A is unit triangular. |
|
47 * |
|
48 * N (input) INTEGER |
|
49 * The order of the matrix A. N >= 0. |
|
50 * |
|
51 * A (input) COMPLEX*16 array, dimension (LDA,N) |
|
52 * The triangular matrix A. If UPLO = 'U', the leading N-by-N |
|
53 * upper triangular part of the array A contains the upper |
|
54 * triangular matrix, and the strictly lower triangular part of |
|
55 * A is not referenced. If UPLO = 'L', the leading N-by-N lower |
|
56 * triangular part of the array A contains the lower triangular |
|
57 * matrix, and the strictly upper triangular part of A is not |
|
58 * referenced. If DIAG = 'U', the diagonal elements of A are |
|
59 * also not referenced and are assumed to be 1. |
|
60 * |
|
61 * LDA (input) INTEGER |
|
62 * The leading dimension of the array A. LDA >= max(1,N). |
|
63 * |
|
64 * RCOND (output) DOUBLE PRECISION |
|
65 * The reciprocal of the condition number of the matrix A, |
|
66 * computed as RCOND = 1/(norm(A) * norm(inv(A))). |
|
67 * |
|
68 * WORK (workspace) COMPLEX*16 array, dimension (2*N) |
|
69 * |
|
70 * RWORK (workspace) DOUBLE PRECISION array, dimension (N) |
|
71 * |
|
72 * INFO (output) INTEGER |
|
73 * = 0: successful exit |
|
74 * < 0: if INFO = -i, the i-th argument had an illegal value |
|
75 * |
|
76 * ===================================================================== |
|
77 * |
|
78 * .. Parameters .. |
|
79 DOUBLE PRECISION ONE, ZERO |
|
80 PARAMETER ( ONE = 1.0D+0, ZERO = 0.0D+0 ) |
|
81 * .. |
|
82 * .. Local Scalars .. |
|
83 LOGICAL NOUNIT, ONENRM, UPPER |
|
84 CHARACTER NORMIN |
|
85 INTEGER IX, KASE, KASE1 |
|
86 DOUBLE PRECISION AINVNM, ANORM, SCALE, SMLNUM, XNORM |
|
87 COMPLEX*16 ZDUM |
|
88 * .. |
7034
|
89 * .. Local Arrays .. |
|
90 INTEGER ISAVE( 3 ) |
|
91 * .. |
5785
|
92 * .. External Functions .. |
|
93 LOGICAL LSAME |
|
94 INTEGER IZAMAX |
|
95 DOUBLE PRECISION DLAMCH, ZLANTR |
|
96 EXTERNAL LSAME, IZAMAX, DLAMCH, ZLANTR |
|
97 * .. |
|
98 * .. External Subroutines .. |
7034
|
99 EXTERNAL XERBLA, ZDRSCL, ZLACN2, ZLATRS |
5785
|
100 * .. |
|
101 * .. Intrinsic Functions .. |
|
102 INTRINSIC ABS, DBLE, DIMAG, MAX |
|
103 * .. |
|
104 * .. Statement Functions .. |
|
105 DOUBLE PRECISION CABS1 |
|
106 * .. |
|
107 * .. Statement Function definitions .. |
|
108 CABS1( ZDUM ) = ABS( DBLE( ZDUM ) ) + ABS( DIMAG( ZDUM ) ) |
|
109 * .. |
|
110 * .. Executable Statements .. |
|
111 * |
|
112 * Test the input parameters. |
|
113 * |
|
114 INFO = 0 |
|
115 UPPER = LSAME( UPLO, 'U' ) |
|
116 ONENRM = NORM.EQ.'1' .OR. LSAME( NORM, 'O' ) |
|
117 NOUNIT = LSAME( DIAG, 'N' ) |
|
118 * |
|
119 IF( .NOT.ONENRM .AND. .NOT.LSAME( NORM, 'I' ) ) THEN |
|
120 INFO = -1 |
|
121 ELSE IF( .NOT.UPPER .AND. .NOT.LSAME( UPLO, 'L' ) ) THEN |
|
122 INFO = -2 |
|
123 ELSE IF( .NOT.NOUNIT .AND. .NOT.LSAME( DIAG, 'U' ) ) THEN |
|
124 INFO = -3 |
|
125 ELSE IF( N.LT.0 ) THEN |
|
126 INFO = -4 |
|
127 ELSE IF( LDA.LT.MAX( 1, N ) ) THEN |
|
128 INFO = -6 |
|
129 END IF |
|
130 IF( INFO.NE.0 ) THEN |
|
131 CALL XERBLA( 'ZTRCON', -INFO ) |
|
132 RETURN |
|
133 END IF |
|
134 * |
|
135 * Quick return if possible |
|
136 * |
|
137 IF( N.EQ.0 ) THEN |
|
138 RCOND = ONE |
|
139 RETURN |
|
140 END IF |
|
141 * |
|
142 RCOND = ZERO |
|
143 SMLNUM = DLAMCH( 'Safe minimum' )*DBLE( MAX( 1, N ) ) |
|
144 * |
|
145 * Compute the norm of the triangular matrix A. |
|
146 * |
|
147 ANORM = ZLANTR( NORM, UPLO, DIAG, N, N, A, LDA, RWORK ) |
|
148 * |
|
149 * Continue only if ANORM > 0. |
|
150 * |
|
151 IF( ANORM.GT.ZERO ) THEN |
|
152 * |
|
153 * Estimate the norm of the inverse of A. |
|
154 * |
|
155 AINVNM = ZERO |
|
156 NORMIN = 'N' |
|
157 IF( ONENRM ) THEN |
|
158 KASE1 = 1 |
|
159 ELSE |
|
160 KASE1 = 2 |
|
161 END IF |
|
162 KASE = 0 |
|
163 10 CONTINUE |
7034
|
164 CALL ZLACN2( N, WORK( N+1 ), WORK, AINVNM, KASE, ISAVE ) |
5785
|
165 IF( KASE.NE.0 ) THEN |
|
166 IF( KASE.EQ.KASE1 ) THEN |
|
167 * |
|
168 * Multiply by inv(A). |
|
169 * |
|
170 CALL ZLATRS( UPLO, 'No transpose', DIAG, NORMIN, N, A, |
|
171 $ LDA, WORK, SCALE, RWORK, INFO ) |
|
172 ELSE |
|
173 * |
|
174 * Multiply by inv(A'). |
|
175 * |
|
176 CALL ZLATRS( UPLO, 'Conjugate transpose', DIAG, NORMIN, |
|
177 $ N, A, LDA, WORK, SCALE, RWORK, INFO ) |
|
178 END IF |
|
179 NORMIN = 'Y' |
|
180 * |
|
181 * Multiply by 1/SCALE if doing so will not cause overflow. |
|
182 * |
|
183 IF( SCALE.NE.ONE ) THEN |
|
184 IX = IZAMAX( N, WORK, 1 ) |
|
185 XNORM = CABS1( WORK( IX ) ) |
|
186 IF( SCALE.LT.XNORM*SMLNUM .OR. SCALE.EQ.ZERO ) |
|
187 $ GO TO 20 |
|
188 CALL ZDRSCL( N, SCALE, WORK, 1 ) |
|
189 END IF |
|
190 GO TO 10 |
|
191 END IF |
|
192 * |
|
193 * Compute the estimate of the reciprocal condition number. |
|
194 * |
|
195 IF( AINVNM.NE.ZERO ) |
|
196 $ RCOND = ( ONE / ANORM ) / AINVNM |
|
197 END IF |
|
198 * |
|
199 20 CONTINUE |
|
200 RETURN |
|
201 * |
|
202 * End of ZTRCON |
|
203 * |
|
204 END |