LAPACK  3.10.0
LAPACK: Linear Algebra PACKage
cgbt02.f
Go to the documentation of this file.
1 *> \brief \b CGBT02
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 CGBT02( 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 * REAL RESID
18 * ..
19 * .. Array Arguments ..
20 * REAL RWORK( * )
21 * COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> CGBT02 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 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 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 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 REAL 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 REAL
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 complex_lin
144 *
145 * =====================================================================
146  SUBROUTINE cgbt02( 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  REAL RESID
157 * ..
158 * .. Array Arguments ..
159  REAL RWORK( * )
160  COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
161 * ..
162 *
163 * =====================================================================
164 *
165 * .. Parameters ..
166  REAL ZERO, ONE
167  parameter( zero = 0.0e+0, one = 1.0e+0 )
168  COMPLEX CONE
169  parameter( cone = ( 1.0e+0, 0.0e+0 ) )
170 * ..
171 * .. Local Scalars ..
172  INTEGER I1, I2, J, KD, N1
173  REAL ANORM, BNORM, EPS, TEMP, XNORM
174  COMPLEX CDUM
175 * ..
176 * .. External Functions ..
177  LOGICAL LSAME, SISNAN
178  REAL SCASUM, SLAMCH
179  EXTERNAL lsame, scasum, sisnan, slamch
180 * ..
181 * .. External Subroutines ..
182  EXTERNAL cgbmv
183 * ..
184 * .. Statement Functions ..
185  REAL CABS1
186 * ..
187 * .. Intrinsic Functions ..
188  INTRINSIC abs, aimag, max, min, real
189 * ..
190 * .. Statement Function definitions ..
191  cabs1( cdum ) = abs( real( cdum ) ) + abs( aimag( cdum ) )
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 = slamch( '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 = scasum( i2-i1+1, a( i1, j ), 1 )
216  IF( anorm.LT.temp .OR. sisnan( 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. sisnan( 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 cgbmv( 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 = scasum( n1, b( 1, j ), 1 )
261  xnorm = scasum( 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 CGBT02
272 *
273  END
subroutine cgbmv(TRANS, M, N, KL, KU, ALPHA, A, LDA, X, INCX, BETA, Y, INCY)
CGBMV
Definition: cgbmv.f:187
subroutine cgbt02(TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B, LDB, RWORK, RESID)
CGBT02
Definition: cgbt02.f:148