209
210
211
212
213
214
215 CHARACTER NORM, TRANSR, UPLO
216 INTEGER N
217
218
219 DOUBLE PRECISION A( 0: * ), WORK( 0: * )
220
221
222
223
224
225 DOUBLE PRECISION ONE, ZERO
226 parameter( one = 1.0d+0, zero = 0.0d+0 )
227
228
229 INTEGER I, J, IFM, ILU, NOE, N1, K, L, LDA
230 DOUBLE PRECISION SCALE, S, VALUE, AA, TEMP
231
232
233 LOGICAL LSAME, DISNAN
235
236
238
239
240 INTRINSIC abs, max, sqrt
241
242
243
244 IF( n.EQ.0 ) THEN
246 RETURN
247 ELSE IF( n.EQ.1 ) THEN
249 RETURN
250 END IF
251
252
253
254 noe = 1
255 IF( mod( n, 2 ).EQ.0 )
256 $ noe = 0
257
258
259
260 ifm = 1
261 IF(
lsame( transr,
'T' ) )
262 $ ifm = 0
263
264
265
266 ilu = 1
267 IF(
lsame( uplo,
'U' ) )
268 $ ilu = 0
269
270
271
272
273
274 IF( ifm.EQ.1 ) THEN
275 IF( noe.EQ.1 ) THEN
276 lda = n
277 ELSE
278
279 lda = n + 1
280 END IF
281 ELSE
282
283 lda = ( n+1 ) / 2
284 END IF
285
286 IF(
lsame( norm,
'M' ) )
THEN
287
288
289
290 k = ( n+1 ) / 2
291 VALUE = zero
292 IF( noe.EQ.1 ) THEN
293
294 IF( ifm.EQ.1 ) THEN
295
296 DO j = 0, k - 1
297 DO i = 0, n - 1
298 temp = abs( a( i+j*lda ) )
299 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
300 $ VALUE = temp
301 END DO
302 END DO
303 ELSE
304
305 DO j = 0, n - 1
306 DO i = 0, k - 1
307 temp = abs( a( i+j*lda ) )
308 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
309 $ VALUE = temp
310 END DO
311 END DO
312 END IF
313 ELSE
314
315 IF( ifm.EQ.1 ) THEN
316
317 DO j = 0, k - 1
318 DO i = 0, n
319 temp = abs( a( i+j*lda ) )
320 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
321 $ VALUE = temp
322 END DO
323 END DO
324 ELSE
325
326 DO j = 0, n
327 DO i = 0, k - 1
328 temp = abs( a( i+j*lda ) )
329 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
330 $ VALUE = temp
331 END DO
332 END DO
333 END IF
334 END IF
335 ELSE IF( (
lsame( norm,
'I' ) ) .OR. (
lsame( norm,
'O' ) ) .OR.
336 $ ( norm.EQ.'1' ) ) THEN
337
338
339
340 IF( ifm.EQ.1 ) THEN
341 k = n / 2
342 IF( noe.EQ.1 ) THEN
343
344 IF( ilu.EQ.0 ) THEN
345 DO i = 0, k - 1
346 work( i ) = zero
347 END DO
348 DO j = 0, k
349 s = zero
350 DO i = 0, k + j - 1
351 aa = abs( a( i+j*lda ) )
352
353 s = s + aa
354 work( i ) = work( i ) + aa
355 END DO
356 aa = abs( a( i+j*lda ) )
357
358 work( j+k ) = s + aa
359 IF( i.EQ.k+k )
360 $ GO TO 10
361 i = i + 1
362 aa = abs( a( i+j*lda ) )
363
364 work( j ) = work( j ) + aa
365 s = zero
366 DO l = j + 1, k - 1
367 i = i + 1
368 aa = abs( a( i+j*lda ) )
369
370 s = s + aa
371 work( l ) = work( l ) + aa
372 END DO
373 work( j ) = work( j ) + s
374 END DO
375 10 CONTINUE
376 VALUE = work( 0 )
377 DO i = 1, n-1
378 temp = work( i )
379 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
380 $ VALUE = temp
381 END DO
382 ELSE
383
384 k = k + 1
385
386 DO i = k, n - 1
387 work( i ) = zero
388 END DO
389 DO j = k - 1, 0, -1
390 s = zero
391 DO i = 0, j - 2
392 aa = abs( a( i+j*lda ) )
393
394 s = s + aa
395 work( i+k ) = work( i+k ) + aa
396 END DO
397 IF( j.GT.0 ) THEN
398 aa = abs( a( i+j*lda ) )
399
400 s = s + aa
401 work( i+k ) = work( i+k ) + s
402
403 i = i + 1
404 END IF
405 aa = abs( a( i+j*lda ) )
406
407 work( j ) = aa
408 s = zero
409 DO l = j + 1, n - 1
410 i = i + 1
411 aa = abs( a( i+j*lda ) )
412
413 s = s + aa
414 work( l ) = work( l ) + aa
415 END DO
416 work( j ) = work( j ) + s
417 END DO
418 VALUE = work( 0 )
419 DO i = 1, n-1
420 temp = work( i )
421 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
422 $ VALUE = temp
423 END DO
424 END IF
425 ELSE
426
427 IF( ilu.EQ.0 ) THEN
428 DO i = 0, k - 1
429 work( i ) = zero
430 END DO
431 DO j = 0, k - 1
432 s = zero
433 DO i = 0, k + j - 1
434 aa = abs( a( i+j*lda ) )
435
436 s = s + aa
437 work( i ) = work( i ) + aa
438 END DO
439 aa = abs( a( i+j*lda ) )
440
441 work( j+k ) = s + aa
442 i = i + 1
443 aa = abs( a( i+j*lda ) )
444
445 work( j ) = work( j ) + aa
446 s = zero
447 DO l = j + 1, k - 1
448 i = i + 1
449 aa = abs( a( i+j*lda ) )
450
451 s = s + aa
452 work( l ) = work( l ) + aa
453 END DO
454 work( j ) = work( j ) + s
455 END DO
456 VALUE = work( 0 )
457 DO i = 1, n-1
458 temp = work( i )
459 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
460 $ VALUE = temp
461 END DO
462 ELSE
463
464 DO i = k, n - 1
465 work( i ) = zero
466 END DO
467 DO j = k - 1, 0, -1
468 s = zero
469 DO i = 0, j - 1
470 aa = abs( a( i+j*lda ) )
471
472 s = s + aa
473 work( i+k ) = work( i+k ) + aa
474 END DO
475 aa = abs( a( i+j*lda ) )
476
477 s = s + aa
478 work( i+k ) = work( i+k ) + s
479
480 i = i + 1
481 aa = abs( a( i+j*lda ) )
482
483 work( j ) = aa
484 s = zero
485 DO l = j + 1, n - 1
486 i = i + 1
487 aa = abs( a( i+j*lda ) )
488
489 s = s + aa
490 work( l ) = work( l ) + aa
491 END DO
492 work( j ) = work( j ) + s
493 END DO
494 VALUE = work( 0 )
495 DO i = 1, n-1
496 temp = work( i )
497 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
498 $ VALUE = temp
499 END DO
500 END IF
501 END IF
502 ELSE
503
504 k = n / 2
505 IF( noe.EQ.1 ) THEN
506
507 IF( ilu.EQ.0 ) THEN
508 n1 = k
509
510 k = k + 1
511
512 DO i = n1, n - 1
513 work( i ) = zero
514 END DO
515 DO j = 0, n1 - 1
516 s = zero
517 DO i = 0, k - 1
518 aa = abs( a( i+j*lda ) )
519
520 work( i+n1 ) = work( i+n1 ) + aa
521 s = s + aa
522 END DO
523 work( j ) = s
524 END DO
525
526 s = abs( a( 0+j*lda ) )
527
528 DO i = 1, k - 1
529 aa = abs( a( i+j*lda ) )
530
531 work( i+n1 ) = work( i+n1 ) + aa
532 s = s + aa
533 END DO
534 work( j ) = work( j ) + s
535 DO j = k, n - 1
536 s = zero
537 DO i = 0, j - k - 1
538 aa = abs( a( i+j*lda ) )
539
540 work( i ) = work( i ) + aa
541 s = s + aa
542 END DO
543
544 aa = abs( a( i+j*lda ) )
545
546 s = s + aa
547 work( j-k ) = work( j-k ) + s
548 i = i + 1
549 s = abs( a( i+j*lda ) )
550
551 DO l = j + 1, n - 1
552 i = i + 1
553 aa = abs( a( i+j*lda ) )
554
555 work( l ) = work( l ) + aa
556 s = s + aa
557 END DO
558 work( j ) = work( j ) + s
559 END DO
560 VALUE = work( 0 )
561 DO i = 1, n-1
562 temp = work( i )
563 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
564 $ VALUE = temp
565 END DO
566 ELSE
567
568 k = k + 1
569
570 DO i = k, n - 1
571 work( i ) = zero
572 END DO
573 DO j = 0, k - 2
574
575 s = zero
576 DO i = 0, j - 1
577 aa = abs( a( i+j*lda ) )
578
579 work( i ) = work( i ) + aa
580 s = s + aa
581 END DO
582 aa = abs( a( i+j*lda ) )
583
584 s = s + aa
585 work( j ) = s
586
587 i = i + 1
588
589 aa = abs( a( i+j*lda ) )
590 s = aa
591 DO l = k + j + 1, n - 1
592 i = i + 1
593 aa = abs( a( i+j*lda ) )
594
595 s = s + aa
596 work( l ) = work( l ) + aa
597 END DO
598 work( k+j ) = work( k+j ) + s
599 END DO
600
601 s = zero
602 DO i = 0, k - 2
603 aa = abs( a( i+j*lda ) )
604
605 work( i ) = work( i ) + aa
606 s = s + aa
607 END DO
608
609 aa = abs( a( i+j*lda ) )
610
611 s = s + aa
612 work( i ) = s
613
614 DO j = k, n - 1
615
616 s = zero
617 DO i = 0, k - 1
618 aa = abs( a( i+j*lda ) )
619
620 work( i ) = work( i ) + aa
621 s = s + aa
622 END DO
623 work( j ) = work( j ) + s
624 END DO
625 VALUE = work( 0 )
626 DO i = 1, n-1
627 temp = work( i )
628 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
629 $ VALUE = temp
630 END DO
631 END IF
632 ELSE
633
634 IF( ilu.EQ.0 ) THEN
635 DO i = k, n - 1
636 work( i ) = zero
637 END DO
638 DO j = 0, k - 1
639 s = zero
640 DO i = 0, k - 1
641 aa = abs( a( i+j*lda ) )
642
643 work( i+k ) = work( i+k ) + aa
644 s = s + aa
645 END DO
646 work( j ) = s
647 END DO
648
649 aa = abs( a( 0+j*lda ) )
650
651 s = aa
652 DO i = 1, k - 1
653 aa = abs( a( i+j*lda ) )
654
655 work( i+k ) = work( i+k ) + aa
656 s = s + aa
657 END DO
658 work( j ) = work( j ) + s
659 DO j = k + 1, n - 1
660 s = zero
661 DO i = 0, j - 2 - k
662 aa = abs( a( i+j*lda ) )
663
664 work( i ) = work( i ) + aa
665 s = s + aa
666 END DO
667
668 aa = abs( a( i+j*lda ) )
669
670 s = s + aa
671 work( j-k-1 ) = work( j-k-1 ) + s
672 i = i + 1
673 aa = abs( a( i+j*lda ) )
674
675 s = aa
676 DO l = j + 1, n - 1
677 i = i + 1
678 aa = abs( a( i+j*lda ) )
679
680 work( l ) = work( l ) + aa
681 s = s + aa
682 END DO
683 work( j ) = work( j ) + s
684 END DO
685
686 s = zero
687 DO i = 0, k - 2
688 aa = abs( a( i+j*lda ) )
689
690 work( i ) = work( i ) + aa
691 s = s + aa
692 END DO
693
694 aa = abs( a( i+j*lda ) )
695
696 s = s + aa
697 work( i ) = work( i ) + s
698 VALUE = work( 0 )
699 DO i = 1, n-1
700 temp = work( i )
701 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
702 $ VALUE = temp
703 END DO
704 ELSE
705
706 DO i = k, n - 1
707 work( i ) = zero
708 END DO
709
710 s = abs( a( 0 ) )
711
712 DO i = 1, k - 1
713 aa = abs( a( i ) )
714
715 work( i+k ) = work( i+k ) + aa
716 s = s + aa
717 END DO
718 work( k ) = work( k ) + s
719 DO j = 1, k - 1
720
721 s = zero
722 DO i = 0, j - 2
723 aa = abs( a( i+j*lda ) )
724
725 work( i ) = work( i ) + aa
726 s = s + aa
727 END DO
728 aa = abs( a( i+j*lda ) )
729
730 s = s + aa
731 work( j-1 ) = s
732
733 i = i + 1
734
735 aa = abs( a( i+j*lda ) )
736 s = aa
737 DO l = k + j + 1, n - 1
738 i = i + 1
739 aa = abs( a( i+j*lda ) )
740
741 s = s + aa
742 work( l ) = work( l ) + aa
743 END DO
744 work( k+j ) = work( k+j ) + s
745 END DO
746
747 s = zero
748 DO i = 0, k - 2
749 aa = abs( a( i+j*lda ) )
750
751 work( i ) = work( i ) + aa
752 s = s + aa
753 END DO
754
755 aa = abs( a( i+j*lda ) )
756
757 s = s + aa
758 work( i ) = s
759
760 DO j = k + 1, n
761
762 s = zero
763 DO i = 0, k - 1
764 aa = abs( a( i+j*lda ) )
765
766 work( i ) = work( i ) + aa
767 s = s + aa
768 END DO
769 work( j-1 ) = work( j-1 ) + s
770 END DO
771 VALUE = work( 0 )
772 DO i = 1, n-1
773 temp = work( i )
774 IF(
VALUE .LT. temp .OR.
disnan( temp ) )
775 $ VALUE = temp
776 END DO
777 END IF
778 END IF
779 END IF
780 ELSE IF( (
lsame( norm,
'F' ) ) .OR. (
lsame( norm,
'E' ) ) )
THEN
781
782
783
784 k = ( n+1 ) / 2
785 scale = zero
786 s = one
787 IF( noe.EQ.1 ) THEN
788
789 IF( ifm.EQ.1 ) THEN
790
791 IF( ilu.EQ.0 ) THEN
792
793 DO j = 0, k - 3
794 CALL dlassq( k-j-2, a( k+j+1+j*lda ), 1, scale, s )
795
796 END DO
797 DO j = 0, k - 1
798 CALL dlassq( k+j-1, a( 0+j*lda ), 1, scale, s )
799
800 END DO
801 s = s + s
802
803 CALL dlassq( k-1, a( k ), lda+1, scale, s )
804
805 CALL dlassq( k, a( k-1 ), lda+1, scale, s )
806
807 ELSE
808
809 DO j = 0, k - 1
810 CALL dlassq( n-j-1, a( j+1+j*lda ), 1, scale, s )
811
812 END DO
813 DO j = 0, k - 2
814 CALL dlassq( j, a( 0+( 1+j )*lda ), 1, scale, s )
815
816 END DO
817 s = s + s
818
819 CALL dlassq( k, a( 0 ), lda+1, scale, s )
820
821 CALL dlassq( k-1, a( 0+lda ), lda+1, scale, s )
822
823 END IF
824 ELSE
825
826 IF( ilu.EQ.0 ) THEN
827
828 DO j = 1, k - 2
829 CALL dlassq( j, a( 0+( k+j )*lda ), 1, scale, s )
830
831 END DO
832 DO j = 0, k - 2
833 CALL dlassq( k, a( 0+j*lda ), 1, scale, s )
834
835 END DO
836 DO j = 0, k - 2
837 CALL dlassq( k-j-1, a( j+1+( j+k-1 )*lda ), 1,
838 $ scale, s )
839
840 END DO
841 s = s + s
842
843 CALL dlassq( k-1, a( 0+k*lda ), lda+1, scale, s )
844
845 CALL dlassq( k, a( 0+( k-1 )*lda ), lda+1, scale, s )
846
847 ELSE
848
849 DO j = 1, k - 1
850 CALL dlassq( j, a( 0+j*lda ), 1, scale, s )
851
852 END DO
853 DO j = k, n - 1
854 CALL dlassq( k, a( 0+j*lda ), 1, scale, s )
855
856 END DO
857 DO j = 0, k - 3
858 CALL dlassq( k-j-2, a( j+2+j*lda ), 1, scale, s )
859
860 END DO
861 s = s + s
862
863 CALL dlassq( k, a( 0 ), lda+1, scale, s )
864
865 CALL dlassq( k-1, a( 1 ), lda+1, scale, s )
866
867 END IF
868 END IF
869 ELSE
870
871 IF( ifm.EQ.1 ) THEN
872
873 IF( ilu.EQ.0 ) THEN
874
875 DO j = 0, k - 2
876 CALL dlassq( k-j-1, a( k+j+2+j*lda ), 1, scale, s )
877
878 END DO
879 DO j = 0, k - 1
880 CALL dlassq( k+j, a( 0+j*lda ), 1, scale, s )
881
882 END DO
883 s = s + s
884
885 CALL dlassq( k, a( k+1 ), lda+1, scale, s )
886
887 CALL dlassq( k, a( k ), lda+1, scale, s )
888
889 ELSE
890
891 DO j = 0, k - 1
892 CALL dlassq( n-j-1, a( j+2+j*lda ), 1, scale, s )
893
894 END DO
895 DO j = 1, k - 1
896 CALL dlassq( j, a( 0+j*lda ), 1, scale, s )
897
898 END DO
899 s = s + s
900
901 CALL dlassq( k, a( 1 ), lda+1, scale, s )
902
903 CALL dlassq( k, a( 0 ), lda+1, scale, s )
904
905 END IF
906 ELSE
907
908 IF( ilu.EQ.0 ) THEN
909
910 DO j = 1, k - 1
911 CALL dlassq( j, a( 0+( k+1+j )*lda ), 1, scale, s )
912
913 END DO
914 DO j = 0, k - 1
915 CALL dlassq( k, a( 0+j*lda ), 1, scale, s )
916
917 END DO
918 DO j = 0, k - 2
919 CALL dlassq( k-j-1, a( j+1+( j+k )*lda ), 1, scale,
920 $ s )
921
922 END DO
923 s = s + s
924
925 CALL dlassq( k, a( 0+( k+1 )*lda ), lda+1, scale, s )
926
927 CALL dlassq( k, a( 0+k*lda ), lda+1, scale, s )
928
929 ELSE
930
931 DO j = 1, k - 1
932 CALL dlassq( j, a( 0+( j+1 )*lda ), 1, scale, s )
933
934 END DO
935 DO j = k + 1, n
936 CALL dlassq( k, a( 0+j*lda ), 1, scale, s )
937
938 END DO
939 DO j = 0, k - 2
940 CALL dlassq( k-j-1, a( j+1+j*lda ), 1, scale, s )
941
942 END DO
943 s = s + s
944
945 CALL dlassq( k, a( lda ), lda+1, scale, s )
946
947 CALL dlassq( k, a( 0 ), lda+1, scale, s )
948
949 END IF
950 END IF
951 END IF
952 VALUE = scale*sqrt( s )
953 END IF
954
956 RETURN
957
958
959
logical function disnan(din)
DISNAN tests input for NaN.
double precision function dlansf(norm, transr, uplo, n, a, work)
DLANSF returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
subroutine dlassq(n, x, incx, scale, sumsq)
DLASSQ updates a sum of squares represented in scaled form.
logical function lsame(ca, cb)
LSAME