3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE CTBT02( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, X,
12 * LDX, B, LDB, WORK, RWORK, RESID )
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER KD, LDAB, LDB, LDX, N, NRHS
19 * .. Array Arguments ..
21 * COMPLEX AB( LDAB, * ), B( LDB, * ), WORK( * ),
31 *> CTBT02 computes the residual for the computed solution to a
32 *> triangular system of linear equations A*x = b, A**T *x = b, or
33 *> A**H *x = b when A is a triangular band matrix. Here A**T denotes
34 *> the transpose of A, A**H denotes the conjugate transpose of A, and
35 *> x and b are N by NRHS matrices. The test ratio is the maximum over
36 *> the number of right hand sides of
37 *> norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
38 *> where op(A) denotes A, A**T, or A**H, and EPS is the machine epsilon.
46 *> UPLO is CHARACTER*1
47 *> Specifies whether the matrix A is upper or lower triangular.
48 *> = 'U': Upper triangular
49 *> = 'L': Lower triangular
54 *> TRANS is CHARACTER*1
55 *> Specifies the operation applied to A.
56 *> = 'N': A *x = b (No transpose)
57 *> = 'T': A**T *x = b (Transpose)
58 *> = 'C': A**H *x = b (Conjugate transpose)
63 *> DIAG is CHARACTER*1
64 *> Specifies whether or not the matrix A is unit triangular.
65 *> = 'N': Non-unit triangular
66 *> = 'U': Unit triangular
72 *> The order of the matrix A. N >= 0.
78 *> The number of superdiagonals or subdiagonals of the
79 *> triangular band matrix A. KD >= 0.
85 *> The number of right hand sides, i.e., the number of columns
86 *> of the matrices X and B. NRHS >= 0.
91 *> AB is COMPLEX array, dimension (LDA,N)
92 *> The upper or lower triangular band matrix A, stored in the
93 *> first kd+1 rows of the array. The j-th column of A is stored
94 *> in the j-th column of the array AB as follows:
95 *> if UPLO = 'U', AB(kd+1+i-j,j) = A(i,j) for max(1,j-kd)<=i<=j;
96 *> if UPLO = 'L', AB(1+i-j,j) = A(i,j) for j<=i<=min(n,j+kd).
102 *> The leading dimension of the array AB. LDAB >= max(1,KD+1).
107 *> X is COMPLEX array, dimension (LDX,NRHS)
108 *> The computed solution vectors for the system of linear
115 *> The leading dimension of the array X. LDX >= max(1,N).
120 *> B is COMPLEX array, dimension (LDB,NRHS)
121 *> The right hand side vectors for the system of linear
128 *> The leading dimension of the array B. LDB >= max(1,N).
133 *> WORK is COMPLEX array, dimension (N)
138 *> RWORK is REAL array, dimension (N)
144 *> The maximum over the number of right hand sides of
145 *> norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
151 *> \author Univ. of Tennessee
152 *> \author Univ. of California Berkeley
153 *> \author Univ. of Colorado Denver
156 *> \date November 2011
158 *> \ingroup complex_lin
160 * =====================================================================
161 SUBROUTINE CTBT02( UPLO, TRANS, DIAG, N, KD, NRHS, AB, LDAB, X,
162 $ LDX, B, LDB, WORK, RWORK, RESID )
164 * -- LAPACK test routine (version 3.4.0) --
165 * -- LAPACK is a software package provided by Univ. of Tennessee, --
166 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
169 * .. Scalar Arguments ..
170 CHARACTER DIAG, TRANS, UPLO
171 INTEGER KD, LDAB, LDB, LDX, N, NRHS
174 * .. Array Arguments ..
176 COMPLEX AB( LDAB, * ), B( LDB, * ), WORK( * ),
180 * =====================================================================
184 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
186 * .. Local Scalars ..
188 REAL ANORM, BNORM, EPS, XNORM
190 * .. External Functions ..
192 REAL CLANTB, SCASUM, SLAMCH
193 EXTERNAL LSAME, CLANTB, SCASUM, SLAMCH
195 * .. External Subroutines ..
196 EXTERNAL CAXPY, CCOPY, CTBMV
198 * .. Intrinsic Functions ..
201 * .. Executable Statements ..
203 * Quick exit if N = 0 or NRHS = 0
205 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
210 * Compute the 1-norm of A or A'.
212 IF( LSAME( TRANS, 'N' ) ) THEN
213 ANORM = CLANTB( '1', UPLO, DIAG, N, KD, AB, LDAB, RWORK )
215 ANORM = CLANTB( 'I', UPLO, DIAG, N, KD, AB, LDAB, RWORK )
218 * Exit with RESID = 1/EPS if ANORM = 0.
220 EPS = SLAMCH( 'Epsilon' )
221 IF( ANORM.LE.ZERO ) THEN
226 * Compute the maximum over the number of right hand sides of
227 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
231 CALL CCOPY( N, X( 1, J ), 1, WORK, 1 )
232 CALL CTBMV( UPLO, TRANS, DIAG, N, KD, AB, LDAB, WORK, 1 )
233 CALL CAXPY( N, CMPLX( -ONE ), B( 1, J ), 1, WORK, 1 )
234 BNORM = SCASUM( N, WORK, 1 )
235 XNORM = SCASUM( N, X( 1, J ), 1 )
236 IF( XNORM.LE.ZERO ) THEN
239 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )