LAPACK  3.6.1 LAPACK: Linear Algebra PACKage
chet01.f
Go to the documentation of this file.
1 *> \brief \b CHET01
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 CHET01( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC,
12 * RWORK, RESID )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER UPLO
16 * INTEGER LDA, LDAFAC, LDC, N
17 * REAL RESID
18 * ..
19 * .. Array Arguments ..
20 * INTEGER IPIV( * )
21 * REAL RWORK( * )
22 * COMPLEX A( LDA, * ), AFAC( LDAFAC, * ), C( LDC, * )
23 * ..
24 *
25 *
26 *> \par Purpose:
27 * =============
28 *>
29 *> \verbatim
30 *>
31 *> CHET01 reconstructs a Hermitian indefinite matrix A from its
32 *> block L*D*L' or U*D*U' factorization and computes the residual
33 *> norm( C - A ) / ( N * norm(A) * EPS ),
34 *> where C is the reconstructed matrix, EPS is the machine epsilon,
35 *> L' is the conjugate transpose of L, and U' is the conjugate transpose
36 *> of U.
37 *> \endverbatim
38 *
39 * Arguments:
40 * ==========
41 *
42 *> \param[in] UPLO
43 *> \verbatim
44 *> UPLO is CHARACTER*1
45 *> Specifies whether the upper or lower triangular part of the
46 *> Hermitian matrix A is stored:
47 *> = 'U': Upper triangular
48 *> = 'L': Lower triangular
49 *> \endverbatim
50 *>
51 *> \param[in] N
52 *> \verbatim
53 *> N is INTEGER
54 *> The number of rows and columns of the matrix A. N >= 0.
55 *> \endverbatim
56 *>
57 *> \param[in] A
58 *> \verbatim
59 *> A is COMPLEX array, dimension (LDA,N)
60 *> The original Hermitian matrix A.
61 *> \endverbatim
62 *>
63 *> \param[in] LDA
64 *> \verbatim
65 *> LDA is INTEGER
66 *> The leading dimension of the array A. LDA >= max(1,N)
67 *> \endverbatim
68 *>
69 *> \param[in] AFAC
70 *> \verbatim
71 *> AFAC is COMPLEX array, dimension (LDAFAC,N)
72 *> The factored form of the matrix A. AFAC contains the block
73 *> diagonal matrix D and the multipliers used to obtain the
74 *> factor L or U from the block L*D*L' or U*D*U' factorization
75 *> as computed by CHETRF.
76 *> \endverbatim
77 *>
78 *> \param[in] LDAFAC
79 *> \verbatim
80 *> LDAFAC is INTEGER
81 *> The leading dimension of the array AFAC. LDAFAC >= max(1,N).
82 *> \endverbatim
83 *>
84 *> \param[in] IPIV
85 *> \verbatim
86 *> IPIV is INTEGER array, dimension (N)
87 *> The pivot indices from CHETRF.
88 *> \endverbatim
89 *>
90 *> \param[out] C
91 *> \verbatim
92 *> C is COMPLEX array, dimension (LDC,N)
93 *> \endverbatim
94 *>
95 *> \param[in] LDC
96 *> \verbatim
97 *> LDC is INTEGER
98 *> The leading dimension of the array C. LDC >= max(1,N).
99 *> \endverbatim
100 *>
101 *> \param[out] RWORK
102 *> \verbatim
103 *> RWORK is REAL array, dimension (N)
104 *> \endverbatim
105 *>
106 *> \param[out] RESID
107 *> \verbatim
108 *> RESID is REAL
109 *> If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
110 *> If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
111 *> \endverbatim
112 *
113 * Authors:
114 * ========
115 *
116 *> \author Univ. of Tennessee
117 *> \author Univ. of California Berkeley
118 *> \author Univ. of Colorado Denver
119 *> \author NAG Ltd.
120 *
121 *> \date November 2013
122 *
123 *> \ingroup complex_lin
124 *
125 * =====================================================================
126  SUBROUTINE chet01( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC,
127  \$ rwork, resid )
128 *
129 * -- LAPACK test routine (version 3.5.0) --
130 * -- LAPACK is a software package provided by Univ. of Tennessee, --
131 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
132 * November 2013
133 *
134 * .. Scalar Arguments ..
135  CHARACTER UPLO
136  INTEGER LDA, LDAFAC, LDC, N
137  REAL RESID
138 * ..
139 * .. Array Arguments ..
140  INTEGER IPIV( * )
141  REAL RWORK( * )
142  COMPLEX A( lda, * ), AFAC( ldafac, * ), C( ldc, * )
143 * ..
144 *
145 * =====================================================================
146 *
147 * .. Parameters ..
148  REAL ZERO, ONE
149  parameter ( zero = 0.0e+0, one = 1.0e+0 )
150  COMPLEX CZERO, CONE
151  parameter ( czero = ( 0.0e+0, 0.0e+0 ),
152  \$ cone = ( 1.0e+0, 0.0e+0 ) )
153 * ..
154 * .. Local Scalars ..
155  INTEGER I, INFO, J
156  REAL ANORM, EPS
157 * ..
158 * .. External Functions ..
159  LOGICAL LSAME
160  REAL CLANHE, SLAMCH
161  EXTERNAL lsame, clanhe, slamch
162 * ..
163 * .. External Subroutines ..
164  EXTERNAL clavhe, claset
165 * ..
166 * .. Intrinsic Functions ..
167  INTRINSIC aimag, real
168 * ..
169 * .. Executable Statements ..
170 *
171 * Quick exit if N = 0.
172 *
173  IF( n.LE.0 ) THEN
174  resid = zero
175  RETURN
176  END IF
177 *
178 * Determine EPS and the norm of A.
179 *
180  eps = slamch( 'Epsilon' )
181  anorm = clanhe( '1', uplo, n, a, lda, rwork )
182 *
183 * Check the imaginary parts of the diagonal elements and return with
184 * an error code if any are nonzero.
185 *
186  DO 10 j = 1, n
187  IF( aimag( afac( j, j ) ).NE.zero ) THEN
188  resid = one / eps
189  RETURN
190  END IF
191  10 CONTINUE
192 *
193 * Initialize C to the identity matrix.
194 *
195  CALL claset( 'Full', n, n, czero, cone, c, ldc )
196 *
197 * Call CLAVHE to form the product D * U' (or D * L' ).
198 *
199  CALL clavhe( uplo, 'Conjugate', 'Non-unit', n, n, afac, ldafac,
200  \$ ipiv, c, ldc, info )
201 *
202 * Call CLAVHE again to multiply by U (or L ).
203 *
204  CALL clavhe( uplo, 'No transpose', 'Unit', n, n, afac, ldafac,
205  \$ ipiv, c, ldc, info )
206 *
207 * Compute the difference C - A .
208 *
209  IF( lsame( uplo, 'U' ) ) THEN
210  DO 30 j = 1, n
211  DO 20 i = 1, j - 1
212  c( i, j ) = c( i, j ) - a( i, j )
213  20 CONTINUE
214  c( j, j ) = c( j, j ) - REAL( A( J, J ) )
215  30 CONTINUE
216  ELSE
217  DO 50 j = 1, n
218  c( j, j ) = c( j, j ) - REAL( A( J, J ) )
219  DO 40 i = j + 1, n
220  c( i, j ) = c( i, j ) - a( i, j )
221  40 CONTINUE
222  50 CONTINUE
223  END IF
224 *
225 * Compute norm( C - A ) / ( N * norm(A) * EPS )
226 *
227  resid = clanhe( '1', uplo, n, c, ldc, rwork )
228 *
229  IF( anorm.LE.zero ) THEN
230  IF( resid.NE.zero )
231  \$ resid = one / eps
232  ELSE
233  resid = ( ( resid / REAL( N ) ) / anorm ) / eps
234  END IF
235 *
236  RETURN
237 *
238 * End of CHET01
239 *
240  END
subroutine claset(UPLO, M, N, ALPHA, BETA, A, LDA)
CLASET initializes the off-diagonal elements and the diagonal elements of a matrix to given values...
Definition: claset.f:108
subroutine chet01(UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC, RWORK, RESID)
CHET01
Definition: chet01.f:128
subroutine clavhe(UPLO, TRANS, DIAG, N, NRHS, A, LDA, IPIV, B, LDB, INFO)
CLAVHE
Definition: clavhe.f:155