```0001:       REAL FUNCTION CLANHF( NORM, TRANSR, UPLO, N, A, WORK )
0002: *
0003: *  -- LAPACK routine (version 3.2)                                    --
0004: *
0005: *  -- Contributed by Fred Gustavson of the IBM Watson Research Center --
0006: *  -- November 2008                                                   --
0007: *
0008: *  -- LAPACK is a software package provided by Univ. of Tennessee,    --
0009: *  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
0010: *
0011: *     .. Scalar Arguments ..
0012:       CHARACTER          NORM, TRANSR, UPLO
0013:       INTEGER            N
0014: *     ..
0015: *     .. Array Arguments ..
0016:       REAL               WORK( 0: * )
0017:       COMPLEX            A( 0: * )
0018: *     ..
0019: *
0020: *  Purpose
0021: *  =======
0022: *
0023: *  CLANHF  returns the value of the one norm,  or the Frobenius norm, or
0024: *  the  infinity norm,  or the  element of  largest absolute value  of a
0025: *  complex Hermitian matrix A in RFP format.
0026: *
0027: *  Description
0028: *  ===========
0029: *
0030: *  CLANHF returns the value
0031: *
0032: *     CLANHF = ( max(abs(A(i,j))), NORM = 'M' or 'm'
0033: *              (
0034: *              ( norm1(A),         NORM = '1', 'O' or 'o'
0035: *              (
0036: *              ( normI(A),         NORM = 'I' or 'i'
0037: *              (
0038: *              ( normF(A),         NORM = 'F', 'f', 'E' or 'e'
0039: *
0040: *  where  norm1  denotes the  one norm of a matrix (maximum column sum),
0041: *  normI  denotes the  infinity norm  of a matrix  (maximum row sum) and
0042: *  normF  denotes the  Frobenius norm of a matrix (square root of sum of
0043: *  squares).  Note that  max(abs(A(i,j)))  is not a  matrix norm.
0044: *
0045: *  Arguments
0046: *  =========
0047: *
0048: *  NORM      (input) CHARACTER
0049: *            Specifies the value to be returned in CLANHF as described
0050: *            above.
0051: *
0052: *  TRANSR    (input) CHARACTER
0053: *            Specifies whether the RFP format of A is normal or
0054: *            conjugate-transposed format.
0055: *            = 'N':  RFP format is Normal
0056: *            = 'C':  RFP format is Conjugate-transposed
0057: *
0058: *  UPLO      (input) CHARACTER
0059: *            On entry, UPLO specifies whether the RFP matrix A came from
0060: *            an upper or lower triangular matrix as follows:
0061: *
0062: *            UPLO = 'U' or 'u' RFP A came from an upper triangular
0063: *            matrix
0064: *
0065: *            UPLO = 'L' or 'l' RFP A came from a  lower triangular
0066: *            matrix
0067: *
0068: *  N         (input) INTEGER
0069: *            The order of the matrix A.  N >= 0.  When N = 0, CLANHF is
0070: *            set to zero.
0071: *
0072: *   A        (input) COMPLEX*16 array, dimension ( N*(N+1)/2 );
0073: *            On entry, the matrix A in RFP Format.
0074: *            RFP Format is described by TRANSR, UPLO and N as follows:
0075: *            If TRANSR='N' then RFP A is (0:N,0:K-1) when N is even;
0076: *            K=N/2. RFP A is (0:N-1,0:K) when N is odd; K=N/2. If
0077: *            TRANSR = 'C' then RFP is the Conjugate-transpose of RFP A
0078: *            as defined when TRANSR = 'N'. The contents of RFP A are
0079: *            defined by UPLO as follows: If UPLO = 'U' the RFP A
0080: *            contains the ( N*(N+1)/2 ) elements of upper packed A
0081: *            either in normal or conjugate-transpose Format. If
0082: *            UPLO = 'L' the RFP A contains the ( N*(N+1) /2 ) elements
0083: *            of lower packed A either in normal or conjugate-transpose
0084: *            Format. The LDA of RFP A is (N+1)/2 when TRANSR = 'C'. When
0085: *            TRANSR is 'N' the LDA is N+1 when N is even and is N when
0086: *            is odd. See the Note below for more details.
0087: *            Unchanged on exit.
0088: *
0089: *  WORK      (workspace) REAL array, dimension (LWORK),
0090: *            where LWORK >= N when NORM = 'I' or '1' or 'O'; otherwise,
0091: *            WORK is not referenced.
0092: *
0093: *  Note:
0094: *  =====
0095: *
0096: *  We first consider Standard Packed Format when N is even.
0097: *  We give an example where N = 6.
0098: *
0099: *      AP is Upper             AP is Lower
0100: *
0101: *   00 01 02 03 04 05       00
0102: *      11 12 13 14 15       10 11
0103: *         22 23 24 25       20 21 22
0104: *            33 34 35       30 31 32 33
0105: *               44 45       40 41 42 43 44
0106: *                  55       50 51 52 53 54 55
0107: *
0108: *
0109: *  Let TRANSR = 'N'. RFP holds AP as follows:
0110: *  For UPLO = 'U' the upper trapezoid A(0:5,0:2) consists of the last
0111: *  three columns of AP upper. The lower triangle A(4:6,0:2) consists of
0112: *  conjugate-transpose of the first three columns of AP upper.
0113: *  For UPLO = 'L' the lower trapezoid A(1:6,0:2) consists of the first
0114: *  three columns of AP lower. The upper triangle A(0:2,0:2) consists of
0115: *  conjugate-transpose of the last three columns of AP lower.
0116: *  To denote conjugate we place -- above the element. This covers the
0117: *  case N even and TRANSR = 'N'.
0118: *
0119: *         RFP A                   RFP A
0120: *
0121: *                                -- -- --
0122: *        03 04 05                33 43 53
0123: *                                   -- --
0124: *        13 14 15                00 44 54
0125: *                                      --
0126: *        23 24 25                10 11 55
0127: *
0128: *        33 34 35                20 21 22
0129: *        --
0130: *        00 44 45                30 31 32
0131: *        -- --
0132: *        01 11 55                40 41 42
0133: *        -- -- --
0134: *        02 12 22                50 51 52
0135: *
0136: *  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
0137: *  transpose of RFP A above. One therefore gets:
0138: *
0139: *
0140: *           RFP A                   RFP A
0141: *
0142: *     -- -- -- --                -- -- -- -- -- --
0143: *     03 13 23 33 00 01 02    33 00 10 20 30 40 50
0144: *     -- -- -- -- --                -- -- -- -- --
0145: *     04 14 24 34 44 11 12    43 44 11 21 31 41 51
0146: *     -- -- -- -- -- --                -- -- -- --
0147: *     05 15 25 35 45 55 22    53 54 55 22 32 42 52
0148: *
0149: *
0150: *  We next  consider Standard Packed Format when N is odd.
0151: *  We give an example where N = 5.
0152: *
0153: *     AP is Upper                 AP is Lower
0154: *
0155: *   00 01 02 03 04              00
0156: *      11 12 13 14              10 11
0157: *         22 23 24              20 21 22
0158: *            33 34              30 31 32 33
0159: *               44              40 41 42 43 44
0160: *
0161: *
0162: *  Let TRANSR = 'N'. RFP holds AP as follows:
0163: *  For UPLO = 'U' the upper trapezoid A(0:4,0:2) consists of the last
0164: *  three columns of AP upper. The lower triangle A(3:4,0:1) consists of
0165: *  conjugate-transpose of the first two   columns of AP upper.
0166: *  For UPLO = 'L' the lower trapezoid A(0:4,0:2) consists of the first
0167: *  three columns of AP lower. The upper triangle A(0:1,1:2) consists of
0168: *  conjugate-transpose of the last two   columns of AP lower.
0169: *  To denote conjugate we place -- above the element. This covers the
0170: *  case N odd  and TRANSR = 'N'.
0171: *
0172: *         RFP A                   RFP A
0173: *
0174: *                                   -- --
0175: *        02 03 04                00 33 43
0176: *                                      --
0177: *        12 13 14                10 11 44
0178: *
0179: *        22 23 24                20 21 22
0180: *        --
0181: *        00 33 34                30 31 32
0182: *        -- --
0183: *        01 11 44                40 41 42
0184: *
0185: *  Now let TRANSR = 'C'. RFP A in both UPLO cases is just the conjugate-
0186: *  transpose of RFP A above. One therefore gets:
0187: *
0188: *
0189: *           RFP A                   RFP A
0190: *
0191: *     -- -- --                   -- -- -- -- -- --
0192: *     02 12 22 00 01             00 10 20 30 40 50
0193: *     -- -- -- --                   -- -- -- -- --
0194: *     03 13 23 33 11             33 11 21 31 41 51
0195: *     -- -- -- -- --                   -- -- -- --
0196: *     04 14 24 34 44             43 44 22 32 42 52
0197: *
0198: *  =====================================================================
0199: *
0200: *     .. Parameters ..
0201:       REAL               ONE, ZERO
0202:       PARAMETER          ( ONE = 1.0E+0, ZERO = 0.0E+0 )
0203: *     ..
0204: *     .. Local Scalars ..
0205:       INTEGER            I, J, IFM, ILU, NOE, N1, K, L, LDA
0206:       REAL               SCALE, S, VALUE, AA
0207: *     ..
0208: *     .. External Functions ..
0209:       LOGICAL            LSAME
0210:       INTEGER            ISAMAX
0211:       EXTERNAL           LSAME, ISAMAX
0212: *     ..
0213: *     .. External Subroutines ..
0214:       EXTERNAL           CLASSQ
0215: *     ..
0216: *     .. Intrinsic Functions ..
0217:       INTRINSIC          ABS, REAL, MAX, SQRT
0218: *     ..
0219: *     .. Executable Statements ..
0220: *
0221:       IF( N.EQ.0 ) THEN
0222:          CLANHF = ZERO
0223:          RETURN
0224:       END IF
0225: *
0226: *     set noe = 1 if n is odd. if n is even set noe=0
0227: *
0228:       NOE = 1
0229:       IF( MOD( N, 2 ).EQ.0 )
0230:      +   NOE = 0
0231: *
0232: *     set ifm = 0 when form='C' or 'c' and 1 otherwise
0233: *
0234:       IFM = 1
0235:       IF( LSAME( TRANSR, 'C' ) )
0236:      +   IFM = 0
0237: *
0238: *     set ilu = 0 when uplo='U or 'u' and 1 otherwise
0239: *
0240:       ILU = 1
0241:       IF( LSAME( UPLO, 'U' ) )
0242:      +   ILU = 0
0243: *
0244: *     set lda = (n+1)/2 when ifm = 0
0245: *     set lda = n when ifm = 1 and noe = 1
0246: *     set lda = n+1 when ifm = 1 and noe = 0
0247: *
0248:       IF( IFM.EQ.1 ) THEN
0249:          IF( NOE.EQ.1 ) THEN
0250:             LDA = N
0251:          ELSE
0252: *           noe=0
0253:             LDA = N + 1
0254:          END IF
0255:       ELSE
0256: *        ifm=0
0257:          LDA = ( N+1 ) / 2
0258:       END IF
0259: *
0260:       IF( LSAME( NORM, 'M' ) ) THEN
0261: *
0262: *       Find max(abs(A(i,j))).
0263: *
0264:          K = ( N+1 ) / 2
0265:          VALUE = ZERO
0266:          IF( NOE.EQ.1 ) THEN
0267: *           n is odd & n = k + k - 1
0268:             IF( IFM.EQ.1 ) THEN
0269: *              A is n by k
0270:                IF( ILU.EQ.1 ) THEN
0271: *                 uplo ='L'
0272:                   J = 0
0273: *                 -> L(0,0)
0274:                   VALUE = MAX( VALUE, ABS( REAL( A( J+J*LDA ) ) ) )
0275:                   DO I = 1, N - 1
0276:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0277:                   END DO
0278:                   DO J = 1, K - 1
0279:                      DO I = 0, J - 2
0280:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0281:                      END DO
0282:                      I = J - 1
0283: *                    L(k+j,k+j)
0284:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0285:                      I = J
0286: *                    -> L(j,j)
0287:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0288:                      DO I = J + 1, N - 1
0289:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0290:                      END DO
0291:                   END DO
0292:                ELSE
0293: *                 uplo = 'U'
0294:                   DO J = 0, K - 2
0295:                      DO I = 0, K + J - 2
0296:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0297:                      END DO
0298:                      I = K + J - 1
0299: *                    -> U(i,i)
0300:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0301:                      I = I + 1
0302: *                    =k+j; i -> U(j,j)
0303:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0304:                      DO I = K + J + 1, N - 1
0305:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0306:                      END DO
0307:                   END DO
0308:                   DO I = 0, N - 2
0309:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0310: *                    j=k-1
0311:                   END DO
0312: *                 i=n-1 -> U(n-1,n-1)
0313:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0314:                END IF
0315:             ELSE
0316: *              xpose case; A is k by n
0317:                IF( ILU.EQ.1 ) THEN
0318: *                 uplo ='L'
0319:                   DO J = 0, K - 2
0320:                      DO I = 0, J - 1
0321:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0322:                      END DO
0323:                      I = J
0324: *                    L(i,i)
0325:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0326:                      I = J + 1
0327: *                    L(j+k,j+k)
0328:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0329:                      DO I = J + 2, K - 1
0330:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0331:                      END DO
0332:                   END DO
0333:                   J = K - 1
0334:                   DO I = 0, K - 2
0335:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0336:                   END DO
0337:                   I = K - 1
0338: *                 -> L(i,i) is at A(i,j)
0339:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0340:                   DO J = K, N - 1
0341:                      DO I = 0, K - 1
0342:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0343:                      END DO
0344:                   END DO
0345:                ELSE
0346: *                 uplo = 'U'
0347:                   DO J = 0, K - 2
0348:                      DO I = 0, K - 1
0349:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0350:                      END DO
0351:                   END DO
0352:                   J = K - 1
0353: *                 -> U(j,j) is at A(0,j)
0354:                   VALUE = MAX( VALUE, ABS( REAL( A( 0+J*LDA ) ) ) )
0355:                   DO I = 1, K - 1
0356:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0357:                   END DO
0358:                   DO J = K, N - 1
0359:                      DO I = 0, J - K - 1
0360:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0361:                      END DO
0362:                      I = J - K
0363: *                    -> U(i,i) at A(i,j)
0364:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0365:                      I = J - K + 1
0366: *                    U(j,j)
0367:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0368:                      DO I = J - K + 2, K - 1
0369:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0370:                      END DO
0371:                   END DO
0372:                END IF
0373:             END IF
0374:          ELSE
0375: *           n is even & k = n/2
0376:             IF( IFM.EQ.1 ) THEN
0377: *              A is n+1 by k
0378:                IF( ILU.EQ.1 ) THEN
0379: *                 uplo ='L'
0380:                   J = 0
0381: *                 -> L(k,k) & j=1 -> L(0,0)
0382:                   VALUE = MAX( VALUE, ABS( REAL( A( J+J*LDA ) ) ) )
0383:                   VALUE = MAX( VALUE, ABS( REAL( A( J+1+J*LDA ) ) ) )
0384:                   DO I = 2, N
0385:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0386:                   END DO
0387:                   DO J = 1, K - 1
0388:                      DO I = 0, J - 1
0389:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0390:                      END DO
0391:                      I = J
0392: *                    L(k+j,k+j)
0393:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0394:                      I = J + 1
0395: *                    -> L(j,j)
0396:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0397:                      DO I = J + 2, N
0398:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0399:                      END DO
0400:                   END DO
0401:                ELSE
0402: *                 uplo = 'U'
0403:                   DO J = 0, K - 2
0404:                      DO I = 0, K + J - 1
0405:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0406:                      END DO
0407:                      I = K + J
0408: *                    -> U(i,i)
0409:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0410:                      I = I + 1
0411: *                    =k+j+1; i -> U(j,j)
0412:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0413:                      DO I = K + J + 2, N
0414:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0415:                      END DO
0416:                   END DO
0417:                   DO I = 0, N - 2
0418:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0419: *                    j=k-1
0420:                   END DO
0421: *                 i=n-1 -> U(n-1,n-1)
0422:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0423:                   I = N
0424: *                 -> U(k-1,k-1)
0425:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0426:                END IF
0427:             ELSE
0428: *              xpose case; A is k by n+1
0429:                IF( ILU.EQ.1 ) THEN
0430: *                 uplo ='L'
0431:                   J = 0
0432: *                 -> L(k,k) at A(0,0)
0433:                   VALUE = MAX( VALUE, ABS( REAL( A( J+J*LDA ) ) ) )
0434:                   DO I = 1, K - 1
0435:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0436:                   END DO
0437:                   DO J = 1, K - 1
0438:                      DO I = 0, J - 2
0439:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0440:                      END DO
0441:                      I = J - 1
0442: *                    L(i,i)
0443:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0444:                      I = J
0445: *                    L(j+k,j+k)
0446:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0447:                      DO I = J + 1, K - 1
0448:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0449:                      END DO
0450:                   END DO
0451:                   J = K
0452:                   DO I = 0, K - 2
0453:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0454:                   END DO
0455:                   I = K - 1
0456: *                 -> L(i,i) is at A(i,j)
0457:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0458:                   DO J = K + 1, N
0459:                      DO I = 0, K - 1
0460:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0461:                      END DO
0462:                   END DO
0463:                ELSE
0464: *                 uplo = 'U'
0465:                   DO J = 0, K - 1
0466:                      DO I = 0, K - 1
0467:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0468:                      END DO
0469:                   END DO
0470:                   J = K
0471: *                 -> U(j,j) is at A(0,j)
0472:                   VALUE = MAX( VALUE, ABS( REAL( A( 0+J*LDA ) ) ) )
0473:                   DO I = 1, K - 1
0474:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0475:                   END DO
0476:                   DO J = K + 1, N - 1
0477:                      DO I = 0, J - K - 2
0478:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0479:                      END DO
0480:                      I = J - K - 1
0481: *                    -> U(i,i) at A(i,j)
0482:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0483:                      I = J - K
0484: *                    U(j,j)
0485:                      VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0486:                      DO I = J - K + 1, K - 1
0487:                         VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0488:                      END DO
0489:                   END DO
0490:                   J = N
0491:                   DO I = 0, K - 2
0492:                      VALUE = MAX( VALUE, ABS( A( I+J*LDA ) ) )
0493:                   END DO
0494:                   I = K - 1
0495: *                 U(k,k) at A(i,j)
0496:                   VALUE = MAX( VALUE, ABS( REAL( A( I+J*LDA ) ) ) )
0497:                END IF
0498:             END IF
0499:          END IF
0500:       ELSE IF( ( LSAME( NORM, 'I' ) ) .OR. ( LSAME( NORM, 'O' ) ) .OR.
0501:      +         ( NORM.EQ.'1' ) ) THEN
0502: *
0503: *       Find normI(A) ( = norm1(A), since A is Hermitian).
0504: *
0505:          IF( IFM.EQ.1 ) THEN
0506: *           A is 'N'
0507:             K = N / 2
0508:             IF( NOE.EQ.1 ) THEN
0509: *              n is odd & A is n by (n+1)/2
0510:                IF( ILU.EQ.0 ) THEN
0511: *                 uplo = 'U'
0512:                   DO I = 0, K - 1
0513:                      WORK( I ) = ZERO
0514:                   END DO
0515:                   DO J = 0, K
0516:                      S = ZERO
0517:                      DO I = 0, K + J - 1
0518:                         AA = ABS( A( I+J*LDA ) )
0519: *                       -> A(i,j+k)
0520:                         S = S + AA
0521:                         WORK( I ) = WORK( I ) + AA
0522:                      END DO
0523:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0524: *                    -> A(j+k,j+k)
0525:                      WORK( J+K ) = S + AA
0526:                      IF( I.EQ.K+K )
0527:      +                  GO TO 10
0528:                      I = I + 1
0529:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0530: *                    -> A(j,j)
0531:                      WORK( J ) = WORK( J ) + AA
0532:                      S = ZERO
0533:                      DO L = J + 1, K - 1
0534:                         I = I + 1
0535:                         AA = ABS( A( I+J*LDA ) )
0536: *                       -> A(l,j)
0537:                         S = S + AA
0538:                         WORK( L ) = WORK( L ) + AA
0539:                      END DO
0540:                      WORK( J ) = WORK( J ) + S
0541:                   END DO
0542:    10             CONTINUE
0543:                   I = ISAMAX( N, WORK, 1 )
0544:                   VALUE = WORK( I-1 )
0545:                ELSE
0546: *                 ilu = 1 & uplo = 'L'
0547:                   K = K + 1
0548: *                 k=(n+1)/2 for n odd and ilu=1
0549:                   DO I = K, N - 1
0550:                      WORK( I ) = ZERO
0551:                   END DO
0552:                   DO J = K - 1, 0, -1
0553:                      S = ZERO
0554:                      DO I = 0, J - 2
0555:                         AA = ABS( A( I+J*LDA ) )
0556: *                       -> A(j+k,i+k)
0557:                         S = S + AA
0558:                         WORK( I+K ) = WORK( I+K ) + AA
0559:                      END DO
0560:                      IF( J.GT.0 ) THEN
0561:                         AA = ABS( REAL( A( I+J*LDA ) ) )
0562: *                       -> A(j+k,j+k)
0563:                         S = S + AA
0564:                         WORK( I+K ) = WORK( I+K ) + S
0565: *                       i=j
0566:                         I = I + 1
0567:                      END IF
0568:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0569: *                    -> A(j,j)
0570:                      WORK( J ) = AA
0571:                      S = ZERO
0572:                      DO L = J + 1, N - 1
0573:                         I = I + 1
0574:                         AA = ABS( A( I+J*LDA ) )
0575: *                       -> A(l,j)
0576:                         S = S + AA
0577:                         WORK( L ) = WORK( L ) + AA
0578:                      END DO
0579:                      WORK( J ) = WORK( J ) + S
0580:                   END DO
0581:                   I = ISAMAX( N, WORK, 1 )
0582:                   VALUE = WORK( I-1 )
0583:                END IF
0584:             ELSE
0585: *              n is even & A is n+1 by k = n/2
0586:                IF( ILU.EQ.0 ) THEN
0587: *                 uplo = 'U'
0588:                   DO I = 0, K - 1
0589:                      WORK( I ) = ZERO
0590:                   END DO
0591:                   DO J = 0, K - 1
0592:                      S = ZERO
0593:                      DO I = 0, K + J - 1
0594:                         AA = ABS( A( I+J*LDA ) )
0595: *                       -> A(i,j+k)
0596:                         S = S + AA
0597:                         WORK( I ) = WORK( I ) + AA
0598:                      END DO
0599:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0600: *                    -> A(j+k,j+k)
0601:                      WORK( J+K ) = S + AA
0602:                      I = I + 1
0603:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0604: *                    -> A(j,j)
0605:                      WORK( J ) = WORK( J ) + AA
0606:                      S = ZERO
0607:                      DO L = J + 1, K - 1
0608:                         I = I + 1
0609:                         AA = ABS( A( I+J*LDA ) )
0610: *                       -> A(l,j)
0611:                         S = S + AA
0612:                         WORK( L ) = WORK( L ) + AA
0613:                      END DO
0614:                      WORK( J ) = WORK( J ) + S
0615:                   END DO
0616:                   I = ISAMAX( N, WORK, 1 )
0617:                   VALUE = WORK( I-1 )
0618:                ELSE
0619: *                 ilu = 1 & uplo = 'L'
0620:                   DO I = K, N - 1
0621:                      WORK( I ) = ZERO
0622:                   END DO
0623:                   DO J = K - 1, 0, -1
0624:                      S = ZERO
0625:                      DO I = 0, J - 1
0626:                         AA = ABS( A( I+J*LDA ) )
0627: *                       -> A(j+k,i+k)
0628:                         S = S + AA
0629:                         WORK( I+K ) = WORK( I+K ) + AA
0630:                      END DO
0631:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0632: *                    -> A(j+k,j+k)
0633:                      S = S + AA
0634:                      WORK( I+K ) = WORK( I+K ) + S
0635: *                    i=j
0636:                      I = I + 1
0637:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0638: *                    -> A(j,j)
0639:                      WORK( J ) = AA
0640:                      S = ZERO
0641:                      DO L = J + 1, N - 1
0642:                         I = I + 1
0643:                         AA = ABS( A( I+J*LDA ) )
0644: *                       -> A(l,j)
0645:                         S = S + AA
0646:                         WORK( L ) = WORK( L ) + AA
0647:                      END DO
0648:                      WORK( J ) = WORK( J ) + S
0649:                   END DO
0650:                   I = ISAMAX( N, WORK, 1 )
0651:                   VALUE = WORK( I-1 )
0652:                END IF
0653:             END IF
0654:          ELSE
0655: *           ifm=0
0656:             K = N / 2
0657:             IF( NOE.EQ.1 ) THEN
0658: *              n is odd & A is (n+1)/2 by n
0659:                IF( ILU.EQ.0 ) THEN
0660: *                 uplo = 'U'
0661:                   N1 = K
0662: *                 n/2
0663:                   K = K + 1
0664: *                 k is the row size and lda
0665:                   DO I = N1, N - 1
0666:                      WORK( I ) = ZERO
0667:                   END DO
0668:                   DO J = 0, N1 - 1
0669:                      S = ZERO
0670:                      DO I = 0, K - 1
0671:                         AA = ABS( A( I+J*LDA ) )
0672: *                       A(j,n1+i)
0673:                         WORK( I+N1 ) = WORK( I+N1 ) + AA
0674:                         S = S + AA
0675:                      END DO
0676:                      WORK( J ) = S
0677:                   END DO
0678: *                 j=n1=k-1 is special
0679:                   S = ABS( REAL( A( 0+J*LDA ) ) )
0680: *                 A(k-1,k-1)
0681:                   DO I = 1, K - 1
0682:                      AA = ABS( A( I+J*LDA ) )
0683: *                    A(k-1,i+n1)
0684:                      WORK( I+N1 ) = WORK( I+N1 ) + AA
0685:                      S = S + AA
0686:                   END DO
0687:                   WORK( J ) = WORK( J ) + S
0688:                   DO J = K, N - 1
0689:                      S = ZERO
0690:                      DO I = 0, J - K - 1
0691:                         AA = ABS( A( I+J*LDA ) )
0692: *                       A(i,j-k)
0693:                         WORK( I ) = WORK( I ) + AA
0694:                         S = S + AA
0695:                      END DO
0696: *                    i=j-k
0697:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0698: *                    A(j-k,j-k)
0699:                      S = S + AA
0700:                      WORK( J-K ) = WORK( J-K ) + S
0701:                      I = I + 1
0702:                      S = ABS( REAL( A( I+J*LDA ) ) )
0703: *                    A(j,j)
0704:                      DO L = J + 1, N - 1
0705:                         I = I + 1
0706:                         AA = ABS( A( I+J*LDA ) )
0707: *                       A(j,l)
0708:                         WORK( L ) = WORK( L ) + AA
0709:                         S = S + AA
0710:                      END DO
0711:                      WORK( J ) = WORK( J ) + S
0712:                   END DO
0713:                   I = ISAMAX( N, WORK, 1 )
0714:                   VALUE = WORK( I-1 )
0715:                ELSE
0716: *                 ilu=1 & uplo = 'L'
0717:                   K = K + 1
0718: *                 k=(n+1)/2 for n odd and ilu=1
0719:                   DO I = K, N - 1
0720:                      WORK( I ) = ZERO
0721:                   END DO
0722:                   DO J = 0, K - 2
0723: *                    process
0724:                      S = ZERO
0725:                      DO I = 0, J - 1
0726:                         AA = ABS( A( I+J*LDA ) )
0727: *                       A(j,i)
0728:                         WORK( I ) = WORK( I ) + AA
0729:                         S = S + AA
0730:                      END DO
0731:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0732: *                    i=j so process of A(j,j)
0733:                      S = S + AA
0734:                      WORK( J ) = S
0735: *                    is initialised here
0736:                      I = I + 1
0737: *                    i=j process A(j+k,j+k)
0738:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0739:                      S = AA
0740:                      DO L = K + J + 1, N - 1
0741:                         I = I + 1
0742:                         AA = ABS( A( I+J*LDA ) )
0743: *                       A(l,k+j)
0744:                         S = S + AA
0745:                         WORK( L ) = WORK( L ) + AA
0746:                      END DO
0747:                      WORK( K+J ) = WORK( K+J ) + S
0748:                   END DO
0749: *                 j=k-1 is special :process col A(k-1,0:k-1)
0750:                   S = ZERO
0751:                   DO I = 0, K - 2
0752:                      AA = ABS( A( I+J*LDA ) )
0753: *                    A(k,i)
0754:                      WORK( I ) = WORK( I ) + AA
0755:                      S = S + AA
0756:                   END DO
0757: *                 i=k-1
0758:                   AA = ABS( REAL( A( I+J*LDA ) ) )
0759: *                 A(k-1,k-1)
0760:                   S = S + AA
0761:                   WORK( I ) = S
0762: *                 done with col j=k+1
0763:                   DO J = K, N - 1
0764: *                    process col j of A = A(j,0:k-1)
0765:                      S = ZERO
0766:                      DO I = 0, K - 1
0767:                         AA = ABS( A( I+J*LDA ) )
0768: *                       A(j,i)
0769:                         WORK( I ) = WORK( I ) + AA
0770:                         S = S + AA
0771:                      END DO
0772:                      WORK( J ) = WORK( J ) + S
0773:                   END DO
0774:                   I = ISAMAX( N, WORK, 1 )
0775:                   VALUE = WORK( I-1 )
0776:                END IF
0777:             ELSE
0778: *              n is even & A is k=n/2 by n+1
0779:                IF( ILU.EQ.0 ) THEN
0780: *                 uplo = 'U'
0781:                   DO I = K, N - 1
0782:                      WORK( I ) = ZERO
0783:                   END DO
0784:                   DO J = 0, K - 1
0785:                      S = ZERO
0786:                      DO I = 0, K - 1
0787:                         AA = ABS( A( I+J*LDA ) )
0788: *                       A(j,i+k)
0789:                         WORK( I+K ) = WORK( I+K ) + AA
0790:                         S = S + AA
0791:                      END DO
0792:                      WORK( J ) = S
0793:                   END DO
0794: *                 j=k
0795:                   AA = ABS( REAL( A( 0+J*LDA ) ) )
0796: *                 A(k,k)
0797:                   S = AA
0798:                   DO I = 1, K - 1
0799:                      AA = ABS( A( I+J*LDA ) )
0800: *                    A(k,k+i)
0801:                      WORK( I+K ) = WORK( I+K ) + AA
0802:                      S = S + AA
0803:                   END DO
0804:                   WORK( J ) = WORK( J ) + S
0805:                   DO J = K + 1, N - 1
0806:                      S = ZERO
0807:                      DO I = 0, J - 2 - K
0808:                         AA = ABS( A( I+J*LDA ) )
0809: *                       A(i,j-k-1)
0810:                         WORK( I ) = WORK( I ) + AA
0811:                         S = S + AA
0812:                      END DO
0813: *                    i=j-1-k
0814:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0815: *                    A(j-k-1,j-k-1)
0816:                      S = S + AA
0817:                      WORK( J-K-1 ) = WORK( J-K-1 ) + S
0818:                      I = I + 1
0819:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0820: *                    A(j,j)
0821:                      S = AA
0822:                      DO L = J + 1, N - 1
0823:                         I = I + 1
0824:                         AA = ABS( A( I+J*LDA ) )
0825: *                       A(j,l)
0826:                         WORK( L ) = WORK( L ) + AA
0827:                         S = S + AA
0828:                      END DO
0829:                      WORK( J ) = WORK( J ) + S
0830:                   END DO
0831: *                 j=n
0832:                   S = ZERO
0833:                   DO I = 0, K - 2
0834:                      AA = ABS( A( I+J*LDA ) )
0835: *                    A(i,k-1)
0836:                      WORK( I ) = WORK( I ) + AA
0837:                      S = S + AA
0838:                   END DO
0839: *                 i=k-1
0840:                   AA = ABS( REAL( A( I+J*LDA ) ) )
0841: *                 A(k-1,k-1)
0842:                   S = S + AA
0843:                   WORK( I ) = WORK( I ) + S
0844:                   I = ISAMAX( N, WORK, 1 )
0845:                   VALUE = WORK( I-1 )
0846:                ELSE
0847: *                 ilu=1 & uplo = 'L'
0848:                   DO I = K, N - 1
0849:                      WORK( I ) = ZERO
0850:                   END DO
0851: *                 j=0 is special :process col A(k:n-1,k)
0852:                   S = ABS( REAL( A( 0 ) ) )
0853: *                 A(k,k)
0854:                   DO I = 1, K - 1
0855:                      AA = ABS( A( I ) )
0856: *                    A(k+i,k)
0857:                      WORK( I+K ) = WORK( I+K ) + AA
0858:                      S = S + AA
0859:                   END DO
0860:                   WORK( K ) = WORK( K ) + S
0861:                   DO J = 1, K - 1
0862: *                    process
0863:                      S = ZERO
0864:                      DO I = 0, J - 2
0865:                         AA = ABS( A( I+J*LDA ) )
0866: *                       A(j-1,i)
0867:                         WORK( I ) = WORK( I ) + AA
0868:                         S = S + AA
0869:                      END DO
0870:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0871: *                    i=j-1 so process of A(j-1,j-1)
0872:                      S = S + AA
0873:                      WORK( J-1 ) = S
0874: *                    is initialised here
0875:                      I = I + 1
0876: *                    i=j process A(j+k,j+k)
0877:                      AA = ABS( REAL( A( I+J*LDA ) ) )
0878:                      S = AA
0879:                      DO L = K + J + 1, N - 1
0880:                         I = I + 1
0881:                         AA = ABS( A( I+J*LDA ) )
0882: *                       A(l,k+j)
0883:                         S = S + AA
0884:                         WORK( L ) = WORK( L ) + AA
0885:                      END DO
0886:                      WORK( K+J ) = WORK( K+J ) + S
0887:                   END DO
0888: *                 j=k is special :process col A(k,0:k-1)
0889:                   S = ZERO
0890:                   DO I = 0, K - 2
0891:                      AA = ABS( A( I+J*LDA ) )
0892: *                    A(k,i)
0893:                      WORK( I ) = WORK( I ) + AA
0894:                      S = S + AA
0895:                   END DO
0896: *
0897: *                 i=k-1
0898:                   AA = ABS( REAL( A( I+J*LDA ) ) )
0899: *                 A(k-1,k-1)
0900:                   S = S + AA
0901:                   WORK( I ) = S
0902: *                 done with col j=k+1
0903:                   DO J = K + 1, N
0904: *
0905: *                    process col j-1 of A = A(j-1,0:k-1)
0906:                      S = ZERO
0907:                      DO I = 0, K - 1
0908:                         AA = ABS( A( I+J*LDA ) )
0909: *                       A(j-1,i)
0910:                         WORK( I ) = WORK( I ) + AA
0911:                         S = S + AA
0912:                      END DO
0913:                      WORK( J-1 ) = WORK( J-1 ) + S
0914:                   END DO
0915:                   I = ISAMAX( N, WORK, 1 )
0916:                   VALUE = WORK( I-1 )
0917:                END IF
0918:             END IF
0919:          END IF
0920:       ELSE IF( ( LSAME( NORM, 'F' ) ) .OR. ( LSAME( NORM, 'E' ) ) ) THEN
0921: *
0922: *       Find normF(A).
0923: *
0924:          K = ( N+1 ) / 2
0925:          SCALE = ZERO
0926:          S = ONE
0927:          IF( NOE.EQ.1 ) THEN
0928: *           n is odd
0929:             IF( IFM.EQ.1 ) THEN
0930: *              A is normal & A is n by k
0931:                IF( ILU.EQ.0 ) THEN
0932: *                 A is upper
0933:                   DO J = 0, K - 3
0934:                      CALL CLASSQ( K-J-2, A( K+J+1+J*LDA ), 1, SCALE, S )
0935: *                    L at A(k,0)
0936:                   END DO
0937:                   DO J = 0, K - 1
0938:                      CALL CLASSQ( K+J-1, A( 0+J*LDA ), 1, SCALE, S )
0939: *                    trap U at A(0,0)
0940:                   END DO
0941:                   S = S + S
0942: *                 double s for the off diagonal elements
0943:                   L = K - 1
0944: *                 -> U(k,k) at A(k-1,0)
0945:                   DO I = 0, K - 2
0946:                      AA = REAL( A( L ) )
0947: *                    U(k+i,k+i)
0948:                      IF( AA.NE.ZERO ) THEN
0949:                         IF( SCALE.LT.AA ) THEN
0950:                            S = ONE + S*( SCALE / AA )**2
0951:                            SCALE = AA
0952:                         ELSE
0953:                            S = S + ( AA / SCALE )**2
0954:                         END IF
0955:                      END IF
0956:                      AA = REAL( A( L+1 ) )
0957: *                    U(i,i)
0958:                      IF( AA.NE.ZERO ) THEN
0959:                         IF( SCALE.LT.AA ) THEN
0960:                            S = ONE + S*( SCALE / AA )**2
0961:                            SCALE = AA
0962:                         ELSE
0963:                            S = S + ( AA / SCALE )**2
0964:                         END IF
0965:                      END IF
0966:                      L = L + LDA + 1
0967:                   END DO
0968:                   AA = REAL( A( L ) )
0969: *                 U(n-1,n-1)
0970:                   IF( AA.NE.ZERO ) THEN
0971:                      IF( SCALE.LT.AA ) THEN
0972:                         S = ONE + S*( SCALE / AA )**2
0973:                         SCALE = AA
0974:                      ELSE
0975:                         S = S + ( AA / SCALE )**2
0976:                      END IF
0977:                   END IF
0978:                ELSE
0979: *                 ilu=1 & A is lower
0980:                   DO J = 0, K - 1
0981:                      CALL CLASSQ( N-J-1, A( J+1+J*LDA ), 1, SCALE, S )
0982: *                    trap L at A(0,0)
0983:                   END DO
0984:                   DO J = 1, K - 2
0985:                      CALL CLASSQ( J, A( 0+( 1+J )*LDA ), 1, SCALE, S )
0986: *                    U at A(0,1)
0987:                   END DO
0988:                   S = S + S
0989: *                 double s for the off diagonal elements
0990:                   AA = REAL( A( 0 ) )
0991: *                 L(0,0) at A(0,0)
0992:                   IF( AA.NE.ZERO ) THEN
0993:                      IF( SCALE.LT.AA ) THEN
0994:                         S = ONE + S*( SCALE / AA )**2
0995:                         SCALE = AA
0996:                      ELSE
0997:                         S = S + ( AA / SCALE )**2
0998:                      END IF
0999:                   END IF
1000:                   L = LDA
1001: *                 -> L(k,k) at A(0,1)
1002:                   DO I = 1, K - 1
1003:                      AA = REAL( A( L ) )
1004: *                    L(k-1+i,k-1+i)
1005:                      IF( AA.NE.ZERO ) THEN
1006:                         IF( SCALE.LT.AA ) THEN
1007:                            S = ONE + S*( SCALE / AA )**2
1008:                            SCALE = AA
1009:                         ELSE
1010:                            S = S + ( AA / SCALE )**2
1011:                         END IF
1012:                      END IF
1013:                      AA = REAL( A( L+1 ) )
1014: *                    L(i,i)
1015:                      IF( AA.NE.ZERO ) THEN
1016:                         IF( SCALE.LT.AA ) THEN
1017:                            S = ONE + S*( SCALE / AA )**2
1018:                            SCALE = AA
1019:                         ELSE
1020:                            S = S + ( AA / SCALE )**2
1021:                         END IF
1022:                      END IF
1023:                      L = L + LDA + 1
1024:                   END DO
1025:                END IF
1026:             ELSE
1027: *              A is xpose & A is k by n
1028:                IF( ILU.EQ.0 ) THEN
1029: *                 A' is upper
1030:                   DO J = 1, K - 2
1031:                      CALL CLASSQ( J, A( 0+( K+J )*LDA ), 1, SCALE, S )
1032: *                    U at A(0,k)
1033:                   END DO
1034:                   DO J = 0, K - 2
1035:                      CALL CLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
1036: *                    k by k-1 rect. at A(0,0)
1037:                   END DO
1038:                   DO J = 0, K - 2
1039:                      CALL CLASSQ( K-J-1, A( J+1+( J+K-1 )*LDA ), 1,
1040:      +                            SCALE, S )
1041: *                    L at A(0,k-1)
1042:                   END DO
1043:                   S = S + S
1044: *                 double s for the off diagonal elements
1045:                   L = 0 + K*LDA - LDA
1046: *                 -> U(k-1,k-1) at A(0,k-1)
1047:                   AA = REAL( A( L ) )
1048: *                 U(k-1,k-1)
1049:                   IF( AA.NE.ZERO ) THEN
1050:                      IF( SCALE.LT.AA ) THEN
1051:                         S = ONE + S*( SCALE / AA )**2
1052:                         SCALE = AA
1053:                      ELSE
1054:                         S = S + ( AA / SCALE )**2
1055:                      END IF
1056:                   END IF
1057:                   L = L + LDA
1058: *                 -> U(0,0) at A(0,k)
1059:                   DO J = K, N - 1
1060:                      AA = REAL( A( L ) )
1061: *                    -> U(j-k,j-k)
1062:                      IF( AA.NE.ZERO ) THEN
1063:                         IF( SCALE.LT.AA ) THEN
1064:                            S = ONE + S*( SCALE / AA )**2
1065:                            SCALE = AA
1066:                         ELSE
1067:                            S = S + ( AA / SCALE )**2
1068:                         END IF
1069:                      END IF
1070:                      AA = REAL( A( L+1 ) )
1071: *                    -> U(j,j)
1072:                      IF( AA.NE.ZERO ) THEN
1073:                         IF( SCALE.LT.AA ) THEN
1074:                            S = ONE + S*( SCALE / AA )**2
1075:                            SCALE = AA
1076:                         ELSE
1077:                            S = S + ( AA / SCALE )**2
1078:                         END IF
1079:                      END IF
1080:                      L = L + LDA + 1
1081:                   END DO
1082:                ELSE
1083: *                 A' is lower
1084:                   DO J = 1, K - 1
1085:                      CALL CLASSQ( J, A( 0+J*LDA ), 1, SCALE, S )
1086: *                    U at A(0,0)
1087:                   END DO
1088:                   DO J = K, N - 1
1089:                      CALL CLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
1090: *                    k by k-1 rect. at A(0,k)
1091:                   END DO
1092:                   DO J = 0, K - 3
1093:                      CALL CLASSQ( K-J-2, A( J+2+J*LDA ), 1, SCALE, S )
1094: *                    L at A(1,0)
1095:                   END DO
1096:                   S = S + S
1097: *                 double s for the off diagonal elements
1098:                   L = 0
1099: *                 -> L(0,0) at A(0,0)
1100:                   DO I = 0, K - 2
1101:                      AA = REAL( A( L ) )
1102: *                    L(i,i)
1103:                      IF( AA.NE.ZERO ) THEN
1104:                         IF( SCALE.LT.AA ) THEN
1105:                            S = ONE + S*( SCALE / AA )**2
1106:                            SCALE = AA
1107:                         ELSE
1108:                            S = S + ( AA / SCALE )**2
1109:                         END IF
1110:                      END IF
1111:                      AA = REAL( A( L+1 ) )
1112: *                    L(k+i,k+i)
1113:                      IF( AA.NE.ZERO ) THEN
1114:                         IF( SCALE.LT.AA ) THEN
1115:                            S = ONE + S*( SCALE / AA )**2
1116:                            SCALE = AA
1117:                         ELSE
1118:                            S = S + ( AA / SCALE )**2
1119:                         END IF
1120:                      END IF
1121:                      L = L + LDA + 1
1122:                   END DO
1123: *                 L-> k-1 + (k-1)*lda or L(k-1,k-1) at A(k-1,k-1)
1124:                   AA = REAL( A( L ) )
1125: *                 L(k-1,k-1) at A(k-1,k-1)
1126:                   IF( AA.NE.ZERO ) THEN
1127:                      IF( SCALE.LT.AA ) THEN
1128:                         S = ONE + S*( SCALE / AA )**2
1129:                         SCALE = AA
1130:                      ELSE
1131:                         S = S + ( AA / SCALE )**2
1132:                      END IF
1133:                   END IF
1134:                END IF
1135:             END IF
1136:          ELSE
1137: *           n is even
1138:             IF( IFM.EQ.1 ) THEN
1139: *              A is normal
1140:                IF( ILU.EQ.0 ) THEN
1141: *                 A is upper
1142:                   DO J = 0, K - 2
1143:                      CALL CLASSQ( K-J-1, A( K+J+2+J*LDA ), 1, SCALE, S )
1144: *                 L at A(k+1,0)
1145:                   END DO
1146:                   DO J = 0, K - 1
1147:                      CALL CLASSQ( K+J, A( 0+J*LDA ), 1, SCALE, S )
1148: *                 trap U at A(0,0)
1149:                   END DO
1150:                   S = S + S
1151: *                 double s for the off diagonal elements
1152:                   L = K
1153: *                 -> U(k,k) at A(k,0)
1154:                   DO I = 0, K - 1
1155:                      AA = REAL( A( L ) )
1156: *                    U(k+i,k+i)
1157:                      IF( AA.NE.ZERO ) THEN
1158:                         IF( SCALE.LT.AA ) THEN
1159:                            S = ONE + S*( SCALE / AA )**2
1160:                            SCALE = AA
1161:                         ELSE
1162:                            S = S + ( AA / SCALE )**2
1163:                         END IF
1164:                      END IF
1165:                      AA = REAL( A( L+1 ) )
1166: *                    U(i,i)
1167:                      IF( AA.NE.ZERO ) THEN
1168:                         IF( SCALE.LT.AA ) THEN
1169:                            S = ONE + S*( SCALE / AA )**2
1170:                            SCALE = AA
1171:                         ELSE
1172:                            S = S + ( AA / SCALE )**2
1173:                         END IF
1174:                      END IF
1175:                      L = L + LDA + 1
1176:                   END DO
1177:                ELSE
1178: *                 ilu=1 & A is lower
1179:                   DO J = 0, K - 1
1180:                      CALL CLASSQ( N-J-1, A( J+2+J*LDA ), 1, SCALE, S )
1181: *                    trap L at A(1,0)
1182:                   END DO
1183:                   DO J = 1, K - 1
1184:                      CALL CLASSQ( J, A( 0+J*LDA ), 1, SCALE, S )
1185: *                    U at A(0,0)
1186:                   END DO
1187:                   S = S + S
1188: *                 double s for the off diagonal elements
1189:                   L = 0
1190: *                 -> L(k,k) at A(0,0)
1191:                   DO I = 0, K - 1
1192:                      AA = REAL( A( L ) )
1193: *                    L(k-1+i,k-1+i)
1194:                      IF( AA.NE.ZERO ) THEN
1195:                         IF( SCALE.LT.AA ) THEN
1196:                            S = ONE + S*( SCALE / AA )**2
1197:                            SCALE = AA
1198:                         ELSE
1199:                            S = S + ( AA / SCALE )**2
1200:                         END IF
1201:                      END IF
1202:                      AA = REAL( A( L+1 ) )
1203: *                    L(i,i)
1204:                      IF( AA.NE.ZERO ) THEN
1205:                         IF( SCALE.LT.AA ) THEN
1206:                            S = ONE + S*( SCALE / AA )**2
1207:                            SCALE = AA
1208:                         ELSE
1209:                            S = S + ( AA / SCALE )**2
1210:                         END IF
1211:                      END IF
1212:                      L = L + LDA + 1
1213:                   END DO
1214:                END IF
1215:             ELSE
1216: *              A is xpose
1217:                IF( ILU.EQ.0 ) THEN
1218: *                 A' is upper
1219:                   DO J = 1, K - 1
1220:                      CALL CLASSQ( J, A( 0+( K+1+J )*LDA ), 1, SCALE, S )
1221: *                 U at A(0,k+1)
1222:                   END DO
1223:                   DO J = 0, K - 1
1224:                      CALL CLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
1225: *                 k by k rect. at A(0,0)
1226:                   END DO
1227:                   DO J = 0, K - 2
1228:                      CALL CLASSQ( K-J-1, A( J+1+( J+K )*LDA ), 1, SCALE,
1229:      +                            S )
1230: *                 L at A(0,k)
1231:                   END DO
1232:                   S = S + S
1233: *                 double s for the off diagonal elements
1234:                   L = 0 + K*LDA
1235: *                 -> U(k,k) at A(0,k)
1236:                   AA = REAL( A( L ) )
1237: *                 U(k,k)
1238:                   IF( AA.NE.ZERO ) THEN
1239:                      IF( SCALE.LT.AA ) THEN
1240:                         S = ONE + S*( SCALE / AA )**2
1241:                         SCALE = AA
1242:                      ELSE
1243:                         S = S + ( AA / SCALE )**2
1244:                      END IF
1245:                   END IF
1246:                   L = L + LDA
1247: *                 -> U(0,0) at A(0,k+1)
1248:                   DO J = K + 1, N - 1
1249:                      AA = REAL( A( L ) )
1250: *                    -> U(j-k-1,j-k-1)
1251:                      IF( AA.NE.ZERO ) THEN
1252:                         IF( SCALE.LT.AA ) THEN
1253:                            S = ONE + S*( SCALE / AA )**2
1254:                            SCALE = AA
1255:                         ELSE
1256:                            S = S + ( AA / SCALE )**2
1257:                         END IF
1258:                      END IF
1259:                      AA = REAL( A( L+1 ) )
1260: *                    -> U(j,j)
1261:                      IF( AA.NE.ZERO ) THEN
1262:                         IF( SCALE.LT.AA ) THEN
1263:                            S = ONE + S*( SCALE / AA )**2
1264:                            SCALE = AA
1265:                         ELSE
1266:                            S = S + ( AA / SCALE )**2
1267:                         END IF
1268:                      END IF
1269:                      L = L + LDA + 1
1270:                   END DO
1271: *                 L=k-1+n*lda
1272: *                 -> U(k-1,k-1) at A(k-1,n)
1273:                   AA = REAL( A( L ) )
1274: *                 U(k,k)
1275:                   IF( AA.NE.ZERO ) THEN
1276:                      IF( SCALE.LT.AA ) THEN
1277:                         S = ONE + S*( SCALE / AA )**2
1278:                         SCALE = AA
1279:                      ELSE
1280:                         S = S + ( AA / SCALE )**2
1281:                      END IF
1282:                   END IF
1283:                ELSE
1284: *                 A' is lower
1285:                   DO J = 1, K - 1
1286:                      CALL CLASSQ( J, A( 0+( J+1 )*LDA ), 1, SCALE, S )
1287: *                 U at A(0,1)
1288:                   END DO
1289:                   DO J = K + 1, N
1290:                      CALL CLASSQ( K, A( 0+J*LDA ), 1, SCALE, S )
1291: *                 k by k rect. at A(0,k+1)
1292:                   END DO
1293:                   DO J = 0, K - 2
1294:                      CALL CLASSQ( K-J-1, A( J+1+J*LDA ), 1, SCALE, S )
1295: *                 L at A(0,0)
1296:                   END DO
1297:                   S = S + S
1298: *                 double s for the off diagonal elements
1299:                   L = 0
1300: *                 -> L(k,k) at A(0,0)
1301:                   AA = REAL( A( L ) )
1302: *                 L(k,k) at A(0,0)
1303:                   IF( AA.NE.ZERO ) THEN
1304:                      IF( SCALE.LT.AA ) THEN
1305:                         S = ONE + S*( SCALE / AA )**2
1306:                         SCALE = AA
1307:                      ELSE
1308:                         S = S + ( AA / SCALE )**2
1309:                      END IF
1310:                   END IF
1311:                   L = LDA
1312: *                 -> L(0,0) at A(0,1)
1313:                   DO I = 0, K - 2
1314:                      AA = REAL( A( L ) )
1315: *                    L(i,i)
1316:                      IF( AA.NE.ZERO ) THEN
1317:                         IF( SCALE.LT.AA ) THEN
1318:                            S = ONE + S*( SCALE / AA )**2
1319:                            SCALE = AA
1320:                         ELSE
1321:                            S = S + ( AA / SCALE )**2
1322:                         END IF
1323:                      END IF
1324:                      AA = REAL( A( L+1 ) )
1325: *                    L(k+i+1,k+i+1)
1326:                      IF( AA.NE.ZERO ) THEN
1327:                         IF( SCALE.LT.AA ) THEN
1328:                            S = ONE + S*( SCALE / AA )**2
1329:                            SCALE = AA
1330:                         ELSE
1331:                            S = S + ( AA / SCALE )**2
1332:                         END IF
1333:                      END IF
1334:                      L = L + LDA + 1
1335:                   END DO
1336: *                 L-> k - 1 + k*lda or L(k-1,k-1) at A(k-1,k)
1337:                   AA = REAL( A( L ) )
1338: *                 L(k-1,k-1) at A(k-1,k)
1339:                   IF( AA.NE.ZERO ) THEN
1340:                      IF( SCALE.LT.AA ) THEN
1341:                         S = ONE + S*( SCALE / AA )**2
1342:                         SCALE = AA
1343:                      ELSE
1344:                         S = S + ( AA / SCALE )**2
1345:                      END IF
1346:                   END IF
1347:                END IF
1348:             END IF
1349:          END IF
1350:          VALUE = SCALE*SQRT( S )
1351:       END IF
1352: *
1353:       CLANHF = VALUE
1354:       RETURN
1355: *
1356: *     End of CLANHF
1357: *
1358:       END
1359: ```