LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ dtrt03()

subroutine dtrt03 ( character uplo,
character trans,
character diag,
integer n,
integer nrhs,
double precision, dimension( lda, * ) a,
integer lda,
double precision scale,
double precision, dimension( * ) cnorm,
double precision tscal,
double precision, dimension( ldx, * ) x,
integer ldx,
double precision, dimension( ldb, * ) b,
integer ldb,
double precision, dimension( * ) work,
double precision resid )

DTRT03

Purpose:
!>
!> DTRT03 computes the residual for the solution to a scaled triangular
!> system of equations A*x = s*b  or  A'*x = s*b.
!> Here A is a triangular matrix, A' is the transpose of A, s is a
!> scalar, and x and b are N by NRHS matrices.  The test ratio is the
!> maximum over the number of right hand sides of
!>    norm(s*b - op(A)*x) / ( norm(op(A)) * norm(x) * EPS ),
!> where op(A) denotes A or A' and EPS is the machine epsilon.
!> 
Parameters
[in]UPLO
!>          UPLO is CHARACTER*1
!>          Specifies whether the matrix A is upper or lower triangular.
!>          = 'U':  Upper triangular
!>          = 'L':  Lower triangular
!> 
[in]TRANS
!>          TRANS is CHARACTER*1
!>          Specifies the operation applied to A.
!>          = 'N':  A *x = s*b  (No transpose)
!>          = 'T':  A'*x = s*b  (Transpose)
!>          = 'C':  A'*x = s*b  (Conjugate transpose = Transpose)
!> 
[in]DIAG
!>          DIAG is CHARACTER*1
!>          Specifies whether or not the matrix A is unit triangular.
!>          = 'N':  Non-unit triangular
!>          = 'U':  Unit triangular
!> 
[in]N
!>          N is INTEGER
!>          The order of the matrix A.  N >= 0.
!> 
[in]NRHS
!>          NRHS is INTEGER
!>          The number of right hand sides, i.e., the number of columns
!>          of the matrices X and B.  NRHS >= 0.
!> 
[in]A
!>          A is DOUBLE PRECISION array, dimension (LDA,N)
!>          The triangular matrix A.  If UPLO = 'U', the leading n by n
!>          upper triangular part of the array A contains the upper
!>          triangular matrix, and the strictly lower triangular part of
!>          A is not referenced.  If UPLO = 'L', the leading n by n lower
!>          triangular part of the array A contains the lower triangular
!>          matrix, and the strictly upper triangular part of A is not
!>          referenced.  If DIAG = 'U', the diagonal elements of A are
!>          also not referenced and are assumed to be 1.
!> 
[in]LDA
!>          LDA is INTEGER
!>          The leading dimension of the array A.  LDA >= max(1,N).
!> 
[in]SCALE
!>          SCALE is DOUBLE PRECISION
!>          The scaling factor s used in solving the triangular system.
!> 
[in]CNORM
!>          CNORM is DOUBLE PRECISION array, dimension (N)
!>          The 1-norms of the columns of A, not counting the diagonal.
!> 
[in]TSCAL
!>          TSCAL is DOUBLE PRECISION
!>          The scaling factor used in computing the 1-norms in CNORM.
!>          CNORM actually contains the column norms of TSCAL*A.
!> 
[in]X
!>          X is DOUBLE PRECISION array, dimension (LDX,NRHS)
!>          The computed solution vectors for the system of linear
!>          equations.
!> 
[in]LDX
!>          LDX is INTEGER
!>          The leading dimension of the array X.  LDX >= max(1,N).
!> 
[in]B
!>          B is DOUBLE PRECISION array, dimension (LDB,NRHS)
!>          The right hand side vectors for the system of linear
!>          equations.
!> 
[in]LDB
!>          LDB is INTEGER
!>          The leading dimension of the array B.  LDB >= max(1,N).
!> 
[out]WORK
!>          WORK is DOUBLE PRECISION array, dimension (N)
!> 
[out]RESID
!>          RESID is DOUBLE PRECISION
!>          The maximum over the number of right hand sides of
!>          norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
!> 
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 167 of file dtrt03.f.

