LAPACK  3.10.1
LAPACK: Linear Algebra PACKage

◆ ctrt02()

subroutine ctrt02 ( character  UPLO,
character  TRANS,
character  DIAG,
integer  N,
integer  NRHS,
complex, dimension( lda, * )  A,
integer  LDA,
complex, dimension( ldx, * )  X,
integer  LDX,
complex, dimension( ldb, * )  B,
integer  LDB,
complex, dimension( * )  WORK,
real, dimension( * )  RWORK,
real  RESID 
)

CTRT02

Purpose:
 CTRT02 computes the residual for the computed solution to a
 triangular system of linear equations op(A)*X = B, where A is a
 triangular matrix. The test ratio is the maximum over
    norm(b - op(A)*x) / ( ||op(A)||_1 * norm(x) * EPS ),
 where op(A) = A, A**T, or A**H, b is the column of B, x is the
 solution vector, 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 = B  (No transpose)
          = 'T':  A**T * X = B  (Transpose)
          = 'C':  A**H * X = B  (Conjugate 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 COMPLEX 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]X
          X is COMPLEX 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 COMPLEX 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 COMPLEX array, dimension (N)
[out]RWORK
          RWORK is REAL array, dimension (N)
[out]RESID
          RESID is REAL
          The maximum over the number of right hand sides of
          norm(op(A)*X - B) / ( norm(op(A)) * norm(X) * EPS ).
Author
Univ. of Tennessee
Univ. of California Berkeley
Univ. of Colorado Denver
NAG Ltd.

Definition at line 153 of file ctrt02.f.

155 *
156 * -- LAPACK test routine --
157 * -- LAPACK is a software package provided by Univ. of Tennessee, --
158 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
159 *
160 * .. Scalar Arguments ..
161  CHARACTER DIAG, TRANS, UPLO
162  INTEGER LDA, LDB, LDX, N, NRHS
163  REAL RESID
164 * ..
165 * .. Array Arguments ..
166  REAL RWORK( * )
167  COMPLEX A( LDA, * ), B( LDB, * ), WORK( * ),
168  $ X( LDX, * )
169 * ..
170 *
171 * =====================================================================
172 *
173 * .. Parameters ..
174  REAL ZERO, ONE
175  parameter( zero = 0.0e+0, one = 1.0e+0 )
176 * ..
177 * .. Local Scalars ..
178  INTEGER J
179  REAL ANORM, BNORM, EPS, XNORM
180 * ..
181 * .. External Functions ..
182  LOGICAL LSAME
183  REAL CLANTR, SCASUM, SLAMCH
184  EXTERNAL lsame, clantr, scasum, slamch
185 * ..
186 * .. External Subroutines ..
187  EXTERNAL caxpy, ccopy, ctrmv
188 * ..
189 * .. Intrinsic Functions ..
190  INTRINSIC cmplx, max
191 * ..
192 * .. Executable Statements ..
193 *
194 * Quick exit if N = 0 or NRHS = 0
195 *
196  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
197  resid = zero
198  RETURN
199  END IF
200 *
201 * Compute the 1-norm of op(A).
202 *
203  IF( lsame( trans, 'N' ) ) THEN
204  anorm = clantr( '1', uplo, diag, n, n, a, lda, rwork )
205  ELSE
206  anorm = clantr( 'I', uplo, diag, n, n, a, lda, rwork )
207  END IF
208 *
209 * Exit with RESID = 1/EPS if ANORM = 0.
210 *
211  eps = slamch( 'Epsilon' )
212  IF( anorm.LE.zero ) THEN
213  resid = one / eps
214  RETURN
215  END IF
216 *
217 * Compute the maximum over the number of right hand sides of
218 * norm(op(A)*X - B) / ( norm(op(A)) * norm(X) * EPS )
219 *
220  resid = zero
221  DO 10 j = 1, nrhs
222  CALL ccopy( n, x( 1, j ), 1, work, 1 )
223  CALL ctrmv( uplo, trans, diag, n, a, lda, work, 1 )
224  CALL caxpy( n, cmplx( -one ), b( 1, j ), 1, work, 1 )
225  bnorm = scasum( n, work, 1 )
226  xnorm = scasum( n, x( 1, j ), 1 )
227  IF( xnorm.LE.zero ) THEN
228  resid = one / eps
229  ELSE
230  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
231  END IF
232  10 CONTINUE
233 *
234  RETURN
235 *
236 * End of CTRT02
237 *
logical function lsame(CA, CB)
LSAME
Definition: lsame.f:53
subroutine ccopy(N, CX, INCX, CY, INCY)
CCOPY
Definition: ccopy.f:81
subroutine caxpy(N, CA, CX, INCX, CY, INCY)
CAXPY
Definition: caxpy.f:88
subroutine ctrmv(UPLO, TRANS, DIAG, N, A, LDA, X, INCX)
CTRMV
Definition: ctrmv.f:147
real function clantr(NORM, UPLO, DIAG, M, N, A, LDA, WORK)
CLANTR returns the value of the 1-norm, or the Frobenius norm, or the infinity norm,...
Definition: clantr.f:142
real function scasum(N, CX, INCX)
SCASUM
Definition: scasum.f:72
real function slamch(CMACH)
SLAMCH
Definition: slamch.f:68
Here is the call graph for this function:
Here is the caller graph for this function: