3 * =========== DOCUMENTATION ===========
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
11 * SUBROUTINE DTRT02( UPLO, TRANS, DIAG, N, NRHS, A, LDA, X, LDX, B,
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER LDA, LDB, LDX, N, NRHS
17 * DOUBLE PRECISION RESID
19 * .. Array Arguments ..
20 * DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * ),
30 *> DTRT02 computes the residual for the computed solution to a
31 *> triangular system of linear equations A*x = b or A'*x = b.
32 *> Here A is a triangular matrix, A' is the transpose of A, and x and b
33 *> are N by NRHS matrices. The test ratio is the maximum over the
34 *> number of right hand sides of
35 *> norm(b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
36 *> where op(A) denotes A or A' and EPS is the machine epsilon.
44 *> UPLO is CHARACTER*1
45 *> Specifies whether the matrix A is upper or lower triangular.
46 *> = 'U': Upper triangular
47 *> = 'L': Lower triangular
52 *> TRANS is CHARACTER*1
53 *> Specifies the operation applied to A.
54 *> = 'N': A *x = b (No transpose)
55 *> = 'T': A'*x = b (Transpose)
56 *> = 'C': A'*x = b (Conjugate transpose = Transpose)
61 *> DIAG is CHARACTER*1
62 *> Specifies whether or not the matrix A is unit triangular.
63 *> = 'N': Non-unit triangular
64 *> = 'U': Unit triangular
70 *> The order of the matrix A. N >= 0.
76 *> The number of right hand sides, i.e., the number of columns
77 *> of the matrices X and B. NRHS >= 0.
82 *> A is DOUBLE PRECISION array, dimension (LDA,N)
83 *> The triangular matrix A. If UPLO = 'U', the leading n by n
84 *> upper triangular part of the array A contains the upper
85 *> triangular matrix, and the strictly lower triangular part of
86 *> A is not referenced. If UPLO = 'L', the leading n by n lower
87 *> triangular part of the array A contains the lower triangular
88 *> matrix, and the strictly upper triangular part of A is not
89 *> referenced. If DIAG = 'U', the diagonal elements of A are
90 *> also not referenced and are assumed to be 1.
96 *> The leading dimension of the array A. LDA >= max(1,N).
101 *> X is DOUBLE PRECISION array, dimension (LDX,NRHS)
102 *> The computed solution vectors for the system of linear
109 *> The leading dimension of the array X. LDX >= max(1,N).
114 *> B is DOUBLE PRECISION array, dimension (LDB,NRHS)
115 *> The right hand side vectors for the system of linear
122 *> The leading dimension of the array B. LDB >= max(1,N).
127 *> WORK is DOUBLE PRECISION array, dimension (N)
132 *> RESID is DOUBLE PRECISION
133 *> The maximum over the number of right hand sides of
134 *> norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
140 *> \author Univ. of Tennessee
141 *> \author Univ. of California Berkeley
142 *> \author Univ. of Colorado Denver
145 *> \date November 2011
147 *> \ingroup double_lin
149 * =====================================================================
150 SUBROUTINE DTRT02( UPLO, TRANS, DIAG, N, NRHS, A, LDA, X, LDX, B,
153 * -- LAPACK test routine (version 3.4.0) --
154 * -- LAPACK is a software package provided by Univ. of Tennessee, --
155 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
158 * .. Scalar Arguments ..
159 CHARACTER DIAG, TRANS, UPLO
160 INTEGER LDA, LDB, LDX, N, NRHS
161 DOUBLE PRECISION RESID
163 * .. Array Arguments ..
164 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), WORK( * ),
168 * =====================================================================
171 DOUBLE PRECISION ZERO, ONE
172 PARAMETER ( ZERO = 0.0D+0, ONE = 1.0D+0 )
174 * .. Local Scalars ..
176 DOUBLE PRECISION ANORM, BNORM, EPS, XNORM
178 * .. External Functions ..
180 DOUBLE PRECISION DASUM, DLAMCH, DLANTR
181 EXTERNAL LSAME, DASUM, DLAMCH, DLANTR
183 * .. External Subroutines ..
184 EXTERNAL DAXPY, DCOPY, DTRMV
186 * .. Intrinsic Functions ..
189 * .. Executable Statements ..
191 * Quick exit if N = 0 or NRHS = 0
193 IF( N.LE.0 .OR. NRHS.LE.0 ) THEN
198 * Compute the 1-norm of A or A'.
200 IF( LSAME( TRANS, 'N' ) ) THEN
201 ANORM = DLANTR( '1', UPLO, DIAG, N, N, A, LDA, WORK )
203 ANORM = DLANTR( 'I', UPLO, DIAG, N, N, A, LDA, WORK )
206 * Exit with RESID = 1/EPS if ANORM = 0.
208 EPS = DLAMCH( 'Epsilon' )
209 IF( ANORM.LE.ZERO ) THEN
214 * Compute the maximum over the number of right hand sides of
215 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS )
219 CALL DCOPY( N, X( 1, J ), 1, WORK, 1 )
220 CALL DTRMV( UPLO, TRANS, DIAG, N, A, LDA, WORK, 1 )
221 CALL DAXPY( N, -ONE, B( 1, J ), 1, WORK, 1 )
222 BNORM = DASUM( N, WORK, 1 )
223 XNORM = DASUM( N, X( 1, J ), 1 )
224 IF( XNORM.LE.ZERO ) THEN
227 RESID = MAX( RESID, ( ( BNORM / ANORM ) / XNORM ) / EPS )