LAPACK  3.9.1
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, 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 * COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> CGBT02 computes the residual for a solution of a banded system of
30 *> equations A*x = b or A'*x = b:
31 *> RESID = norm( B - A*X ) / ( norm(A) * norm(X) * EPS).
32 *> where EPS is the machine precision.
33 *> \endverbatim
34 *
35 * Arguments:
36 * ==========
37 *
38 *> \param[in] TRANS
39 *> \verbatim
40 *> TRANS is CHARACTER*1
41 *> Specifies the form of the system of equations:
42 *> = 'N': A *x = b
43 *> = 'T': A'*x = b, where A' is the transpose of A
44 *> = 'C': A'*x = b, where A' is the transpose of A
45 *> \endverbatim
46 *>
47 *> \param[in] M
48 *> \verbatim
49 *> M is INTEGER
50 *> The number of rows of the matrix A. M >= 0.
51 *> \endverbatim
52 *>
53 *> \param[in] N
54 *> \verbatim
55 *> N is INTEGER
56 *> The number of columns of the matrix A. N >= 0.
57 *> \endverbatim
58 *>
59 *> \param[in] KL
60 *> \verbatim
61 *> KL is INTEGER
62 *> The number of subdiagonals within the band of A. KL >= 0.
63 *> \endverbatim
64 *>
65 *> \param[in] KU
66 *> \verbatim
67 *> KU is INTEGER
68 *> The number of superdiagonals within the band of A. KU >= 0.
69 *> \endverbatim
70 *>
71 *> \param[in] NRHS
72 *> \verbatim
73 *> NRHS is INTEGER
74 *> The number of columns of B. NRHS >= 0.
75 *> \endverbatim
76 *>
77 *> \param[in] A
78 *> \verbatim
79 *> A is COMPLEX array, dimension (LDA,N)
80 *> The original matrix A in band storage, stored in rows 1 to
81 *> KL+KU+1.
82 *> \endverbatim
83 *>
84 *> \param[in] LDA
85 *> \verbatim
86 *> LDA is INTEGER
87 *> The leading dimension of the array A. LDA >= max(1,KL+KU+1).
88 *> \endverbatim
89 *>
90 *> \param[in] X
91 *> \verbatim
92 *> X is COMPLEX array, dimension (LDX,NRHS)
93 *> The computed solution vectors for the system of linear
94 *> equations.
95 *> \endverbatim
96 *>
97 *> \param[in] LDX
98 *> \verbatim
99 *> LDX is INTEGER
100 *> The leading dimension of the array X. If TRANS = 'N',
101 *> LDX >= max(1,N); if TRANS = 'T' or 'C', LDX >= max(1,M).
102 *> \endverbatim
103 *>
104 *> \param[in,out] B
105 *> \verbatim
106 *> B is COMPLEX array, dimension (LDB,NRHS)
107 *> On entry, the right hand side vectors for the system of
108 *> linear equations.
109 *> On exit, B is overwritten with the difference B - A*X.
110 *> \endverbatim
111 *>
112 *> \param[in] LDB
113 *> \verbatim
114 *> LDB is INTEGER
115 *> The leading dimension of the array B. IF TRANS = 'N',
116 *> LDB >= max(1,M); if TRANS = 'T' or 'C', LDB >= max(1,N).
117 *> \endverbatim
118 *>
119 *> \param[out] RESID
120 *> \verbatim
121 *> RESID is REAL
122 *> The maximum over the number of right hand sides of
123 *> norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
124 *> \endverbatim
125 *
126 * Authors:
127 * ========
128 *
129 *> \author Univ. of Tennessee
130 *> \author Univ. of California Berkeley
131 *> \author Univ. of Colorado Denver
132 *> \author NAG Ltd.
133 *
134 *> \ingroup complex_lin
135 *
136 * =====================================================================
137  SUBROUTINE cgbt02( TRANS, M, N, KL, KU, NRHS, A, LDA, X, LDX, B,
138  $ LDB, RESID )
139 *
140 * -- LAPACK test routine --
141 * -- LAPACK is a software package provided by Univ. of Tennessee, --
142 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
143 *
144 * .. Scalar Arguments ..
145  CHARACTER TRANS
146  INTEGER KL, KU, LDA, LDB, LDX, M, N, NRHS
147  REAL RESID
148 * ..
149 * .. Array Arguments ..
150  COMPLEX A( LDA, * ), B( LDB, * ), X( LDX, * )
151 * ..
152 *
153 * =====================================================================
154 *
155 * .. Parameters ..
156  REAL ZERO, ONE
157  parameter( zero = 0.0e+0, one = 1.0e+0 )
158  COMPLEX CONE
159  parameter( cone = ( 1.0e+0, 0.0e+0 ) )
160 * ..
161 * .. Local Scalars ..
162  INTEGER I1, I2, J, KD, N1
163  REAL ANORM, BNORM, EPS, XNORM
164 * ..
165 * .. External Functions ..
166  LOGICAL LSAME
167  REAL SCASUM, SLAMCH
168  EXTERNAL lsame, scasum, slamch
169 * ..
170 * .. External Subroutines ..
171  EXTERNAL cgbmv
172 * ..
173 * .. Intrinsic Functions ..
174  INTRINSIC max, min
175 * ..
176 * .. Executable Statements ..
177 *
178 * Quick return if N = 0 pr NRHS = 0
179 *
180  IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 ) THEN
181  resid = zero
182  RETURN
183  END IF
184 *
185 * Exit with RESID = 1/EPS if ANORM = 0.
186 *
187  eps = slamch( 'Epsilon' )
188  kd = ku + 1
189  anorm = zero
190  DO 10 j = 1, n
191  i1 = max( kd+1-j, 1 )
192  i2 = min( kd+m-j, kl+kd )
193  anorm = max( anorm, scasum( i2-i1+1, a( i1, j ), 1 ) )
194  10 CONTINUE
195  IF( anorm.LE.zero ) THEN
196  resid = one / eps
197  RETURN
198  END IF
199 *
200  IF( lsame( trans, 'T' ) .OR. lsame( trans, 'C' ) ) THEN
201  n1 = n
202  ELSE
203  n1 = m
204  END IF
205 *
206 * Compute B - A*X (or B - A'*X )
207 *
208  DO 20 j = 1, nrhs
209  CALL cgbmv( trans, m, n, kl, ku, -cone, a, lda, x( 1, j ), 1,
210  $ cone, b( 1, j ), 1 )
211  20 CONTINUE
212 *
213 * Compute the maximum over the number of right hand sides of
214 * norm(B - A*X) / ( norm(A) * norm(X) * EPS ).
215 *
216  resid = zero
217  DO 30 j = 1, nrhs
218  bnorm = scasum( n1, b( 1, j ), 1 )
219  xnorm = scasum( n1, x( 1, j ), 1 )
220  IF( xnorm.LE.zero ) THEN
221  resid = one / eps
222  ELSE
223  resid = max( resid, ( ( bnorm/anorm )/xnorm )/eps )
224  END IF
225  30 CONTINUE
226 *
227  RETURN
228 *
229 * End of CGBT02
230 *
231  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, RESID)
CGBT02
Definition: cgbt02.f:139