LAPACK  3.6.1 LAPACK: Linear Algebra PACKage
ztpt02.f
Go to the documentation of this file.
1 *> \brief \b ZTPT02
2 *
3 * =========== DOCUMENTATION ===========
4 *
5 * Online html documentation available at
6 * http://www.netlib.org/lapack/explore-html/
7 *
8 * Definition:
9 * ===========
10 *
11 * SUBROUTINE ZTPT02( UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB,
12 * WORK, RWORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER DIAG, TRANS, UPLO
16 * INTEGER LDB, LDX, N, NRHS
17 * DOUBLE PRECISION RESID
18 * ..
19 * .. Array Arguments ..
20 * DOUBLE PRECISION RWORK( * )
21 * COMPLEX*16 AP( * ), B( LDB, * ), WORK( * ), X( LDX, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> ZTPT02 computes the residual for the computed solution to a
31 *> triangular system of linear equations A*x = b, A**T *x = b, or
32 *> A**H *x = b, when the triangular matrix A is stored in packed format.
33 *> Here A**T denotes the transpose of A, A**H denotes the conjugate
34 *> transpose of A, and x and b are N by NRHS matrices. The test ratio
35 *> is the maximum over the number of right hand sides of
36 *> the maximum over 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.
39 *> \endverbatim
40 *
41 * Arguments:
42 * ==========
43 *
44 *> \param[in] UPLO
45 *> \verbatim
46 *> UPLO is CHARACTER*1
47 *> Specifies whether the matrix A is upper or lower triangular.
48 *> = 'U': Upper triangular
49 *> = 'L': Lower triangular
50 *> \endverbatim
51 *>
52 *> \param[in] TRANS
53 *> \verbatim
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)
59 *> \endverbatim
60 *>
61 *> \param[in] DIAG
62 *> \verbatim
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
67 *> \endverbatim
68 *>
69 *> \param[in] N
70 *> \verbatim
71 *> N is INTEGER
72 *> The order of the matrix A. N >= 0.
73 *> \endverbatim
74 *>
75 *> \param[in] NRHS
76 *> \verbatim
77 *> NRHS is INTEGER
78 *> The number of right hand sides, i.e., the number of columns
79 *> of the matrices X and B. NRHS >= 0.
80 *> \endverbatim
81 *>
82 *> \param[in] AP
83 *> \verbatim
84 *> AP is COMPLEX*16 array, dimension (N*(N+1)/2)
85 *> The upper or lower triangular matrix A, packed columnwise in
86 *> a linear array. The j-th column of A is stored in the array
87 *> AP as follows:
88 *> if UPLO = 'U', AP((j-1)*j/2 + i) = A(i,j) for 1<=i<=j;
89 *> if UPLO = 'L',
90 *> AP((j-1)*(n-j) + j*(j+1)/2 + i-j) = A(i,j) for j<=i<=n.
91 *> \endverbatim
92 *>
93 *> \param[in] X
94 *> \verbatim
95 *> X is COMPLEX*16 array, dimension (LDX,NRHS)
96 *> The computed solution vectors for the system of linear
97 *> equations.
98 *> \endverbatim
99 *>
100 *> \param[in] LDX
101 *> \verbatim
102 *> LDX is INTEGER
103 *> The leading dimension of the array X. LDX >= max(1,N).
104 *> \endverbatim
105 *>
106 *> \param[in] B
107 *> \verbatim
108 *> B is COMPLEX*16 array, dimension (LDB,NRHS)
109 *> The right hand side vectors for the system of linear
110 *> equations.
111 *> \endverbatim
112 *>
113 *> \param[in] LDB
114 *> \verbatim
115 *> LDB is INTEGER
116 *> The leading dimension of the array B. LDB >= max(1,N).
117 *> \endverbatim
118 *>
119 *> \param[out] WORK
120 *> \verbatim
121 *> WORK is COMPLEX*16 array, dimension (N)
122 *> \endverbatim
123 *>
124 *> \param[out] RWORK
125 *> \verbatim
126 *> RWORK is DOUBLE PRECISION array, dimension (N)
127 *> \endverbatim
128 *>
129 *> \param[out] RESID
130 *> \verbatim
131 *> RESID is DOUBLE PRECISION
132 *> The maximum over the number of right hand sides of
133 *> norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
134 *> \endverbatim
135 *
136 * Authors:
137 * ========
138 *
139 *> \author Univ. of Tennessee
140 *> \author Univ. of California Berkeley
141 *> \author Univ. of Colorado Denver
142 *> \author NAG Ltd.
143 *
144 *> \date November 2011
145 *
146 *> \ingroup complex16_lin
147 *
148 * =====================================================================
149  SUBROUTINE ztpt02( UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB,
150  \$ work, rwork, resid )
151 *
152 * -- LAPACK test routine (version 3.4.0) --
153 * -- LAPACK is a software package provided by Univ. of Tennessee, --
154 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
155 * November 2011
156 *
157 * .. Scalar Arguments ..
158  CHARACTER DIAG, TRANS, UPLO
159  INTEGER LDB, LDX, N, NRHS
160  DOUBLE PRECISION RESID
161 * ..
162 * .. Array Arguments ..
163  DOUBLE PRECISION RWORK( * )
164  COMPLEX*16 AP( * ), B( ldb, * ), WORK( * ), X( ldx, * )
165 * ..
166 *
167 * =====================================================================
168 *
169 * .. Parameters ..
170  DOUBLE PRECISION ZERO, ONE
171  parameter ( zero = 0.0d+0, one = 1.0d+0 )
172 * ..
173 * .. Local Scalars ..
174  INTEGER J
175  DOUBLE PRECISION ANORM, BNORM, EPS, XNORM
176 * ..
177 * .. External Functions ..
178  LOGICAL LSAME
179  DOUBLE PRECISION DLAMCH, DZASUM, ZLANTP
180  EXTERNAL lsame, dlamch, dzasum, zlantp
181 * ..
182 * .. External Subroutines ..
183  EXTERNAL zaxpy, zcopy, ztpmv
184 * ..
185 * .. Intrinsic Functions ..
186  INTRINSIC dcmplx, max
187 * ..
188 * .. Executable Statements ..
189 *
190 * Quick exit if N = 0 or NRHS = 0
191 *
192  IF( n.LE.0 .OR. nrhs.LE.0 ) THEN
193  resid = zero
194  RETURN
195  END IF
196 *
197 * Compute the 1-norm of A or A**H.
198 *
199  IF( lsame( trans, 'N' ) ) THEN
200  anorm = zlantp( '1', uplo, diag, n, ap, rwork )
201  ELSE
202  anorm = zlantp( 'I', uplo, diag, n, ap, rwork )
203  END IF
204 *
205 * Exit with RESID = 1/EPS if ANORM = 0.
206 *
207  eps = dlamch( 'Epsilon' )
208  IF( anorm.LE.zero ) THEN
209  resid = one / eps
210  RETURN
211  END IF
212 *
213 * Compute the maximum over the number of right hand sides of
214 * norm(op(A)*x - b) / ( norm(op(A)) * norm(x) * EPS ).
215 *
216  resid = zero
217  DO 10 j = 1, nrhs
218  CALL zcopy( n, x( 1, j ), 1, work, 1 )
219  CALL ztpmv( uplo, trans, diag, n, ap, work, 1 )
220  CALL zaxpy( n, dcmplx( -one ), b( 1, j ), 1, work, 1 )
221  bnorm = dzasum( n, work, 1 )
222  xnorm = dzasum( n, x( 1, j ), 1 )
223  IF( xnorm.LE.zero ) THEN
224  resid = one / eps
225  ELSE
226  resid = max( resid, ( ( bnorm / anorm ) / xnorm ) / eps )
227  END IF
228  10 CONTINUE
229 *
230  RETURN
231 *
232 * End of ZTPT02
233 *
234  END
subroutine zcopy(N, ZX, INCX, ZY, INCY)
ZCOPY
Definition: zcopy.f:52
subroutine ztpt02(UPLO, TRANS, DIAG, N, NRHS, AP, X, LDX, B, LDB, WORK, RWORK, RESID)
ZTPT02
Definition: ztpt02.f:151
subroutine ztpmv(UPLO, TRANS, DIAG, N, AP, X, INCX)
ZTPMV
Definition: ztpmv.f:144
subroutine zaxpy(N, ZA, ZX, INCX, ZY, INCY)
ZAXPY
Definition: zaxpy.f:53