133
134
135
136
137
138
139 CHARACTER DIAG, TRANS, UPLO
140 INTEGER IMAT, INFO, LDA, N
141
142
143 INTEGER ISEED( 4 )
144 REAL A( LDA, * ), B( * ), WORK( * )
145
146
147
148
149
150 REAL ONE, TWO, ZERO
151 parameter( one = 1.0e+0, two = 2.0e+0, zero = 0.0e+0 )
152
153
154 LOGICAL UPPER
155 CHARACTER DIST, TYPE
156 CHARACTER*3 PATH
157 INTEGER I, IY, J, JCOUNT, KL, KU, MODE
158 REAL ANORM, BIGNUM, BNORM, BSCAL, C, CNDNUM, PLUS1,
159 $ PLUS2, RA, RB, REXP, S, SFAC, SMLNUM, STAR1,
160 $ TEXP, TLEFT, TSCAL, ULP, UNFL, X, Y, Z
161
162
163 LOGICAL LSAME
164 INTEGER ISAMAX
165 REAL SLAMCH, SLARND
167
168
171
172
173 INTRINSIC abs, max, real, sign, sqrt
174
175
176
177 path( 1: 1 ) = 'Single precision'
178 path( 2: 3 ) = 'TR'
179 unfl =
slamch(
'Safe minimum' )
181 smlnum = unfl
182 bignum = ( one-ulp ) / smlnum
183 IF( ( imat.GE.7 .AND. imat.LE.10 ) .OR. imat.EQ.18 ) THEN
184 diag = 'U'
185 ELSE
186 diag = 'N'
187 END IF
188 info = 0
189
190
191
192 IF( n.LE.0 )
193 $ RETURN
194
195
196
197 upper =
lsame( uplo,
'U' )
198 IF( upper ) THEN
199 CALL slatb4( path, imat, n, n,
TYPE, KL, KU, ANORM, MODE,
200 $ CNDNUM, DIST )
201 ELSE
202 CALL slatb4( path, -imat, n, n,
TYPE, KL, KU, ANORM, MODE,
203 $ CNDNUM, DIST )
204 END IF
205
206
207
208 IF( imat.LE.6 ) THEN
209 CALL slatms( n, n, dist, iseed,
TYPE, B, MODE, CNDNUM, ANORM,
210 $ KL, KU, 'No packing', A, LDA, WORK, INFO )
211
212
213
214
215
216
217 ELSE IF( imat.EQ.7 ) THEN
218 IF( upper ) THEN
219 DO 20 j = 1, n
220 DO 10 i = 1, j - 1
221 a( i, j ) = zero
222 10 CONTINUE
223 a( j, j ) = j
224 20 CONTINUE
225 ELSE
226 DO 40 j = 1, n
227 a( j, j ) = j
228 DO 30 i = j + 1, n
229 a( i, j ) = zero
230 30 CONTINUE
231 40 CONTINUE
232 END IF
233
234
235
236
237
238
239
240 ELSE IF( imat.LE.10 ) THEN
241 IF( upper ) THEN
242 DO 60 j = 1, n
243 DO 50 i = 1, j - 1
244 a( i, j ) = zero
245 50 CONTINUE
246 a( j, j ) = j
247 60 CONTINUE
248 ELSE
249 DO 80 j = 1, n
250 a( j, j ) = j
251 DO 70 i = j + 1, n
252 a( i, j ) = zero
253 70 CONTINUE
254 80 CONTINUE
255 END IF
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315 star1 = 0.25
316 sfac = 0.5
317 plus1 = sfac
318 DO 90 j = 1, n, 2
319 plus2 = star1 / plus1
320 work( j ) = plus1
321 work( n+j ) = star1
322 IF( j+1.LE.n ) THEN
323 work( j+1 ) = plus2
324 work( n+j+1 ) = zero
325 plus1 = star1 / plus2
327 star1 = star1*( sfac**rexp )
328 IF( rexp.LT.zero ) THEN
329 star1 = -sfac**( one-rexp )
330 ELSE
331 star1 = sfac**( one+rexp )
332 END IF
333 END IF
334 90 CONTINUE
335
336 x = sqrt( cndnum ) - 1 / sqrt( cndnum )
337 IF( n.GT.2 ) THEN
338 y = sqrt( 2. / ( n-2 ) )*x
339 ELSE
340 y = zero
341 END IF
342 z = x*x
343
344 IF( upper ) THEN
345 IF( n.GT.3 ) THEN
346 CALL scopy( n-3, work, 1, a( 2, 3 ), lda+1 )
347 IF( n.GT.4 )
348 $
CALL scopy( n-4, work( n+1 ), 1, a( 2, 4 ), lda+1 )
349 END IF
350 DO 100 j = 2, n - 1
351 a( 1, j ) = y
352 a( j, n ) = y
353 100 CONTINUE
354 a( 1, n ) = z
355 ELSE
356 IF( n.GT.3 ) THEN
357 CALL scopy( n-3, work, 1, a( 3, 2 ), lda+1 )
358 IF( n.GT.4 )
359 $
CALL scopy( n-4, work( n+1 ), 1, a( 4, 2 ), lda+1 )
360 END IF
361 DO 110 j = 2, n - 1
362 a( j, 1 ) = y
363 a( n, j ) = y
364 110 CONTINUE
365 a( n, 1 ) = z
366 END IF
367
368
369
370 IF( upper ) THEN
371 DO 120 j = 1, n - 1
372 ra = a( j, j+1 )
373 rb = 2.0
374 CALL srotg( ra, rb, c, s )
375
376
377
378 IF( n.GT.j+1 )
379 $
CALL srot( n-j-1, a( j, j+2 ), lda, a( j+1, j+2 ),
380 $ lda, c, s )
381
382
383
384 IF( j.GT.1 )
385 $
CALL srot( j-1, a( 1, j+1 ), 1, a( 1, j ), 1, -c, -s )
386
387
388
389 a( j, j+1 ) = -a( j, j+1 )
390 120 CONTINUE
391 ELSE
392 DO 130 j = 1, n - 1
393 ra = a( j+1, j )
394 rb = 2.0
395 CALL srotg( ra, rb, c, s )
396
397
398
399 IF( n.GT.j+1 )
400 $
CALL srot( n-j-1, a( j+2, j+1 ), 1, a( j+2, j ), 1, c,
401 $ -s )
402
403
404
405 IF( j.GT.1 )
406 $
CALL srot( j-1, a( j, 1 ), lda, a( j+1, 1 ), lda, -c,
407 $ s )
408
409
410
411 a( j+1, j ) = -a( j+1, j )
412 130 CONTINUE
413 END IF
414
415
416
417
418
419 ELSE IF( imat.EQ.11 ) THEN
420
421
422
423
424
425 IF( upper ) THEN
426 DO 140 j = 1, n
427 CALL slarnv( 2, iseed, j, a( 1, j ) )
428 a( j, j ) = sign( two, a( j, j ) )
429 140 CONTINUE
430 ELSE
431 DO 150 j = 1, n
432 CALL slarnv( 2, iseed, n-j+1, a( j, j ) )
433 a( j, j ) = sign( two, a( j, j ) )
434 150 CONTINUE
435 END IF
436
437
438
439 CALL slarnv( 2, iseed, n, b )
441 bnorm = abs( b( iy ) )
442 bscal = bignum / max( one, bnorm )
443 CALL sscal( n, bscal, b, 1 )
444
445 ELSE IF( imat.EQ.12 ) THEN
446
447
448
449
450
451 CALL slarnv( 2, iseed, n, b )
452 tscal = one / max( one, real( n-1 ) )
453 IF( upper ) THEN
454 DO 160 j = 1, n
455 CALL slarnv( 2, iseed, j, a( 1, j ) )
456 CALL sscal( j-1, tscal, a( 1, j ), 1 )
457 a( j, j ) = sign( one, a( j, j ) )
458 160 CONTINUE
459 a( n, n ) = smlnum*a( n, n )
460 ELSE
461 DO 170 j = 1, n
462 CALL slarnv( 2, iseed, n-j+1, a( j, j ) )
463 IF( n.GT.j )
464 $
CALL sscal( n-j, tscal, a( j+1, j ), 1 )
465 a( j, j ) = sign( one, a( j, j ) )
466 170 CONTINUE
467 a( 1, 1 ) = smlnum*a( 1, 1 )
468 END IF
469
470 ELSE IF( imat.EQ.13 ) THEN
471
472
473
474
475
476 CALL slarnv( 2, iseed, n, b )
477 IF( upper ) THEN
478 DO 180 j = 1, n
479 CALL slarnv( 2, iseed, j, a( 1, j ) )
480 a( j, j ) = sign( one, a( j, j ) )
481 180 CONTINUE
482 a( n, n ) = smlnum*a( n, n )
483 ELSE
484 DO 190 j = 1, n
485 CALL slarnv( 2, iseed, n-j+1, a( j, j ) )
486 a( j, j ) = sign( one, a( j, j ) )
487 190 CONTINUE
488 a( 1, 1 ) = smlnum*a( 1, 1 )
489 END IF
490
491 ELSE IF( imat.EQ.14 ) THEN
492
493
494
495
496
497 IF( upper ) THEN
498 jcount = 1
499 DO 210 j = n, 1, -1
500 DO 200 i = 1, j - 1
501 a( i, j ) = zero
502 200 CONTINUE
503 IF( jcount.LE.2 ) THEN
504 a( j, j ) = smlnum
505 ELSE
506 a( j, j ) = one
507 END IF
508 jcount = jcount + 1
509 IF( jcount.GT.4 )
510 $ jcount = 1
511 210 CONTINUE
512 ELSE
513 jcount = 1
514 DO 230 j = 1, n
515 DO 220 i = j + 1, n
516 a( i, j ) = zero
517 220 CONTINUE
518 IF( jcount.LE.2 ) THEN
519 a( j, j ) = smlnum
520 ELSE
521 a( j, j ) = one
522 END IF
523 jcount = jcount + 1
524 IF( jcount.GT.4 )
525 $ jcount = 1
526 230 CONTINUE
527 END IF
528
529
530
531 IF( upper ) THEN
532 b( 1 ) = zero
533 DO 240 i = n, 2, -2
534 b( i ) = zero
535 b( i-1 ) = smlnum
536 240 CONTINUE
537 ELSE
538 b( n ) = zero
539 DO 250 i = 1, n - 1, 2
540 b( i ) = zero
541 b( i+1 ) = smlnum
542 250 CONTINUE
543 END IF
544
545 ELSE IF( imat.EQ.15 ) THEN
546
547
548
549
550
551 texp = one / max( one, real( n-1 ) )
552 tscal = smlnum**texp
553 CALL slarnv( 2, iseed, n, b )
554 IF( upper ) THEN
555 DO 270 j = 1, n
556 DO 260 i = 1, j - 2
557 a( i, j ) = 0.
558 260 CONTINUE
559 IF( j.GT.1 )
560 $ a( j-1, j ) = -one
561 a( j, j ) = tscal
562 270 CONTINUE
563 b( n ) = one
564 ELSE
565 DO 290 j = 1, n
566 DO 280 i = j + 2, n
567 a( i, j ) = 0.
568 280 CONTINUE
569 IF( j.LT.n )
570 $ a( j+1, j ) = -one
571 a( j, j ) = tscal
572 290 CONTINUE
573 b( 1 ) = one
574 END IF
575
576 ELSE IF( imat.EQ.16 ) THEN
577
578
579
580 iy = n / 2 + 1
581 IF( upper ) THEN
582 DO 300 j = 1, n
583 CALL slarnv( 2, iseed, j, a( 1, j ) )
584 IF( j.NE.iy ) THEN
585 a( j, j ) = sign( two, a( j, j ) )
586 ELSE
587 a( j, j ) = zero
588 END IF
589 300 CONTINUE
590 ELSE
591 DO 310 j = 1, n
592 CALL slarnv( 2, iseed, n-j+1, a( j, j ) )
593 IF( j.NE.iy ) THEN
594 a( j, j ) = sign( two, a( j, j ) )
595 ELSE
596 a( j, j ) = zero
597 END IF
598 310 CONTINUE
599 END IF
600 CALL slarnv( 2, iseed, n, b )
601 CALL sscal( n, two, b, 1 )
602
603 ELSE IF( imat.EQ.17 ) THEN
604
605
606
607
608
609
610 tscal = unfl / ulp
611 tscal = ( one-ulp ) / tscal
612 DO 330 j = 1, n
613 DO 320 i = 1, n
614 a( i, j ) = 0.
615 320 CONTINUE
616 330 CONTINUE
617 texp = one
618 IF( upper ) THEN
619 DO 340 j = n, 2, -2
620 a( 1, j ) = -tscal / real( n+1 )
621 a( j, j ) = one
622 b( j ) = texp*( one-ulp )
623 a( 1, j-1 ) = -( tscal / real( n+1 ) ) / real( n+2 )
624 a( j-1, j-1 ) = one
625 b( j-1 ) = texp*real( n*n+n-1 )
626 texp = texp*2.
627 340 CONTINUE
628 b( 1 ) = ( real( n+1 ) / real( n+2 ) )*tscal
629 ELSE
630 DO 350 j = 1, n - 1, 2
631 a( n, j ) = -tscal / real( n+1 )
632 a( j, j ) = one
633 b( j ) = texp*( one-ulp )
634 a( n, j+1 ) = -( tscal / real( n+1 ) ) / real( n+2 )
635 a( j+1, j+1 ) = one
636 b( j+1 ) = texp*real( n*n+n-1 )
637 texp = texp*2.
638 350 CONTINUE
639 b( n ) = ( real( n+1 ) / real( n+2 ) )*tscal
640 END IF
641
642 ELSE IF( imat.EQ.18 ) THEN
643
644
645
646
647
648 IF( upper ) THEN
649 DO 360 j = 1, n
650 CALL slarnv( 2, iseed, j-1, a( 1, j ) )
651 a( j, j ) = zero
652 360 CONTINUE
653 ELSE
654 DO 370 j = 1, n
655 IF( j.LT.n )
656 $
CALL slarnv( 2, iseed, n-j, a( j+1, j ) )
657 a( j, j ) = zero
658 370 CONTINUE
659 END IF
660
661
662
663 CALL slarnv( 2, iseed, n, b )
665 bnorm = abs( b( iy ) )
666 bscal = bignum / max( one, bnorm )
667 CALL sscal( n, bscal, b, 1 )
668
669 ELSE IF( imat.EQ.19 ) THEN
670
671
672
673
674
675
676 tleft = bignum / max( one, real( n-1 ) )
677 tscal = bignum*( real( n-1 ) / max( one, real( n ) ) )
678 IF( upper ) THEN
679 DO 390 j = 1, n
680 CALL slarnv( 2, iseed, j, a( 1, j ) )
681 DO 380 i = 1, j
682 a( i, j ) = sign( tleft, a( i, j ) ) + tscal*a( i, j )
683 380 CONTINUE
684 390 CONTINUE
685 ELSE
686 DO 410 j = 1, n
687 CALL slarnv( 2, iseed, n-j+1, a( j, j ) )
688 DO 400 i = j, n
689 a( i, j ) = sign( tleft, a( i, j ) ) + tscal*a( i, j )
690 400 CONTINUE
691 410 CONTINUE
692 END IF
693 CALL slarnv( 2, iseed, n, b )
694 CALL sscal( n, two, b, 1 )
695 END IF
696
697
698
699 IF( .NOT.
lsame( trans,
'N' ) )
THEN
700 IF( upper ) THEN
701 DO 420 j = 1, n / 2
702 CALL sswap( n-2*j+1, a( j, j ), lda, a( j+1, n-j+1 ),
703 $ -1 )
704 420 CONTINUE
705 ELSE
706 DO 430 j = 1, n / 2
707 CALL sswap( n-2*j+1, a( j, j ), 1, a( n-j+1, j+1 ),
708 $ -lda )
709 430 CONTINUE
710 END IF
711 END IF
712
713 RETURN
714
715
716
subroutine scopy(n, sx, incx, sy, incy)
SCOPY
integer function isamax(n, sx, incx)
ISAMAX
real function slamch(cmach)
SLAMCH
subroutine slarnv(idist, iseed, n, x)
SLARNV returns a vector of random numbers from a uniform or normal distribution.
logical function lsame(ca, cb)
LSAME
subroutine srot(n, sx, incx, sy, incy, c, s)
SROT
subroutine srotg(a, b, c, s)
SROTG
subroutine sscal(n, sa, sx, incx)
SSCAL
subroutine sswap(n, sx, incx, sy, incy)
SSWAP
real function slarnd(idist, iseed)
SLARND
subroutine slatb4(path, imat, m, n, type, kl, ku, anorm, mode, cndnum, dist)
SLATB4
subroutine slatms(m, n, dist, iseed, sym, d, mode, cond, dmax, kl, ku, pack, a, lda, work, info)
SLATMS