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