169*
170* -- LAPACK test routine --
171* -- LAPACK is a software package provided by Univ. of Tennessee, --
172* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
173*
174* .. Scalar Arguments ..
175 CHARACTER DIAG, TRANS, UPLO
176 INTEGER LDA, LDB, LDX, N, NRHS
177 DOUBLE PRECISION RESID, SCALE, TSCAL
178* ..
179* .. Array Arguments ..
180 DOUBLE PRECISION A( LDA, * ), B( LDB, * ), CNORM( * ),
181 $ WORK( * ), X( LDX, * )
182* ..
183*
184* =====================================================================
185*
186* .. Parameters ..
187 DOUBLE PRECISION ONE, ZERO
188 parameter( one = 1.0d+0, zero = 0.0d+0 )
189* ..
190* .. Local Scalars ..
191 INTEGER IX, J
192 DOUBLE PRECISION BIGNUM, EPS, ERR, SMLNUM, TNORM, XNORM, XSCAL
193* ..
194* .. External Functions ..
195 LOGICAL LSAME
196 INTEGER IDAMAX
197 DOUBLE PRECISION DLAMCH
198 EXTERNAL lsame, idamax, dlamch
199* ..
200* .. External Subroutines ..
201 EXTERNAL daxpy, dcopy, dscal, dtrmv
202* ..
203* .. Intrinsic Functions ..
204 INTRINSIC abs, dble, max
205* ..
206* .. Executable Statements ..
207*
208* Quick exit if N = 0
209*
210 IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
211 resid = zero
212 RETURN
213 END IF
214 eps = dlamch( 'Epsilon' )
215 smlnum = dlamch( 'Safe minimum' )
216 bignum = one / smlnum
217*
218* Compute the norm of the triangular matrix A using the column
219* norms already computed by DLATRS.
220*
221 tnorm = zero
222 IF( lsame( diag, 'N' ) ) THEN
223 DO 10 j = 1, n
224 tnorm = max( tnorm, tscal*abs( a( j, j ) )+cnorm( j ) )
225 10 CONTINUE
226 ELSE
227 DO 20 j = 1, n
228 tnorm = max( tnorm, tscal+cnorm( j ) )
229 20 CONTINUE
230 END IF
231*
232* Compute the maximum over the number of right hand sides of
233* norm(op(A)*x - s*b) / ( norm(op(A)) * norm(x) * EPS ).
234*
235 resid = zero
236 DO 30 j = 1, nrhs
237 CALL dcopy( n, x( 1, j ), 1, work, 1 )
238 ix = idamax( n, work, 1 )
239 xnorm = max( one, abs( x( ix, j ) ) )
240 xscal = ( one / xnorm ) / dble( n )
241 CALL dscal( n, xscal, work, 1 )
242 CALL dtrmv( uplo, trans, diag, n, a, lda, work, 1 )
243 CALL daxpy( n, -scale*xscal, b( 1, j ), 1, work, 1 )
244 ix = idamax( n, work, 1 )
245 err = tscal*abs( work( ix ) )
246 ix = idamax( n, x( 1, j ), 1 )
247 xnorm = abs( x( ix, j ) )
248 IF( err*smlnum.LE.xnorm ) THEN
249 IF( xnorm.GT.zero )
250 $ err = err / xnorm
251 ELSE
252 IF( err.GT.zero )
253 $ err = one / eps
254 END IF
255 IF( err*smlnum.LE.tnorm ) THEN
256 IF( tnorm.GT.zero )
257 $ err = err / tnorm
258 ELSE
259 IF( err.GT.zero )
260 $ err = one / eps
261 END IF
262 resid = max( resid, err )
263 30 CONTINUE
264*
265 RETURN
266*
267* End of DTRT03
268*
subroutine daxpy(n, da, dx, incx, dy, incy)
DAXPY
Definition daxpy.f:89
subroutine dcopy(n, dx, incx, dy, incy)
DCOPY
Definition dcopy.f:82
integer function idamax(n, dx, incx)
IDAMAX
Definition idamax.f:71
double precision function dlamch(cmach)
DLAMCH
Definition dlamch.f:69
logical function lsame(ca, cb)
LSAME
Definition lsame.f:48
subroutine dscal(n, da, dx, incx)
DSCAL
Definition dscal.f:79
subroutine dtrmv(uplo, trans, diag, n, a, lda, x, incx)
DTRMV
Definition dtrmv.f:147
Here is the call graph for this function:
Here is the caller graph for this function: