1*> \brief \b DCHKBL
2*
3*  =========== DOCUMENTATION ===========
4*
5* Online html documentation available at
6*            http://www.netlib.org/lapack/explore-html/
7*
8*  Definition:
9*  ===========
10*
11*       SUBROUTINE DCHKBL( NIN, NOUT )
12*
13*       .. Scalar Arguments ..
14*       INTEGER            NIN, NOUT
15*       ..
16*
17*
18*> \par Purpose:
19*  =============
20*>
21*> \verbatim
22*>
23*> DCHKBL tests DGEBAL, a routine for balancing a general real
24*> matrix and isolating some of its eigenvalues.
25*> \endverbatim
26*
27*  Arguments:
28*  ==========
29*
30*> \param[in] NIN
31*> \verbatim
32*>          NIN is INTEGER
33*>          The logical unit number for input.  NIN > 0.
34*> \endverbatim
35*>
36*> \param[in] NOUT
37*> \verbatim
38*>          NOUT is INTEGER
39*>          The logical unit number for output.  NOUT > 0.
40*> \endverbatim
41*
42*  Authors:
43*  ========
44*
45*> \author Univ. of Tennessee
46*> \author Univ. of California Berkeley
47*> \author Univ. of Colorado Denver
48*> \author NAG Ltd.
49*
50*> \date November 2011
51*
52*> \ingroup double_eig
53*
54*  =====================================================================
55      SUBROUTINE DCHKBL( NIN, NOUT )
56*
57*  -- LAPACK test routine (version 3.4.0) --
58*  -- LAPACK is a software package provided by Univ. of Tennessee,    --
59*  -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
60*     November 2011
61*
62*     .. Scalar Arguments ..
63      INTEGER            NIN, NOUT
64*     ..
65*
66* ======================================================================
67*
68*     .. Parameters ..
69      INTEGER            LDA
70      PARAMETER          ( LDA = 20 )
71      DOUBLE PRECISION   ZERO
72      PARAMETER          ( ZERO = 0.0D+0 )
73*     ..
74*     .. Local Scalars ..
75      INTEGER            I, IHI, IHIIN, ILO, ILOIN, INFO, J, KNT, N,
76     $                   NINFO
77      DOUBLE PRECISION   ANORM, MEPS, RMAX, SFMIN, TEMP, VMAX
78*     ..
79*     .. Local Arrays ..
80      INTEGER            LMAX( 3 )
81      DOUBLE PRECISION   A( LDA, LDA ), AIN( LDA, LDA ), DUMMY( 1 ),
82     $                   SCALE( LDA ), SCALIN( LDA )
83*     ..
84*     .. External Functions ..
85      DOUBLE PRECISION   DLAMCH, DLANGE
86      EXTERNAL           DLAMCH, DLANGE
87*     ..
88*     .. External Subroutines ..
89      EXTERNAL           DGEBAL
90*     ..
91*     .. Intrinsic Functions ..
92      INTRINSIC          ABS, MAX
93*     ..
94*     .. Executable Statements ..
95*
96      LMAX( 1 ) = 0
97      LMAX( 2 ) = 0
98      LMAX( 3 ) = 0
99      NINFO = 0
100      KNT = 0
101      RMAX = ZERO
102      VMAX = ZERO
103      SFMIN = DLAMCH( 'S' )
104      MEPS = DLAMCH( 'E' )
105*
106   10 CONTINUE
107*
108      READ( NIN, FMT = * )N
109      IF( N.EQ.0 )
110     $   GO TO 70
111      DO 20 I = 1, N
112         READ( NIN, FMT = * )( A( I, J ), J = 1, N )
113   20 CONTINUE
114*
115      READ( NIN, FMT = * )ILOIN, IHIIN
116      DO 30 I = 1, N
117         READ( NIN, FMT = * )( AIN( I, J ), J = 1, N )
118   30 CONTINUE
119      READ( NIN, FMT = * )( SCALIN( I ), I = 1, N )
120*
121      ANORM = DLANGE( 'M', N, N, A, LDA, DUMMY )
122      KNT = KNT + 1
123*
124      CALL DGEBAL( 'B', N, A, LDA, ILO, IHI, SCALE, INFO )
125*
126      IF( INFO.NE.0 ) THEN
127         NINFO = NINFO + 1
128         LMAX( 1 ) = KNT
129      END IF
130*
131      IF( ILO.NE.ILOIN .OR. IHI.NE.IHIIN ) THEN
132         NINFO = NINFO + 1
133         LMAX( 2 ) = KNT
134      END IF
135*
136      DO 50 I = 1, N
137         DO 40 J = 1, N
138            TEMP = MAX( A( I, J ), AIN( I, J ) )
139            TEMP = MAX( TEMP, SFMIN )
140            VMAX = MAX( VMAX, ABS( A( I, J )-AIN( I, J ) ) / TEMP )
141   40    CONTINUE
142   50 CONTINUE
143*
144      DO 60 I = 1, N
145         TEMP = MAX( SCALE( I ), SCALIN( I ) )
146         TEMP = MAX( TEMP, SFMIN )
147         VMAX = MAX( VMAX, ABS( SCALE( I )-SCALIN( I ) ) / TEMP )
148   60 CONTINUE
149*
150*
151      IF( VMAX.GT.RMAX ) THEN
152         LMAX( 3 ) = KNT
153         RMAX = VMAX
154      END IF
155*
156      GO TO 10
157*
158   70 CONTINUE
159*
160      WRITE( NOUT, FMT = 9999 )
161 9999 FORMAT( 1X, '.. test output of DGEBAL .. ' )
162*
163      WRITE( NOUT, FMT = 9998 )RMAX
164 9998 FORMAT( 1X, 'value of largest test error            = ', D12.3 )
165      WRITE( NOUT, FMT = 9997 )LMAX( 1 )
166 9997 FORMAT( 1X, 'example number where info is not zero  = ', I4 )
167      WRITE( NOUT, FMT = 9996 )LMAX( 2 )
168 9996 FORMAT( 1X, 'example number where ILO or IHI wrong  = ', I4 )
169      WRITE( NOUT, FMT = 9995 )LMAX( 3 )
170 9995 FORMAT( 1X, 'example number having largest error    = ', I4 )
171      WRITE( NOUT, FMT = 9994 )NINFO
172 9994 FORMAT( 1X, 'number of examples where info is not 0 = ', I4 )
173      WRITE( NOUT, FMT = 9993 )KNT
174 9993 FORMAT( 1X, 'total number of examples tested        = ', I4 )
175*
176      RETURN
177*
178*     End of DCHKBL
179*
180      END
181