MAGMA  1.2.0
MatrixAlgebraonGPUandMulticoreArchitectures
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
chet01.f
Go to the documentation of this file.
1  SUBROUTINE chet01( UPLO, N, A, LDA, AFAC, LDAFAC, IPIV, C, LDC,
2  $ rwork, resid )
3 *
4 * -- LAPACK test routine (version 3.1) --
5 * Univ. of Tennessee, Univ. of California Berkeley and NAG Ltd..
6 * November 2006
7 *
8 * .. Scalar Arguments ..
9  CHARACTER uplo
10  INTEGER lda, ldafac, ldc, n
11  REAL resid
12 * ..
13 * .. Array Arguments ..
14  INTEGER ipiv( * )
15  REAL rwork( * )
16  COMPLEX a( lda, * ), afac( ldafac, * ), c( ldc, * )
17 * ..
18 *
19 * Purpose
20 * =======
21 *
22 * CHET01 reconstructs a Hermitian indefinite matrix A from its
23 * block L*D*L' or U*D*U' factorization and computes the residual
24 * norm( C - A ) / ( N * norm(A) * EPS ),
25 * where C is the reconstructed matrix, EPS is the machine epsilon,
26 * L' is the conjugate transpose of L, and U' is the conjugate transpose
27 * of U.
28 *
29 * Arguments
30 * ==========
31 *
32 * UPLO (input) CHARACTER*1
33 * Specifies whether the upper or lower triangular part of the
34 * Hermitian matrix A is stored:
35 * = 'U': Upper triangular
36 * = 'L': Lower triangular
37 *
38 * N (input) INTEGER
39 * The number of rows and columns of the matrix A. N >= 0.
40 *
41 * A (input) COMPLEX array, dimension (LDA,N)
42 * The original Hermitian matrix A.
43 *
44 * LDA (input) INTEGER
45 * The leading dimension of the array A. LDA >= max(1,N)
46 *
47 * AFAC (input) COMPLEX array, dimension (LDAFAC,N)
48 * The factored form of the matrix A. AFAC contains the block
49 * diagonal matrix D and the multipliers used to obtain the
50 * factor L or U from the block L*D*L' or U*D*U' factorization
51 * as computed by CHETRF.
52 *
53 * LDAFAC (input) INTEGER
54 * The leading dimension of the array AFAC. LDAFAC >= max(1,N).
55 *
56 * IPIV (input) INTEGER array, dimension (N)
57 * The pivot indices from CHETRF.
58 *
59 * C (workspace) COMPLEX array, dimension (LDC,N)
60 *
61 * LDC (integer) INTEGER
62 * The leading dimension of the array C. LDC >= max(1,N).
63 *
64 * RWORK (workspace) REAL array, dimension (N)
65 *
66 * RESID (output) REAL
67 * If UPLO = 'L', norm(L*D*L' - A) / ( N * norm(A) * EPS )
68 * If UPLO = 'U', norm(U*D*U' - A) / ( N * norm(A) * EPS )
69 *
70 * =====================================================================
71 *
72 * .. Parameters ..
73  REAL zero, one
74  parameter( zero = 0.0e+0, one = 1.0e+0 )
75  COMPLEX czero, cone
76  parameter( czero = ( 0.0e+0, 0.0e+0 ),
77  $ cone = ( 1.0e+0, 0.0e+0 ) )
78 * ..
79 * .. Local Scalars ..
80  INTEGER i, info, j
81  REAL anorm, eps
82 * ..
83 * .. External Functions ..
84  LOGICAL lsame
85  REAL clanhe, slamch
86  EXTERNAL lsame, clanhe, slamch
87 * ..
88 * .. External Subroutines ..
89  EXTERNAL clavhe, claset
90 * ..
91 * .. Intrinsic Functions ..
92  INTRINSIC aimag, real
93 * ..
94 * .. Executable Statements ..
95 *
96 * Quick exit if N = 0.
97 *
98  IF( n.LE.0 ) THEN
99  resid = zero
100  return
101  END IF
102 *
103 * Determine EPS and the norm of A.
104 *
105  eps = slamch( 'Epsilon' )
106  anorm = clanhe( '1', uplo, n, a, lda, rwork )
107 *
108 * Check the imaginary parts of the diagonal elements and return with
109 * an error code if any are nonzero.
110 *
111  DO 10 j = 1, n
112  IF( aimag( afac( j, j ) ).NE.zero ) THEN
113  resid = one / eps
114  return
115  END IF
116  10 continue
117 *
118 * Initialize C to the identity matrix.
119 *
120  CALL claset( 'Full', n, n, czero, cone, c, ldc )
121 *
122 * Call CLAVHE to form the product D * U' (or D * L' ).
123 *
124  CALL clavhe( uplo, 'Conjugate', 'Non-unit', n, n, afac, ldafac,
125  $ ipiv, c, ldc, info )
126 *
127 * Call CLAVHE again to multiply by U (or L ).
128 *
129  CALL clavhe( uplo, 'No transpose', 'Unit', n, n, afac, ldafac,
130  $ ipiv, c, ldc, info )
131 *
132 * Compute the difference C - A .
133 *
134  IF( lsame( uplo, 'U' ) ) THEN
135  DO 30 j = 1, n
136  DO 20 i = 1, j - 1
137  c( i, j ) = c( i, j ) - a( i, j )
138  20 continue
139  c( j, j ) = c( j, j ) - REAL( A( J, J ) )
140  30 continue
141  ELSE
142  DO 50 j = 1, n
143  c( j, j ) = c( j, j ) - REAL( A( J, J ) )
144  DO 40 i = j + 1, n
145  c( i, j ) = c( i, j ) - a( i, j )
146  40 continue
147  50 continue
148  END IF
149 *
150 * Compute norm( C - A ) / ( N * norm(A) * EPS )
151 *
152  resid = clanhe( '1', uplo, n, c, ldc, rwork )
153 *
154  IF( anorm.LE.zero ) THEN
155  IF( resid.NE.zero )
156  $ resid = one / eps
157  ELSE
158  resid = ( ( resid / REAL( N ) ) / anorm ) / eps
159  END IF
160 *
161  return
162 *
163 * End of CHET01
164 *
165  END