110
111
112
113
114
115
116 CHARACTER UPLO
117 INTEGER LDW, N
118 REAL RCOND, RESID
119
120
121 REAL RWORK( * )
122 COMPLEX A( * ), AINV( * ), WORK( LDW, * )
123
124
125
126
127
128 REAL ZERO, ONE
129 parameter( zero = 0.0e+0, one = 1.0e+0 )
130
131
132 INTEGER I, ICOL, J, JCOL, K, KCOL, NALL
133 REAL AINVNM, ANORM, EPS
134 COMPLEX T
135
136
137 LOGICAL LSAME
138 REAL CLANGE, CLANSP, SLAMCH
139 COMPLEX CDOTU
141
142
143 INTRINSIC real
144
145
146
147
148
149 IF( n.LE.0 ) THEN
150 rcond = one
151 resid = zero
152 RETURN
153 END IF
154
155
156
158 anorm =
clansp(
'1', uplo, n, a, rwork )
159 ainvnm =
clansp(
'1', uplo, n, ainv, rwork )
160 IF( anorm.LE.zero .OR. ainvnm.LE.zero ) THEN
161 rcond = zero
162 resid = one / eps
163 RETURN
164 END IF
165 rcond = ( one/anorm ) / ainvnm
166
167
168
169
170
171 IF(
lsame( uplo,
'U' ) )
THEN
172 DO 70 i = 1, n
173 icol = ( ( i-1 )*i ) / 2 + 1
174
175
176
177 DO 30 j = 1, i
178 jcol = ( ( j-1 )*j ) / 2 + 1
179 t =
cdotu( j, a( icol ), 1, ainv( jcol ), 1 )
180 jcol = jcol + 2*j - 1
181 kcol = icol - 1
182 DO 10 k = j + 1, i
183 t = t + a( kcol+k )*ainv( jcol )
184 jcol = jcol + k
185 10 CONTINUE
186 kcol = kcol + 2*i
187 DO 20 k = i + 1, n
188 t = t + a( kcol )*ainv( jcol )
189 kcol = kcol + k
190 jcol = jcol + k
191 20 CONTINUE
192 work( i, j ) = -t
193 30 CONTINUE
194
195
196
197 DO 60 j = i + 1, n
198 jcol = ( ( j-1 )*j ) / 2 + 1
199 t =
cdotu( i, a( icol ), 1, ainv( jcol ), 1 )
200 jcol = jcol - 1
201 kcol = icol + 2*i - 1
202 DO 40 k = i + 1, j
203 t = t + a( kcol )*ainv( jcol+k )
204 kcol = kcol + k
205 40 CONTINUE
206 jcol = jcol + 2*j
207 DO 50 k = j + 1, n
208 t = t + a( kcol )*ainv( jcol )
209 kcol = kcol + k
210 jcol = jcol + k
211 50 CONTINUE
212 work( i, j ) = -t
213 60 CONTINUE
214 70 CONTINUE
215 ELSE
216
217
218
219 nall = ( n*( n+1 ) ) / 2
220 DO 140 i = 1, n
221
222
223
224 icol = nall - ( ( n-i+1 )*( n-i+2 ) ) / 2 + 1
225 DO 100 j = 1, i
226 jcol = nall - ( ( n-j )*( n-j+1 ) ) / 2 - ( n-i )
227 t =
cdotu( n-i+1, a( icol ), 1, ainv( jcol ), 1 )
228 kcol = i
229 jcol = j
230 DO 80 k = 1, j - 1
231 t = t + a( kcol )*ainv( jcol )
232 jcol = jcol + n - k
233 kcol = kcol + n - k
234 80 CONTINUE
235 jcol = jcol - j
236 DO 90 k = j, i - 1
237 t = t + a( kcol )*ainv( jcol+k )
238 kcol = kcol + n - k
239 90 CONTINUE
240 work( i, j ) = -t
241 100 CONTINUE
242
243
244
245 icol = nall - ( ( n-i )*( n-i+1 ) ) / 2
246 DO 130 j = i + 1, n
247 jcol = nall - ( ( n-j+1 )*( n-j+2 ) ) / 2 + 1
248 t =
cdotu( n-j+1, a( icol-n+j ), 1, ainv( jcol ), 1 )
249 kcol = i
250 jcol = j
251 DO 110 k = 1, i - 1
252 t = t + a( kcol )*ainv( jcol )
253 jcol = jcol + n - k
254 kcol = kcol + n - k
255 110 CONTINUE
256 kcol = kcol - i
257 DO 120 k = i, j - 1
258 t = t + a( kcol+k )*ainv( jcol )
259 jcol = jcol + n - k
260 120 CONTINUE
261 work( i, j ) = -t
262 130 CONTINUE
263 140 CONTINUE
264 END IF
265
266
267
268 DO 150 i = 1, n
269 work( i, i ) = work( i, i ) + one
270 150 CONTINUE
271
272
273
274 resid =
clange(
'1', n, n, work, ldw, rwork )
275
276 resid = ( ( resid*rcond )/eps ) / real( n )
277
278 RETURN
279
280
281
complex function cdotu(n, cx, incx, cy, incy)
CDOTU
real function slamch(cmach)
SLAMCH
real function clange(norm, m, n, a, lda, work)
CLANGE returns the value of the 1-norm, Frobenius norm, infinity-norm, or the largest absolute value ...
real function clansp(norm, uplo, n, ap, work)
CLANSP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
logical function lsame(ca, cb)
LSAME