125
126
127
128
129
130
131 CHARACTER DIAG, NORM, UPLO
132 INTEGER N
133
134
135 DOUBLE PRECISION WORK( * )
136 COMPLEX*16 AP( * )
137
138
139
140
141
142 DOUBLE PRECISION ONE, ZERO
143 parameter( one = 1.0d+0, zero = 0.0d+0 )
144
145
146 LOGICAL UDIAG
147 INTEGER I, J, K
148 DOUBLE PRECISION SCALE, SUM, VALUE
149
150
151 LOGICAL LSAME, DISNAN
153
154
156
157
158 INTRINSIC abs, sqrt
159
160
161
162 IF( n.EQ.0 ) THEN
163 VALUE = zero
164 ELSE IF(
lsame( norm,
'M' ) )
THEN
165
166
167
168 k = 1
169 IF(
lsame( diag,
'U' ) )
THEN
170 VALUE = one
171 IF(
lsame( uplo,
'U' ) )
THEN
172 DO 20 j = 1, n
173 DO 10 i = k, k + j - 2
174 sum = abs( ap( i ) )
175 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
176 10 CONTINUE
177 k = k + j
178 20 CONTINUE
179 ELSE
180 DO 40 j = 1, n
181 DO 30 i = k + 1, k + n - j
182 sum = abs( ap( i ) )
183 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
184 30 CONTINUE
185 k = k + n - j + 1
186 40 CONTINUE
187 END IF
188 ELSE
189 VALUE = zero
190 IF(
lsame( uplo,
'U' ) )
THEN
191 DO 60 j = 1, n
192 DO 50 i = k, k + j - 1
193 sum = abs( ap( i ) )
194 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
195 50 CONTINUE
196 k = k + j
197 60 CONTINUE
198 ELSE
199 DO 80 j = 1, n
200 DO 70 i = k, k + n - j
201 sum = abs( ap( i ) )
202 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
203 70 CONTINUE
204 k = k + n - j + 1
205 80 CONTINUE
206 END IF
207 END IF
208 ELSE IF( (
lsame( norm,
'O' ) ) .OR. ( norm.EQ.
'1' ) )
THEN
209
210
211
212 VALUE = zero
213 k = 1
214 udiag =
lsame( diag,
'U' )
215 IF(
lsame( uplo,
'U' ) )
THEN
216 DO 110 j = 1, n
217 IF( udiag ) THEN
218 sum = one
219 DO 90 i = k, k + j - 2
220 sum = sum + abs( ap( i ) )
221 90 CONTINUE
222 ELSE
223 sum = zero
224 DO 100 i = k, k + j - 1
225 sum = sum + abs( ap( i ) )
226 100 CONTINUE
227 END IF
228 k = k + j
229 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
230 110 CONTINUE
231 ELSE
232 DO 140 j = 1, n
233 IF( udiag ) THEN
234 sum = one
235 DO 120 i = k + 1, k + n - j
236 sum = sum + abs( ap( i ) )
237 120 CONTINUE
238 ELSE
239 sum = zero
240 DO 130 i = k, k + n - j
241 sum = sum + abs( ap( i ) )
242 130 CONTINUE
243 END IF
244 k = k + n - j + 1
245 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
246 140 CONTINUE
247 END IF
248 ELSE IF(
lsame( norm,
'I' ) )
THEN
249
250
251
252 k = 1
253 IF(
lsame( uplo,
'U' ) )
THEN
254 IF(
lsame( diag,
'U' ) )
THEN
255 DO 150 i = 1, n
256 work( i ) = one
257 150 CONTINUE
258 DO 170 j = 1, n
259 DO 160 i = 1, j - 1
260 work( i ) = work( i ) + abs( ap( k ) )
261 k = k + 1
262 160 CONTINUE
263 k = k + 1
264 170 CONTINUE
265 ELSE
266 DO 180 i = 1, n
267 work( i ) = zero
268 180 CONTINUE
269 DO 200 j = 1, n
270 DO 190 i = 1, j
271 work( i ) = work( i ) + abs( ap( k ) )
272 k = k + 1
273 190 CONTINUE
274 200 CONTINUE
275 END IF
276 ELSE
277 IF(
lsame( diag,
'U' ) )
THEN
278 DO 210 i = 1, n
279 work( i ) = one
280 210 CONTINUE
281 DO 230 j = 1, n
282 k = k + 1
283 DO 220 i = j + 1, n
284 work( i ) = work( i ) + abs( ap( k ) )
285 k = k + 1
286 220 CONTINUE
287 230 CONTINUE
288 ELSE
289 DO 240 i = 1, n
290 work( i ) = zero
291 240 CONTINUE
292 DO 260 j = 1, n
293 DO 250 i = j, n
294 work( i ) = work( i ) + abs( ap( k ) )
295 k = k + 1
296 250 CONTINUE
297 260 CONTINUE
298 END IF
299 END IF
300 VALUE = zero
301 DO 270 i = 1, n
302 sum = work( i )
303 IF(
VALUE .LT. sum .OR.
disnan( sum ) )
VALUE = sum
304 270 CONTINUE
305 ELSE IF( (
lsame( norm,
'F' ) ) .OR. (
lsame( norm,
'E' ) ) )
THEN
306
307
308
309 IF(
lsame( uplo,
'U' ) )
THEN
310 IF(
lsame( diag,
'U' ) )
THEN
311 scale = one
312 sum = n
313 k = 2
314 DO 280 j = 2, n
315 CALL zlassq( j-1, ap( k ), 1, scale, sum )
316 k = k + j
317 280 CONTINUE
318 ELSE
319 scale = zero
320 sum = one
321 k = 1
322 DO 290 j = 1, n
323 CALL zlassq( j, ap( k ), 1, scale, sum )
324 k = k + j
325 290 CONTINUE
326 END IF
327 ELSE
328 IF(
lsame( diag,
'U' ) )
THEN
329 scale = one
330 sum = n
331 k = 2
332 DO 300 j = 1, n - 1
333 CALL zlassq( n-j, ap( k ), 1, scale, sum )
334 k = k + n - j + 1
335 300 CONTINUE
336 ELSE
337 scale = zero
338 sum = one
339 k = 1
340 DO 310 j = 1, n
341 CALL zlassq( n-j+1, ap( k ), 1, scale, sum )
342 k = k + n - j + 1
343 310 CONTINUE
344 END IF
345 END IF
346 VALUE = scale*sqrt( sum )
347 END IF
348
350 RETURN
351
352
353
logical function disnan(din)
DISNAN tests input for NaN.
double precision function zlantp(norm, uplo, diag, n, ap, work)
ZLANTP returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
subroutine zlassq(n, x, incx, scale, sumsq)
ZLASSQ updates a sum of squares represented in scaled form.
logical function lsame(ca, cb)
LSAME