LAPACK  3.9.0
LAPACK: Linear Algebra PACKage
zhbt21.f
Go to the documentation of this file.
1 *> \brief \b ZHBT21
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 ZHBT21( UPLO, N, KA, KS, A, LDA, D, E, U, LDU, WORK,
12 * RWORK, RESULT )
13 *
14 * .. Scalar Arguments ..
15 * CHARACTER UPLO
16 * INTEGER KA, KS, LDA, LDU, N
17 * ..
18 * .. Array Arguments ..
19 * DOUBLE PRECISION D( * ), E( * ), RESULT( 2 ), RWORK( * )
20 * COMPLEX*16 A( LDA, * ), U( LDU, * ), WORK( * )
21 * ..
22 *
23 *
24 *> \par Purpose:
25 * =============
26 *>
27 *> \verbatim
28 *>
29 *> ZHBT21 generally checks a decomposition of the form
30 *>
31 *> A = U S U**H
32 *>
33 *> where **H means conjugate transpose, A is hermitian banded, U is
34 *> unitary, and S is diagonal (if KS=0) or symmetric
35 *> tridiagonal (if KS=1).
36 *>
37 *> Specifically:
38 *>
39 *> RESULT(1) = | A - U S U**H | / ( |A| n ulp ) and
40 *> RESULT(2) = | I - U U**H | / ( n ulp )
41 *> \endverbatim
42 *
43 * Arguments:
44 * ==========
45 *
46 *> \param[in] UPLO
47 *> \verbatim
48 *> UPLO is CHARACTER
49 *> If UPLO='U', the upper triangle of A and V will be used and
50 *> the (strictly) lower triangle will not be referenced.
51 *> If UPLO='L', the lower triangle of A and V will be used and
52 *> the (strictly) upper triangle will not be referenced.
53 *> \endverbatim
54 *>
55 *> \param[in] N
56 *> \verbatim
57 *> N is INTEGER
58 *> The size of the matrix. If it is zero, ZHBT21 does nothing.
59 *> It must be at least zero.
60 *> \endverbatim
61 *>
62 *> \param[in] KA
63 *> \verbatim
64 *> KA is INTEGER
65 *> The bandwidth of the matrix A. It must be at least zero. If
66 *> it is larger than N-1, then max( 0, N-1 ) will be used.
67 *> \endverbatim
68 *>
69 *> \param[in] KS
70 *> \verbatim
71 *> KS is INTEGER
72 *> The bandwidth of the matrix S. It may only be zero or one.
73 *> If zero, then S is diagonal, and E is not referenced. If
74 *> one, then S is symmetric tri-diagonal.
75 *> \endverbatim
76 *>
77 *> \param[in] A
78 *> \verbatim
79 *> A is COMPLEX*16 array, dimension (LDA, N)
80 *> The original (unfactored) matrix. It is assumed to be
81 *> hermitian, and only the upper (UPLO='U') or only the lower
82 *> (UPLO='L') will be referenced.
83 *> \endverbatim
84 *>
85 *> \param[in] LDA
86 *> \verbatim
87 *> LDA is INTEGER
88 *> The leading dimension of A. It must be at least 1
89 *> and at least min( KA, N-1 ).
90 *> \endverbatim
91 *>
92 *> \param[in] D
93 *> \verbatim
94 *> D is DOUBLE PRECISION array, dimension (N)
95 *> The diagonal of the (symmetric tri-) diagonal matrix S.
96 *> \endverbatim
97 *>
98 *> \param[in] E
99 *> \verbatim
100 *> E is DOUBLE PRECISION array, dimension (N-1)
101 *> The off-diagonal of the (symmetric tri-) diagonal matrix S.
102 *> E(1) is the (1,2) and (2,1) element, E(2) is the (2,3) and
103 *> (3,2) element, etc.
104 *> Not referenced if KS=0.
105 *> \endverbatim
106 *>
107 *> \param[in] U
108 *> \verbatim
109 *> U is COMPLEX*16 array, dimension (LDU, N)
110 *> The unitary matrix in the decomposition, expressed as a
111 *> dense matrix (i.e., not as a product of Householder
112 *> transformations, Givens transformations, etc.)
113 *> \endverbatim
114 *>
115 *> \param[in] LDU
116 *> \verbatim
117 *> LDU is INTEGER
118 *> The leading dimension of U. LDU must be at least N and
119 *> at least 1.
120 *> \endverbatim
121 *>
122 *> \param[out] WORK
123 *> \verbatim
124 *> WORK is COMPLEX*16 array, dimension (N**2)
125 *> \endverbatim
126 *>
127 *> \param[out] RWORK
128 *> \verbatim
129 *> RWORK is DOUBLE PRECISION array, dimension (N)
130 *> \endverbatim
131 *>
132 *> \param[out] RESULT
133 *> \verbatim
134 *> RESULT is DOUBLE PRECISION array, dimension (2)
135 *> The values computed by the two tests described above. The
136 *> values are currently limited to 1/ulp, to avoid overflow.
137 *> \endverbatim
138 *
139 * Authors:
140 * ========
141 *
142 *> \author Univ. of Tennessee
143 *> \author Univ. of California Berkeley
144 *> \author Univ. of Colorado Denver
145 *> \author NAG Ltd.
146 *
147 *> \date December 2016
148 *
149 *> \ingroup complex16_eig
150 *
151 * =====================================================================
152  SUBROUTINE zhbt21( UPLO, N, KA, KS, A, LDA, D, E, U, LDU, WORK,
153  $ RWORK, RESULT )
154 *
155 * -- LAPACK test routine (version 3.7.0) --
156 * -- LAPACK is a software package provided by Univ. of Tennessee, --
157 * -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
158 * December 2016
159 *
160 * .. Scalar Arguments ..
161  CHARACTER UPLO
162  INTEGER KA, KS, LDA, LDU, N
163 * ..
164 * .. Array Arguments ..
165  DOUBLE PRECISION D( * ), E( * ), RESULT( 2 ), RWORK( * )
166  COMPLEX*16 A( LDA, * ), U( LDU, * ), WORK( * )
167 * ..
168 *
169 * =====================================================================
170 *
171 * .. Parameters ..
172  COMPLEX*16 CZERO, CONE
173  parameter( czero = ( 0.0d+0, 0.0d+0 ),
174  $ cone = ( 1.0d+0, 0.0d+0 ) )
175  DOUBLE PRECISION ZERO, ONE
176  parameter( zero = 0.0d+0, one = 1.0d+0 )
177 * ..
178 * .. Local Scalars ..
179  LOGICAL LOWER
180  CHARACTER CUPLO
181  INTEGER IKA, J, JC, JR
182  DOUBLE PRECISION ANORM, ULP, UNFL, WNORM
183 * ..
184 * .. External Functions ..
185  LOGICAL LSAME
186  DOUBLE PRECISION DLAMCH, ZLANGE, ZLANHB, ZLANHP
187  EXTERNAL lsame, dlamch, zlange, zlanhb, zlanhp
188 * ..
189 * .. External Subroutines ..
190  EXTERNAL zgemm, zhpr, zhpr2
191 * ..
192 * .. Intrinsic Functions ..
193  INTRINSIC dble, dcmplx, max, min
194 * ..
195 * .. Executable Statements ..
196 *
197 * Constants
198 *
199  result( 1 ) = zero
200  result( 2 ) = zero
201  IF( n.LE.0 )
202  $ RETURN
203 *
204  ika = max( 0, min( n-1, ka ) )
205 *
206  IF( lsame( uplo, 'U' ) ) THEN
207  lower = .false.
208  cuplo = 'U'
209  ELSE
210  lower = .true.
211  cuplo = 'L'
212  END IF
213 *
214  unfl = dlamch( 'Safe minimum' )
215  ulp = dlamch( 'Epsilon' )*dlamch( 'Base' )
216 *
217 * Some Error Checks
218 *
219 * Do Test 1
220 *
221 * Norm of A:
222 *
223  anorm = max( zlanhb( '1', cuplo, n, ika, a, lda, rwork ), unfl )
224 *
225 * Compute error matrix: Error = A - U S U**H
226 *
227 * Copy A from SB to SP storage format.
228 *
229  j = 0
230  DO 50 jc = 1, n
231  IF( lower ) THEN
232  DO 10 jr = 1, min( ika+1, n+1-jc )
233  j = j + 1
234  work( j ) = a( jr, jc )
235  10 CONTINUE
236  DO 20 jr = ika + 2, n + 1 - jc
237  j = j + 1
238  work( j ) = zero
239  20 CONTINUE
240  ELSE
241  DO 30 jr = ika + 2, jc
242  j = j + 1
243  work( j ) = zero
244  30 CONTINUE
245  DO 40 jr = min( ika, jc-1 ), 0, -1
246  j = j + 1
247  work( j ) = a( ika+1-jr, jc )
248  40 CONTINUE
249  END IF
250  50 CONTINUE
251 *
252  DO 60 j = 1, n
253  CALL zhpr( cuplo, n, -d( j ), u( 1, j ), 1, work )
254  60 CONTINUE
255 *
256  IF( n.GT.1 .AND. ks.EQ.1 ) THEN
257  DO 70 j = 1, n - 1
258  CALL zhpr2( cuplo, n, -dcmplx( e( j ) ), u( 1, j ), 1,
259  $ u( 1, j+1 ), 1, work )
260  70 CONTINUE
261  END IF
262  wnorm = zlanhp( '1', cuplo, n, work, rwork )
263 *
264  IF( anorm.GT.wnorm ) THEN
265  result( 1 ) = ( wnorm / anorm ) / ( n*ulp )
266  ELSE
267  IF( anorm.LT.one ) THEN
268  result( 1 ) = ( min( wnorm, n*anorm ) / anorm ) / ( n*ulp )
269  ELSE
270  result( 1 ) = min( wnorm / anorm, dble( n ) ) / ( n*ulp )
271  END IF
272  END IF
273 *
274 * Do Test 2
275 *
276 * Compute U U**H - I
277 *
278  CALL zgemm( 'N', 'C', n, n, n, cone, u, ldu, u, ldu, czero, work,
279  $ n )
280 *
281  DO 80 j = 1, n
282  work( ( n+1 )*( j-1 )+1 ) = work( ( n+1 )*( j-1 )+1 ) - cone
283  80 CONTINUE
284 *
285  result( 2 ) = min( zlange( '1', n, n, work, n, rwork ),
286  $ dble( n ) ) / ( n*ulp )
287 *
288  RETURN
289 *
290 * End of ZHBT21
291 *
292  END
zhbt21
subroutine zhbt21(UPLO, N, KA, KS, A, LDA, D, E, U, LDU, WORK, RWORK, RESULT)
ZHBT21
Definition: zhbt21.f:154
zhpr2
subroutine zhpr2(UPLO, N, ALPHA, X, INCX, Y, INCY, AP)
ZHPR2
Definition: zhpr2.f:147
zgemm
subroutine zgemm(TRANSA, TRANSB, M, N, K, ALPHA, A, LDA, B, LDB, BETA, C, LDC)
ZGEMM
Definition: zgemm.f:189
zhpr
subroutine zhpr(UPLO, N, ALPHA, X, INCX, AP)
ZHPR
Definition: zhpr.f:132