3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE CTRT02( UPLO, TRANS, DIAG, N, NRHS, A, LDA, X, LDX, B,
12 * LDB, WORK, RWORK, RESID )
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER LDA, LDB, LDX, N, NRHS
19 * .. Array Arguments ..
21 * COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ),
31 *> CTRT02 computes the residual for the computed solution to a
32 *> triangular system of linear equations A*x = b, A**T *x = b,
33 *> or A**H *x = b. Here A is a triangular matrix, A**T is the transpose
34 *> of A, A**H is the conjugate transpose of A, and x and b are N by NRHS
35 *> matrices. The test ratio is the maximum over the number of right
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 right hand sides, i.e., the number of columns
79 *> of the matrices X and B. NRHS >= 0.
84 *> A is COMPLEX array, dimension (LDA,N)
85 *> The triangular matrix A. If UPLO = 'U', the leading n by n
86 *> upper triangular part of the array A contains the upper
87 *> triangular matrix, and the strictly lower triangular part of
88 *> A is not referenced. If UPLO = 'L', the leading n by n lower
89 *> triangular part of the array A contains the lower triangular
90 *> matrix, and the strictly upper triangular part of A is not
91 *> referenced. If DIAG = 'U', the diagonal elements of A are
92 *> also not referenced and are assumed to be 1.
98 *> The leading dimension of the array A. LDA >= max(1,N).
103 *> X is COMPLEX array, dimension (LDX,NRHS)
104 *> The computed solution vectors for the system of linear
111 *> The leading dimension of the array X. LDX >= max(1,N).
116 *> B is COMPLEX array, dimension (LDB,NRHS)
117 *> The right hand side vectors for the system of linear
124 *> The leading dimension of the array B. LDB >= max(1,N).
129 *> WORK is COMPLEX array, dimension (N)
134 *> RWORK is REAL array, dimension (N)
140 *> The maximum over the number of right hand sides of
141 *> norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
147 *> \author Univ. of Tennessee
148 *> \author Univ. of California Berkeley
149 *> \author Univ. of Colorado Denver
152 *> \date November 2011
154 *> \ingroup complex_lin
156 * =====================================================================
157 SUBROUTINE CTRT02( UPLO, TRANS, DIAG, N, NRHS, A, LDA, X, LDX, B,
158 $ LDB, WORK, RWORK, RESID )
160 * -- LAPACK test routine (version 3.4.0) --
161 * -- LAPACK is a software package provided by Univ. of Tennessee, --
162 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
165 * .. Scalar Arguments ..
166 CHARACTER DIAG, TRANS, UPLO
167 INTEGER LDA, LDB, LDX, N, NRHS
170 * .. Array Arguments ..
172 COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ),
176 * =====================================================================
180 PARAMETER ( ZERO = 0.0E+0, ONE = 1.0E+0 )
182 * .. Local Scalars ..
184 REAL ANORM, BNORM, EPS, XNORM
186 * .. External Functions ..
188 REAL CLANTR, SCASUM, SLAMCH
189 EXTERNAL LSAME, CLANTR, SCASUM, SLAMCH
191 * .. External Subroutines ..
192 EXTERNAL CAXPY, CCOPY, CTRMV
194 * .. Intrinsic Functions ..
197 * .. Executable Statements ..
199 * Quick exit if N = 0 or NRHS = 0
201 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
206 * Compute the 1-norm of A or A**H.
208 IF( LSAME( TRANS, 'N' ) ) THEN
209 ANORM = CLANTR( '1', UPLO, DIAG, N, N, A, LDA, RWORK )
211 ANORM = CLANTR( 'I', UPLO, DIAG, N, N, A, LDA, RWORK )
214 * Exit with RESID = 1/EPS if ANORM = 0.
216 EPS = SLAMCH( 'Epsilon' )
217 IF( ANORM.LE.ZERO ) THEN
222 * Compute the maximum over the number of right hand sides of
223 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS )
227 CALL CCOPY( N, X( 1, J ), 1, WORK, 1 )
228 CALL CTRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 )
229 CALL CAXPY( N, CMPLX( -ONE ), B( 1, J ), 1, WORK, 1 )
230 BNORM = SCASUM( N, WORK, 1 )
231 XNORM = SCASUM( N, X( 1, J ), 1 )
232 IF( XNORM.LE.ZERO ) THEN
235 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )