LAPACK 3.12.0 LAPACK: Linear Algebra PACKage
Searching...
No Matches
cppt01.f
Go to the documentation of this file.
1*> \brief \b CPPT01
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 CPPT01( UPLO, N, A, AFAC, RWORK, RESID )
12*
13* .. Scalar Arguments ..
14* CHARACTER UPLO
15* INTEGER N
16* REAL RESID
17* ..
18* .. Array Arguments ..
19* REAL RWORK( * )
20* COMPLEX A( * ), AFAC( * )
21* ..
22*
23*
24*> \par Purpose:
25* =============
26*>
27*> \verbatim
28*>
29*> CPPT01 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 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 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 REAL array, dimension (N)
74*> \endverbatim
75*>
76*> \param[out] RESID
77*> \verbatim
78*> RESID is REAL
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 complex_lin
92*
93* =====================================================================
94 SUBROUTINE cppt01( 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 REAL RESID
104* ..
105* .. Array Arguments ..
106 REAL RWORK( * )
107 COMPLEX A( * ), AFAC( * )
108* ..
109*
110* =====================================================================
111*
112* .. Parameters ..
113 REAL ZERO, ONE
114 parameter( zero = 0.0e+0, one = 1.0e+0 )
115* ..
116* .. Local Scalars ..
117 INTEGER I, K, KC
118 REAL ANORM, EPS, TR
119 COMPLEX TC
120* ..
121* .. External Functions ..
122 LOGICAL LSAME
123 REAL CLANHP, SLAMCH
124 COMPLEX CDOTC
125 EXTERNAL lsame, clanhp, slamch, cdotc
126* ..
127* .. External Subroutines ..
128 EXTERNAL chpr, cscal, ctpmv
129* ..
130* .. Intrinsic Functions ..
131 INTRINSIC aimag, real
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 = slamch( 'Epsilon' )
145 anorm = clanhp( '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( aimag( 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( aimag( 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 = real( cdotc( 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 ctpmv( '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 ) - real( 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 chpr( '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 cscal( 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 ) - real( 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 = clanhp( '1', uplo, n, afac, rwork )
240*
241 resid = ( ( resid / real( n ) ) / anorm ) / eps
242*
243 RETURN
244*
245* End of CPPT01
246*
247 END
subroutine cppt01(uplo, n, a, afac, rwork, resid)
CPPT01
Definition cppt01.f:95
subroutine chpr(uplo, n, alpha, x, incx, ap)
CHPR
Definition chpr.f:130
subroutine cscal(n, ca, cx, incx)
CSCAL
Definition cscal.f:78
subroutine ctpmv(uplo, trans, diag, n, ap, x, incx)
CTPMV
Definition ctpmv.f:142