1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      29
      30
      31
      32
      33
      34
      35
      36
      37
      38
      39
      40
      41
      42
      43
      44
      45
      46
      47
      48
      49
      50
      51
      52
      53
      54
      55
      56
      57
      58
      59
      60
      61
      62
      63
      64
      65
      66
      67
      68
      69
      70
      71
      72
      73
      74
      75
      76
      77
      78
      79
      80
      81
      82
      83
      84
      85
      86
      87
      88
      89
      90
      91
      92
      93
      94
      95
      96
      97
      98
      99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     123
     124
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
      SUBROUTINE SGBT01MNKLKUALDAAFACLDAFACIPIVWORK,
     $                   RESID )
*
*  -- LAPACK test routine (version 3.1) --
*     Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
*     November 2006
*
*     .. Scalar Arguments ..
      INTEGER            KLKULDALDAFACMN
      REAL               RESID
*     ..
*     .. Array Arguments ..
      INTEGER            IPIV* )
      REAL               ALDA* ), AFACLDAFAC* ), WORK* )
*     ..
*
*  Purpose
*  =======
*
*  SGBT01 reconstructs a band matrix  A  from its L*U factorization and
*  computes the residual:
*     norm(L*U - A) / ( N * norm(A) * EPS ),
*  where EPS is the machine epsilon.
*
*  The expression L*U - A is computed one column at a time, so A and
*  AFAC are not modified.
*
*  Arguments
*  =========
*
*  M       (input) INTEGER
*          The number of rows of the matrix A.  M >= 0.
*
*  N       (input) INTEGER
*          The number of columns of the matrix A.  N >= 0.
*
*  KL      (input) INTEGER
*          The number of subdiagonals within the band of A.  KL >= 0.
*
*  KU      (input) INTEGER
*          The number of superdiagonals within the band of A.  KU >= 0.
*
*  A       (input/output) REAL array, dimension (LDA,N)
*          The original matrix A in band storage, stored in rows 1 to
*          KL+KU+1.
*
*  LDA     (input) INTEGER.
*          The leading dimension of the array A.  LDA >= max(1,KL+KU+1).
*
*  AFAC    (input) REAL array, dimension (LDAFAC,N)
*          The factored form of the matrix A.  AFAC contains the banded
*          factors L and U from the L*U factorization, as computed by
*          SGBTRF.  U is stored as an upper triangular band matrix with
*          KL+KU superdiagonals in rows 1 to KL+KU+1, and the
*          multipliers used during the factorization are stored in rows
*          KL+KU+2 to 2*KL+KU+1.  See SGBTRF for further details.
*
*  LDAFAC  (input) INTEGER
*          The leading dimension of the array AFAC.
*          LDAFAC >= max(1,2*KL*KU+1).
*
*  IPIV    (input) INTEGER array, dimension (min(M,N))
*          The pivot indices from SGBTRF.
*
*  WORK    (workspace) REAL array, dimension (2*KL+KU+1)
*
*  RESID   (output) REAL
*          norm(L*U - A) / ( N * norm(A) * EPS )
*
*  =====================================================================
*
*     .. Parameters ..
      REAL               ZEROONE
      PARAMETER          ( ZERO = 0.0E+0ONE = 1.0E+0 )
*     ..
*     .. Local Scalars ..
      INTEGER            II1I2ILIPIWJJLJUJUAKDLENJ
      REAL               ANORMEPST
*     ..
*     .. External Functions ..
      REAL               SASUMSLAMCH
      EXTERNAL           SASUMSLAMCH
*     ..
*     .. External Subroutines ..
      EXTERNAL           SAXPYSCOPY
*     ..
*     .. Intrinsic Functions ..
      INTRINSIC          MAXMINREAL
*     ..
*     .. Executable Statements ..
*
*     Quick exit if M = 0 or N = 0.
*
      RESID = ZERO
      IFM.LE.0 .OR. N.LE.0 )
     $   RETURN
*
*     Determine EPS and the norm of A.
*
      EPS = SLAMCH'Epsilon' )
      KD = KU + 1
      ANORM = ZERO
      DO 10 J = 1N
         I1 = MAXKD+1-J1 )
         I2 = MINKD+M-JKL+KD )
         IFI2.GE.I1 )
     $      ANORM = MAXANORMSASUMI2-I1+1AI1J ), 1 ) )
   10 CONTINUE
*
*     Compute one column at a time of L*U - A.
*
      KD = KL + KU + 1
      DO 40 J = 1N
*
*        Copy the J-th column of U to WORK.
*
         JU = MINKL+KUJ-1 )
         JL = MINKLM-J )
         LENJ = MINMJ ) - J + JU + 1
         IFLENJ.GT.0 ) THEN
            CALL SCOPYLENJAFACKD-JUJ ), 1WORK1 )
            DO 20 I = LENJ + 1JU + JL + 1
               WORKI ) = ZERO
   20       CONTINUE
*
*           Multiply by the unit lower triangular matrix L.  Note that L
*           is stored as a product of transformations and permutations.
*
            DO 30 I = MINM-1J ), J - JU-1
               IL = MINKLM-I )
               IFIL.GT.0 ) THEN
                  IW = I - J + JU + 1
                  T = WORKIW )
                  CALL SAXPYILTAFACKD+1I ), 1WORKIW+1 ),
     $                        1 )
                  IP = IPIVI )
                  IFI.NE.IP ) THEN
                     IP = IP - J + JU + 1
                     WORKIW ) = WORKIP )
                     WORKIP ) = T
                  END IF
               END IF
   30       CONTINUE
*
*           Subtract the corresponding column of A.
*
            JUA = MINJUKU )
            IFJUA+JL+1.GT.0 )
     $         CALL SAXPYJUA+JL+1-ONEAKU+1-JUAJ ), 1,
     $                     WORKJU+1-JUA ), 1 )
*
*           Compute the 1-norm of the column.
*
            RESID = MAXRESIDSASUMJU+JL+1WORK1 ) )
         END IF
   40 CONTINUE
*
*     Compute norm( L*U - A ) / ( N * norm(A) * EPS )
*
      IFANORM.LE.ZERO ) THEN
         IFRESID.NE.ZERO )
     $      RESID = ONE / EPS
      ELSE
         RESID = ( ( RESID / REALN ) ) / ANORM ) / EPS
      END IF
*
      RETURN
*
*     End of SGBT01
*
      END