LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches
zgbt02.f
Go to the documentation of this file.
1*> \brief \b ZGBT02
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 ZGBT02( TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B,
12* LDB, RWORK, RESID )
13*
14* .. Scalar Arguments ..
15* CHARACTER TRANS
16* INTEGER KL, KU, LDA, LDB, LDX, M, N, NRHS
17* DOUBLE PRECISION RESID
18* ..
19* .. Array Arguments ..
20* DOUBLE PRECISION RWORK( * )
21* COMPLEX*16 A( LDA, * ), B( LDB, * ), X( LDX, * )
22* ..
23*
24*
25*> \par Purpose:
26* =============
27*>
28*> \verbatim
29*>
30*> ZGBT02 computes the residual for a solution of a banded system of
31*> equations op(A)*X = B:
32*> RESID = norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ),
33*> where op(A) = A, A**T, or A**H, depending on TRANS, and EPS is the
34*> machine epsilon.
35*> \endverbatim
36*
37* Arguments:
38* ==========
39*
40*> \param[in] TRANS
41*> \verbatim
42*> TRANS is CHARACTER*1
43*> Specifies the form of the system of equations:
44*> = 'N': A * X = B (No transpose)
45*> = 'T': A**T * X = B (Transpose)
46*> = 'C': A**H * X = B (Conjugate transpose)
47*> \endverbatim
48*>
49*> \param[in] M
50*> \verbatim
51*> M is INTEGER
52*> The number of rows of the matrix A. M >= 0.
53*> \endverbatim
54*>
55*> \param[in] N
56*> \verbatim
57*> N is INTEGER
58*> The number of columns of the matrix A. N >= 0.
59*> \endverbatim
60*>
61*> \param[in] KL
62*> \verbatim
63*> KL is INTEGER
64*> The number of subdiagonals within the band of A. KL >= 0.
65*> \endverbatim
66*>
67*> \param[in] KU
68*> \verbatim
69*> KU is INTEGER
70*> The number of superdiagonals within the band of A. KU >= 0.
71*> \endverbatim
72*>
73*> \param[in] NRHS
74*> \verbatim
75*> NRHS is INTEGER
76*> The number of columns of B. NRHS >= 0.
77*> \endverbatim
78*>
79*> \param[in] A
80*> \verbatim
81*> A is COMPLEX*16 array, dimension (LDA,N)
82*> The original matrix A in band storage, stored in rows 1 to
83*> KL+KU+1.
84*> \endverbatim
85*>
86*> \param[in] LDA
87*> \verbatim
88*> LDA is INTEGER
89*> The leading dimension of the array A. LDA >= max(1,KL+KU+1).
90*> \endverbatim
91*>
92*> \param[in] X
93*> \verbatim
94*> X is COMPLEX*16 array, dimension (LDX,NRHS)
95*> The computed solution vectors for the system of linear
96*> equations.
97*> \endverbatim
98*>
99*> \param[in] LDX
100*> \verbatim
101*> LDX is INTEGER
102*> The leading dimension of the array X. If TRANS = 'N',
103*> LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
104*> \endverbatim
105*>
106*> \param[in,out] B
107*> \verbatim
108*> B is COMPLEX*16 array, dimension (LDB,NRHS)
109*> On entry, the right hand side vectors for the system of
110*> linear equations.
111*> On exit, B is overwritten with the difference B - A*X.
112*> \endverbatim
113*>
114*> \param[in] LDB
115*> \verbatim
116*> LDB is INTEGER
117*> The leading dimension of the array B. IF TRANS = 'N',
118*> LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
119*> \endverbatim
120*>
121*> \param[out] RWORK
122*> \verbatim
123*> RWORK is DOUBLE PRECISION array, dimension (MAX(1,LRWORK)),
124*> where LRWORK >= M when TRANS = 'T' or 'C'; otherwise, RWORK
125*> is not referenced.
126*> \endverbatim
127*
128*> \param[out] RESID
129*> \verbatim
130*> RESID is DOUBLE PRECISION
131*> The maximum over the number of right hand sides of
132*> norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ).
133*> \endverbatim
134*
135* Authors:
136* ========
137*
138*> \author Univ. of Tennessee
139*> \author Univ. of California Berkeley
140*> \author Univ. of Colorado Denver
141*> \author NAG Ltd.
142*
143*> \ingroup complex16_lin
144*
145* =====================================================================
146 SUBROUTINE zgbt02( TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B,
147 \$ LDB, RWORK, RESID )
148*
149* -- LAPACK test routine --
150* -- LAPACK is a software package provided by Univ. of Tennessee, --
151* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
152*
153* .. Scalar Arguments ..
154 CHARACTER TRANS
155 INTEGER KL, KU, LDA, LDB, LDX, M, N, NRHS
156 DOUBLE PRECISION RESID
157* ..
158* .. Array Arguments ..
159 DOUBLE PRECISION RWORK( * )
160 COMPLEX*16 A( LDA, * ), B( LDB, * ), X( LDX, * )
161* ..
162*
163* =====================================================================
164*
165* .. Parameters ..
166 DOUBLE PRECISION ZERO, ONE
167 parameter( zero = 0.0d+0, one = 1.0d+0 )
168 COMPLEX*16 CONE
169 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
170* ..
171* .. Local Scalars ..
172 INTEGER I1, I2, J, KD, N1
173 DOUBLE PRECISION ANORM, BNORM, EPS, TEMP, XNORM
174 COMPLEX*16 ZDUM
175* ..
176* .. External Functions ..
177 LOGICAL DISNAN, LSAME
178 DOUBLE PRECISION DLAMCH, DZASUM
179 EXTERNAL disnan, dlamch, dzasum, lsame
180* ..
181* .. External Subroutines ..
182 EXTERNAL zgbmv
183* ..
184* .. Statement Functions ..
185 DOUBLE PRECISION CABS1
186* ..
187* .. Intrinsic Functions ..
188 INTRINSIC abs, dble, dimag, max, min
189* ..
190* .. Statement Function definitions ..
191 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
192* ..
193* .. Executable Statements ..
194*
195* Quick return if N = 0 pr NRHS = 0
196*
197 IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 ) THEN
198 resid = zero
199 RETURN
200 END IF
201*
202* Exit with RESID = 1/EPS if ANORM = 0.
203*
204 eps = dlamch( 'Epsilon' )
205 anorm = zero
206 IF( lsame( trans, 'N' ) ) THEN
207*
208* Find norm1(A).
209*
210 kd = ku + 1
211 DO 10 j = 1, n
212 i1 = max( kd+1-j, 1 )
213 i2 = min( kd+m-j, kl+kd )
214 IF( i2.GE.i1 ) THEN
215 temp = dzasum( i2-i1+1, a( i1, j ), 1 )
216 IF( anorm.LT.temp .OR. disnan( temp ) ) anorm = temp
217 END IF
218 10 CONTINUE
219 ELSE
220*
221* Find normI(A).
222*
223 DO 12 i1 = 1, m
224 rwork( i1 ) = zero
225 12 CONTINUE
226 DO 16 j = 1, n
227 kd = ku + 1 - j
228 DO 14 i1 = max( 1, j-ku ), min( m, j+kl )
229 rwork( i1 ) = rwork( i1 ) + cabs1( a( kd+i1, j ) )
230 14 CONTINUE
231 16 CONTINUE
232 DO 18 i1 = 1, m
233 temp = rwork( i1 )
234 IF( anorm.LT.temp .OR. disnan( temp ) ) anorm = temp
235 18 CONTINUE
236 END IF
237 IF( anorm.LE.zero ) THEN
238 resid = one / eps
239 RETURN
240 END IF
241*
242 IF( lsame( trans, 'T' ) .OR. lsame( trans, 'C' ) ) THEN
243 n1 = n
244 ELSE
245 n1 = m
246 END IF
247*
248* Compute B - op(A)*X
249*
250 DO 20 j = 1, nrhs
251 CALL zgbmv( trans, m, n, kl, ku, -cone, a, lda, x( 1, j ), 1,
252 \$ cone, b( 1, j ), 1 )
253 20 CONTINUE
254*
255* Compute the maximum over the number of right hand sides of
256* norm(B - op(A)*X) / ( norm(op(A)) * norm(X) * EPS ).
257*
258 resid = zero
259 DO 30 j = 1, nrhs
260 bnorm = dzasum( n1, b( 1, j ), 1 )
261 xnorm = dzasum( n1, x( 1, j ), 1 )
262 IF( xnorm.LE.zero ) THEN
263 resid = one / eps
264 ELSE
265 resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
266 END IF
267 30 CONTINUE
268*
269 RETURN
270*
271* End of ZGBT02
272*
273 END
subroutine zgbmv(trans, m, n, kl, ku, alpha, a, lda, x, incx, beta, y, incy)
ZGBMV
Definition zgbmv.f:190
subroutine zgbt02(trans, m, n, kl, ku, nrhs, a, lda, x, ldx, b, ldb, rwork, resid)
ZGBT02
Definition zgbt02.f:148