LAPACK 3.12.0
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
zppt01.f
Go to the documentation of this file.
1*> \brief \b ZPPT01
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 ZPPT01( UPLO, N, A, AFAC, RWORK, RESID )
12*
13* .. Scalar Arguments ..
14* CHARACTER UPLO
15* INTEGER N
16* DOUBLE PRECISION RESID
17* ..
18* .. Array Arguments ..
19* DOUBLE PRECISION RWORK( * )
20* COMPLEX*16 A( * ), AFAC( * )
21* ..
22*
23*
24*> \par Purpose:
25* =============
26*>
27*> \verbatim
28*>
29*> ZPPT01 reconstructs a Hermitian positive definite packed matrix A
30*> from its L*L' or U'*U factorization and computes the residual
31*> norm( L*L' - A ) / ( N * norm(A) * EPS ) or
32*> norm( U'*U - A ) / ( N * norm(A) * EPS ),
33*> where EPS is the machine epsilon, L' is the conjugate transpose of
34*> L, and U' is the conjugate transpose of U.
35*> \endverbatim
36*
37* Arguments:
38* ==========
39*
40*> \param[in] UPLO
41*> \verbatim
42*> UPLO is CHARACTER*1
43*> Specifies whether the upper or lower triangular part of the
44*> Hermitian matrix A is stored:
45*> = 'U': Upper triangular
46*> = 'L': Lower triangular
47*> \endverbatim
48*>
49*> \param[in] N
50*> \verbatim
51*> N is INTEGER
52*> The number of rows and columns of the matrix A. N >= 0.
53*> \endverbatim
54*>
55*> \param[in] A
56*> \verbatim
57*> A is COMPLEX*16 array, dimension (N*(N+1)/2)
58*> The original Hermitian matrix A, stored as a packed
59*> triangular matrix.
60*> \endverbatim
61*>
62*> \param[in,out] AFAC
63*> \verbatim
64*> AFAC is COMPLEX*16 array, dimension (N*(N+1)/2)
65*> On entry, the factor L or U from the L*L' or U'*U
66*> factorization of A, stored as a packed triangular matrix.
67*> Overwritten with the reconstructed matrix, and then with the
68*> difference L*L' - A (or U'*U - A).
69*> \endverbatim
70*>
71*> \param[out] RWORK
72*> \verbatim
73*> RWORK is DOUBLE PRECISION array, dimension (N)
74*> \endverbatim
75*>
76*> \param[out] RESID
77*> \verbatim
78*> RESID is DOUBLE PRECISION
79*> If UPLO = 'L', norm(L*L' - A) / ( N * norm(A) * EPS )
80*> If UPLO = 'U', norm(U'*U - A) / ( N * norm(A) * EPS )
81*> \endverbatim
82*
83* Authors:
84* ========
85*
86*> \author Univ. of Tennessee
87*> \author Univ. of California Berkeley
88*> \author Univ. of Colorado Denver
89*> \author NAG Ltd.
90*
91*> \ingroup complex16_lin
92*
93* =====================================================================
94 SUBROUTINE zppt01( UPLO, N, A, AFAC, RWORK, RESID )
95*
96* -- LAPACK test routine --
97* -- LAPACK is a software package provided by Univ. of Tennessee, --
98* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
99*
100* .. Scalar Arguments ..
101 CHARACTER UPLO
102 INTEGER N
103 DOUBLE PRECISION RESID
104* ..
105* .. Array Arguments ..
106 DOUBLE PRECISION RWORK( * )
107 COMPLEX*16 A( * ), AFAC( * )
108* ..
109*
110* =====================================================================
111*
112* .. Parameters ..
113 DOUBLE PRECISION ZERO, ONE
114 parameter( zero = 0.0d+0, one = 1.0d+0 )
115* ..
116* .. Local Scalars ..
117 INTEGER I, K, KC
118 DOUBLE PRECISION ANORM, EPS, TR
119 COMPLEX*16 TC
120* ..
121* .. External Functions ..
122 LOGICAL LSAME
123 DOUBLE PRECISION DLAMCH, ZLANHP
124 COMPLEX*16 ZDOTC
125 EXTERNAL lsame, dlamch, zlanhp, zdotc
126* ..
127* .. External Subroutines ..
128 EXTERNAL zhpr, zscal, ztpmv
129* ..
130* .. Intrinsic Functions ..
131 INTRINSIC dble, dimag
132* ..
133* .. Executable Statements ..
134*
135* Quick exit if N = 0
136*
137 IF( n.LE.0 ) THEN
138 resid = zero
139 RETURN
140 END IF
141*
142* Exit with RESID = 1/EPS if ANORM = 0.
143*
144 eps = dlamch( 'Epsilon' )
145 anorm = zlanhp( '1', uplo, n, a, rwork )
146 IF( anorm.LE.zero ) THEN
147 resid = one / eps
148 RETURN
149 END IF
150*
151* Check the imaginary parts of the diagonal elements and return with
152* an error code if any are nonzero.
153*
154 kc = 1
155 IF( lsame( uplo, 'U' ) ) THEN
156 DO 10 k = 1, n
157 IF( dimag( afac( kc ) ).NE.zero ) THEN
158 resid = one / eps
159 RETURN
160 END IF
161 kc = kc + k + 1
162 10 CONTINUE
163 ELSE
164 DO 20 k = 1, n
165 IF( dimag( afac( kc ) ).NE.zero ) THEN
166 resid = one / eps
167 RETURN
168 END IF
169 kc = kc + n - k + 1
170 20 CONTINUE
171 END IF
172*
173* Compute the product U'*U, overwriting U.
174*
175 IF( lsame( uplo, 'U' ) ) THEN
176 kc = ( n*( n-1 ) ) / 2 + 1
177 DO 30 k = n, 1, -1
178*
179* Compute the (K,K) element of the result.
180*
181 tr = dble( zdotc( k, afac( kc ), 1, afac( kc ), 1 ) )
182 afac( kc+k-1 ) = tr
183*
184* Compute the rest of column K.
185*
186 IF( k.GT.1 ) THEN
187 CALL ztpmv( 'Upper', 'Conjugate', 'Non-unit', k-1, afac,
188 $ afac( kc ), 1 )
189 kc = kc - ( k-1 )
190 END IF
191 30 CONTINUE
192*
193* Compute the difference L*L' - A
194*
195 kc = 1
196 DO 50 k = 1, n
197 DO 40 i = 1, k - 1
198 afac( kc+i-1 ) = afac( kc+i-1 ) - a( kc+i-1 )
199 40 CONTINUE
200 afac( kc+k-1 ) = afac( kc+k-1 ) - dble( a( kc+k-1 ) )
201 kc = kc + k
202 50 CONTINUE
203*
204* Compute the product L*L', overwriting L.
205*
206 ELSE
207 kc = ( n*( n+1 ) ) / 2
208 DO 60 k = n, 1, -1
209*
210* Add a multiple of column K of the factor L to each of
211* columns K+1 through N.
212*
213 IF( k.LT.n )
214 $ CALL zhpr( 'Lower', n-k, one, afac( kc+1 ), 1,
215 $ afac( kc+n-k+1 ) )
216*
217* Scale column K by the diagonal element.
218*
219 tc = afac( kc )
220 CALL zscal( n-k+1, tc, afac( kc ), 1 )
221*
222 kc = kc - ( n-k+2 )
223 60 CONTINUE
224*
225* Compute the difference U'*U - A
226*
227 kc = 1
228 DO 80 k = 1, n
229 afac( kc ) = afac( kc ) - dble( a( kc ) )
230 DO 70 i = k + 1, n
231 afac( kc+i-k ) = afac( kc+i-k ) - a( kc+i-k )
232 70 CONTINUE
233 kc = kc + n - k + 1
234 80 CONTINUE
235 END IF
236*
237* Compute norm( L*U - A ) / ( N * norm(A) * EPS )
238*
239 resid = zlanhp( '1', uplo, n, afac, rwork )
240*
241 resid = ( ( resid / dble( n ) ) / anorm ) / eps
242*
243 RETURN
244*
245* End of ZPPT01
246*
247 END
subroutine zhpr(uplo, n, alpha, x, incx, ap)
ZHPR
Definition zhpr.f:130
subroutine zscal(n, za, zx, incx)
ZSCAL
Definition zscal.f:78
subroutine ztpmv(uplo, trans, diag, n, ap, x, incx)
ZTPMV
Definition ztpmv.f:142
subroutine zppt01(uplo, n, a, afac, rwork, resid)
ZPPT01
Definition zppt01.f:95