LAPACK  3.4.2
LAPACK: Linear Algebra PACKage
 All Files Functions Groups
ctpt02.f
Go to the documentation of this file.
1 *> \brief \b CTPT02
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 CTPT02( 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 * REAL RESID
18 * ..
19 * .. Array Arguments ..
20 * REAL RWORK( * )
21 * COMPLEX AP( * ), B( LDB, * ), WORK( * ), X( LDX, * )
22 * ..
23 *
24 *
25 *> \par Purpose:
26 * =============
27 *>
28 *> \verbatim
29 *>
30 *> CTPT02 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 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 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 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 array, dimension (N)
122 *> \endverbatim
123 *>
124 *> \param[out] RWORK
125 *> \verbatim
126 *> RWORK is REAL array, dimension (N)
127 *> \endverbatim
128 *>
129 *> \param[out] RESID
130 *> \verbatim
131 *> RESID is REAL
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 complex_lin
147 *
148 * =====================================================================
149  SUBROUTINE ctpt02( 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  REAL resid
161 * ..
162 * .. Array Arguments ..
163  REAL rwork( * )
164  COMPLEX ap( * ), b( ldb, * ), work( * ), x( ldx, * )
165 * ..
166 *
167 * =====================================================================
168 *
169 * .. Parameters ..
170  REAL zero, one
171  parameter( zero = 0.0e+0, one = 1.0e+0 )
172 * ..
173 * .. Local Scalars ..
174  INTEGER j
175  REAL anorm, bnorm, eps, xnorm
176 * ..
177 * .. External Functions ..
178  LOGICAL lsame
179  REAL clantp, scasum, slamch
180  EXTERNAL lsame, clantp, scasum, slamch
181 * ..
182 * .. External Subroutines ..
183  EXTERNAL caxpy, ccopy, ctpmv
184 * ..
185 * .. Intrinsic Functions ..
186  INTRINSIC cmplx, 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 = clantp( '1', uplo, diag, n, ap, rwork )
201  ELSE
202  anorm = clantp( 'I', uplo, diag, n, ap, rwork )
203  END IF
204 *
205 * Exit with RESID = 1/EPS if ANORM = 0.
206 *
207  eps = slamch( '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 ccopy( n, x( 1, j ), 1, work, 1 )
219  CALL ctpmv( uplo, trans, diag, n, ap, work, 1 )
220  CALL caxpy( n, cmplx( -one ), b( 1, j ), 1, work, 1 )
221  bnorm = scasum( n, work, 1 )
222  xnorm = scasum( 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 CTPT02
233 *
234  END