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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
*> \brief \b SCHKGK
*
* =========== DOCUMENTATION ===========
*
* Online html documentation available at
* http://www.netlib.org/lapack/explore-html/
*
* Definition:
* ===========
*
* SUBROUTINE SCHKGK( NIN, NOUT )
*
* .. Scalar Arguments ..
* INTEGER NIN, NOUT
* ..
*
*
*> \par Purpose:
* =============
*>
*> \verbatim
*>
*> SCHKGK tests SGGBAK, a routine for backward balancing of
*> a matrix pair (A, B).
*> \endverbatim
*
* Arguments:
* ==========
*
*> \param[in] NIN
*> \verbatim
*> NIN is INTEGER
*> The logical unit number for input. NIN > 0.
*> \endverbatim
*>
*> \param[in] NOUT
*> \verbatim
*> NOUT is INTEGER
*> The logical unit number for output. NOUT > 0.
*> \endverbatim
*
* Authors:
* ========
*
*> \author Univ. of Tennessee
*> \author Univ. of California Berkeley
*> \author Univ. of Colorado Denver
*> \author NAG Ltd.
*
*> \date November 2011
*
*> \ingroup single_eig
*
* =====================================================================
SUBROUTINE SCHKGK( NIN, NOUT )
*
* -- LAPACK test routine (version 3.4.0) --
* -- LAPACK is a software package provided by Univ. of Tennessee, --
* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
* November 2011
*
* .. Scalar Arguments ..
INTEGER NIN, NOUT
* ..
*
* =====================================================================
*
* .. Parameters ..
INTEGER LDA, LDB, LDVL, LDVR
PARAMETER ( LDA = 50, LDB = 50, LDVL = 50, LDVR = 50 )
INTEGER LDE, LDF, LDWORK
PARAMETER ( LDE = 50, LDF = 50, LDWORK = 50 )
REAL ZERO, ONE
PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
* ..
* .. Local Scalars ..
INTEGER I, IHI, ILO, INFO, J, KNT, M, N, NINFO
REAL ANORM, BNORM, EPS, RMAX, VMAX
* ..
* .. Local Arrays ..
INTEGER LMAX( 4 )
REAL A( LDA, LDA ), AF( LDA, LDA ), B( LDB, LDB ),
$ BF( LDB, LDB ), E( LDE, LDE ), F( LDF, LDF ),
$ LSCALE( LDA ), RSCALE( LDA ), VL( LDVL, LDVL ),
$ VLF( LDVL, LDVL ), VR( LDVR, LDVR ),
$ VRF( LDVR, LDVR ), WORK( LDWORK, LDWORK )
* ..
* .. External Functions ..
REAL SLAMCH, SLANGE
EXTERNAL SLAMCH, SLANGE
* ..
* .. External Subroutines ..
EXTERNAL SGEMM, SGGBAK, SGGBAL, SLACPY
* ..
* .. Intrinsic Functions ..
INTRINSIC ABS, MAX
* ..
* .. Executable Statements ..
*
* Initialization
*
LMAX( 1 ) = 0
LMAX( 2 ) = 0
LMAX( 3 ) = 0
LMAX( 4 ) = 0
NINFO = 0
KNT = 0
RMAX = ZERO
*
EPS = SLAMCH( 'Precision' )
*
10 CONTINUE
READ( NIN, FMT = * )N, M
IF( N.EQ.0 )
$ GO TO 100
*
DO 20 I = 1, N
READ( NIN, FMT = * )( A( I, J ), J = 1, N )
20 CONTINUE
*
DO 30 I = 1, N
READ( NIN, FMT = * )( B( I, J ), J = 1, N )
30 CONTINUE
*
DO 40 I = 1, N
READ( NIN, FMT = * )( VL( I, J ), J = 1, M )
40 CONTINUE
*
DO 50 I = 1, N
READ( NIN, FMT = * )( VR( I, J ), J = 1, M )
50 CONTINUE
*
KNT = KNT + 1
*
ANORM = SLANGE( 'M', N, N, A, LDA, WORK )
BNORM = SLANGE( 'M', N, N, B, LDB, WORK )
*
CALL SLACPY( 'FULL', N, N, A, LDA, AF, LDA )
CALL SLACPY( 'FULL', N, N, B, LDB, BF, LDB )
*
CALL SGGBAL( 'B', N, A, LDA, B, LDB, ILO, IHI, LSCALE, RSCALE,
$ WORK, INFO )
IF( INFO.NE.0 ) THEN
NINFO = NINFO + 1
LMAX( 1 ) = KNT
END IF
*
CALL SLACPY( 'FULL', N, M, VL, LDVL, VLF, LDVL )
CALL SLACPY( 'FULL', N, M, VR, LDVR, VRF, LDVR )
*
CALL SGGBAK( 'B', 'L', N, ILO, IHI, LSCALE, RSCALE, M, VL, LDVL,
$ INFO )
IF( INFO.NE.0 ) THEN
NINFO = NINFO + 1
LMAX( 2 ) = KNT
END IF
*
CALL SGGBAK( 'B', 'R', N, ILO, IHI, LSCALE, RSCALE, M, VR, LDVR,
$ INFO )
IF( INFO.NE.0 ) THEN
NINFO = NINFO + 1
LMAX( 3 ) = KNT
END IF
*
* Test of SGGBAK
*
* Check tilde(VL)'*A*tilde(VR) - VL'*tilde(A)*VR
* where tilde(A) denotes the transformed matrix.
*
CALL SGEMM( 'N', 'N', N, M, N, ONE, AF, LDA, VR, LDVR, ZERO, WORK,
$ LDWORK )
CALL SGEMM( 'T', 'N', M, M, N, ONE, VL, LDVL, WORK, LDWORK, ZERO,
$ E, LDE )
*
CALL SGEMM( 'N', 'N', N, M, N, ONE, A, LDA, VRF, LDVR, ZERO, WORK,
$ LDWORK )
CALL SGEMM( 'T', 'N', M, M, N, ONE, VLF, LDVL, WORK, LDWORK, ZERO,
$ F, LDF )
*
VMAX = ZERO
DO 70 J = 1, M
DO 60 I = 1, M
VMAX = MAX( VMAX, ABS( E( I, J )-F( I, J ) ) )
60 CONTINUE
70 CONTINUE
VMAX = VMAX / ( EPS*MAX( ANORM, BNORM ) )
IF( VMAX.GT.RMAX ) THEN
LMAX( 4 ) = KNT
RMAX = VMAX
END IF
*
* Check tilde(VL)'*B*tilde(VR) - VL'*tilde(B)*VR
*
CALL SGEMM( 'N', 'N', N, M, N, ONE, BF, LDB, VR, LDVR, ZERO, WORK,
$ LDWORK )
CALL SGEMM( 'T', 'N', M, M, N, ONE, VL, LDVL, WORK, LDWORK, ZERO,
$ E, LDE )
*
CALL SGEMM( 'N', 'N', N, M, N, ONE, B, LDB, VRF, LDVR, ZERO, WORK,
$ LDWORK )
CALL SGEMM( 'T', 'N', M, M, N, ONE, VLF, LDVL, WORK, LDWORK, ZERO,
$ F, LDF )
*
VMAX = ZERO
DO 90 J = 1, M
DO 80 I = 1, M
VMAX = MAX( VMAX, ABS( E( I, J )-F( I, J ) ) )
80 CONTINUE
90 CONTINUE
VMAX = VMAX / ( EPS*MAX( ANORM, BNORM ) )
IF( VMAX.GT.RMAX ) THEN
LMAX( 4 ) = KNT
RMAX = VMAX
END IF
*
GO TO 10
*
100 CONTINUE
*
WRITE( NOUT, FMT = 9999 )
9999 FORMAT( 1X, '.. test output of SGGBAK .. ' )
*
WRITE( NOUT, FMT = 9998 )RMAX
9998 FORMAT( ' value of largest test error =', E12.3 )
WRITE( NOUT, FMT = 9997 )LMAX( 1 )
9997 FORMAT( ' example number where SGGBAL info is not 0 =', I4 )
WRITE( NOUT, FMT = 9996 )LMAX( 2 )
9996 FORMAT( ' example number where SGGBAK(L) info is not 0 =', I4 )
WRITE( NOUT, FMT = 9995 )LMAX( 3 )
9995 FORMAT( ' example number where SGGBAK(R) info is not 0 =', I4 )
WRITE( NOUT, FMT = 9994 )LMAX( 4 )
9994 FORMAT( ' example number having largest error =', I4 )
WRITE( NOUT, FMT = 9992 )NINFO
9992 FORMAT( ' number of examples where info is not 0 =', I4 )
WRITE( NOUT, FMT = 9991 )KNT
9991 FORMAT( ' total number of examples tested =', I4 )
*
RETURN
*
* End of SCHKGK
*
END
|