LAPACK 3.12.1
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
cheev_2stage.f
Go to the documentation of this file.
1*> \brief <b> CHEEV_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matrices</b>
2*
3* @generated from zheev_2stage.f, fortran z -> c, Sat Nov 5 23:18:06 2016
4*
5* =========== DOCUMENTATION ===========
6*
7* Online html documentation available at
8* http://www.netlib.org/lapack/explore-html/
9*
10*> Download CHEEV_2STAGE + dependencies
11*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.tgz?format=tgz&filename=/lapack/lapack_routine/cheev_2stage.f">
12*> [TGZ]</a>
13*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.zip?format=zip&filename=/lapack/lapack_routine/cheev_2stage.f">
14*> [ZIP]</a>
15*> <a href="http://www.netlib.org/cgi-bin/netlibfiles.txt?format=txt&filename=/lapack/lapack_routine/cheev_2stage.f">
16*> [TXT]</a>
17*
18* Definition:
19* ===========
20*
21* SUBROUTINE CHEEV_2STAGE( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK,
22* RWORK, INFO )
23*
24* IMPLICIT NONE
25*
26* .. Scalar Arguments ..
27* CHARACTER JOBZ, UPLO
28* INTEGER INFO, LDA, LWORK, N
29* ..
30* .. Array Arguments ..
31* REAL RWORK( * ), W( * )
32* COMPLEX A( LDA, * ), WORK( * )
33* ..
34*
35*
36*> \par Purpose:
37* =============
38*>
39*> \verbatim
40*>
41*> CHEEV_2STAGE computes all eigenvalues and, optionally, eigenvectors of a
42*> complex Hermitian matrix A using the 2stage technique for
43*> the reduction to tridiagonal.
44*> \endverbatim
45*
46* Arguments:
47* ==========
48*
49*> \param[in] JOBZ
50*> \verbatim
51*> JOBZ is CHARACTER*1
52*> = 'N': Compute eigenvalues only;
53*> = 'V': Compute eigenvalues and eigenvectors.
54*> Not available in this release.
55*> \endverbatim
56*>
57*> \param[in] UPLO
58*> \verbatim
59*> UPLO is CHARACTER*1
60*> = 'U': Upper triangle of A is stored;
61*> = 'L': Lower triangle of A is stored.
62*> \endverbatim
63*>
64*> \param[in] N
65*> \verbatim
66*> N is INTEGER
67*> The order of the matrix A. N >= 0.
68*> \endverbatim
69*>
70*> \param[in,out] A
71*> \verbatim
72*> A is COMPLEX array, dimension (LDA, N)
73*> On entry, the Hermitian matrix A. If UPLO = 'U', the
74*> leading N-by-N upper triangular part of A contains the
75*> upper triangular part of the matrix A. If UPLO = 'L',
76*> the leading N-by-N lower triangular part of A contains
77*> the lower triangular part of the matrix A.
78*> On exit, if JOBZ = 'V', then if INFO = 0, A contains the
79*> orthonormal eigenvectors of the matrix A.
80*> If JOBZ = 'N', then on exit the lower triangle (if UPLO='L')
81*> or the upper triangle (if UPLO='U') of A, including the
82*> diagonal, is destroyed.
83*> \endverbatim
84*>
85*> \param[in] LDA
86*> \verbatim
87*> LDA is INTEGER
88*> The leading dimension of the array A. LDA >= max(1,N).
89*> \endverbatim
90*>
91*> \param[out] W
92*> \verbatim
93*> W is REAL array, dimension (N)
94*> If INFO = 0, the eigenvalues in ascending order.
95*> \endverbatim
96*>
97*> \param[out] WORK
98*> \verbatim
99*> WORK is COMPLEX array, dimension (MAX(1,LWORK))
100*> On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
101*> \endverbatim
102*>
103*> \param[in] LWORK
104*> \verbatim
105*> LWORK is INTEGER
106*> The length of the array WORK. LWORK >= 1, when N <= 1;
107*> otherwise
108*> If JOBZ = 'N' and N > 1, LWORK must be queried.
109*> LWORK = MAX(1, dimension) where
110*> dimension = max(stage1,stage2) + (KD+1)*N + N
111*> = N*KD + N*max(KD+1,FACTOPTNB)
112*> + max(2*KD*KD, KD*NTHREADS)
113*> + (KD+1)*N + N
114*> where KD is the blocking size of the reduction,
115*> FACTOPTNB is the blocking used by the QR or LQ
116*> algorithm, usually FACTOPTNB=128 is a good choice
117*> NTHREADS is the number of threads used when
118*> openMP compilation is enabled, otherwise =1.
119*> If JOBZ = 'V' and N > 1, LWORK must be queried. Not yet available
120*>
121*> If LWORK = -1, then a workspace query is assumed; the routine
122*> only calculates the optimal size of the WORK array, returns
123*> this value as the first entry of the WORK array, and no error
124*> message related to LWORK is issued by XERBLA.
125*> \endverbatim
126*>
127*> \param[out] RWORK
128*> \verbatim
129*> RWORK is REAL array, dimension (max(1, 3*N-2))
130*> \endverbatim
131*>
132*> \param[out] INFO
133*> \verbatim
134*> INFO is INTEGER
135*> = 0: successful exit
136*> < 0: if INFO = -i, the i-th argument had an illegal value
137*> > 0: if INFO = i, the algorithm failed to converge; i
138*> off-diagonal elements of an intermediate tridiagonal
139*> form did not converge to zero.
140*> \endverbatim
141*
142* Authors:
143* ========
144*
145*> \author Univ. of Tennessee
146*> \author Univ. of California Berkeley
147*> \author Univ. of Colorado Denver
148*> \author NAG Ltd.
149*
150*> \ingroup heev_2stage
151*
152*> \par Further Details:
153* =====================
154*>
155*> \verbatim
156*>
157*> All details about the 2stage techniques are available in:
158*>
159*> Azzam Haidar, Hatem Ltaief, and Jack Dongarra.
160*> Parallel reduction to condensed forms for symmetric eigenvalue problems
161*> using aggregated fine-grained and memory-aware kernels. In Proceedings
162*> of 2011 International Conference for High Performance Computing,
163*> Networking, Storage and Analysis (SC '11), New York, NY, USA,
164*> Article 8 , 11 pages.
165*> http://doi.acm.org/10.1145/2063384.2063394
166*>
167*> A. Haidar, J. Kurzak, P. Luszczek, 2013.
168*> An improved parallel singular value algorithm and its implementation
169*> for multicore hardware, In Proceedings of 2013 International Conference
170*> for High Performance Computing, Networking, Storage and Analysis (SC '13).
171*> Denver, Colorado, USA, 2013.
172*> Article 90, 12 pages.
173*> http://doi.acm.org/10.1145/2503210.2503292
174*>
175*> A. Haidar, R. Solca, S. Tomov, T. Schulthess and J. Dongarra.
176*> A novel hybrid CPU-GPU generalized eigensolver for electronic structure
177*> calculations based on fine-grained memory aware tasks.
178*> International Journal of High Performance Computing Applications.
179*> Volume 28 Issue 2, Pages 196-209, May 2014.
180*> http://hpc.sagepub.com/content/28/2/196
181*>
182*> \endverbatim
183*
184* =====================================================================
185 SUBROUTINE cheev_2stage( JOBZ, UPLO, N, A, LDA, W, WORK, LWORK,
186 $ RWORK, INFO )
187*
188 IMPLICIT NONE
189*
190* -- LAPACK driver routine --
191* -- LAPACK is a software package provided by Univ. of Tennessee, --
192* -- Univ. of California Berkeley, Univ. of Colorado Denver and NAG Ltd..--
193*
194* .. Scalar Arguments ..
195 CHARACTER JOBZ, UPLO
196 INTEGER INFO, LDA, LWORK, N
197* ..
198* .. Array Arguments ..
199 REAL RWORK( * ), W( * )
200 COMPLEX A( LDA, * ), WORK( * )
201* ..
202*
203* =====================================================================
204*
205* .. Parameters ..
206 REAL ZERO, ONE
207 parameter( zero = 0.0e0, one = 1.0e0 )
208 COMPLEX CONE
209 parameter( cone = ( 1.0e0, 0.0e0 ) )
210* ..
211* .. Local Scalars ..
212 LOGICAL LOWER, LQUERY, WANTZ
213 INTEGER IINFO, IMAX, INDE, INDTAU, INDWRK, ISCALE,
214 $ llwork, lwmin, lhtrd, lwtrd, kd, ib, indhous
215 REAL ANRM, BIGNUM, EPS, RMAX, RMIN, SAFMIN, SIGMA,
216 $ smlnum
217* ..
218* .. External Functions ..
219 LOGICAL LSAME
220 INTEGER ILAENV2STAGE
221 REAL SLAMCH, CLANHE, SROUNDUP_LWORK
222 EXTERNAL lsame, slamch, clanhe, ilaenv2stage,
223 $ sroundup_lwork
224* ..
225* .. External Subroutines ..
226 EXTERNAL sscal, ssterf, xerbla, clascl,
227 $ csteqr,
229* ..
230* .. Intrinsic Functions ..
231 INTRINSIC real, max, sqrt
232* ..
233* .. Executable Statements ..
234*
235* Test the input parameters.
236*
237 wantz = lsame( jobz, 'V' )
238 lower = lsame( uplo, 'L' )
239 lquery = ( lwork.EQ.-1 )
240*
241 info = 0
242 IF( .NOT.( lsame( jobz, 'N' ) ) ) THEN
243 info = -1
244 ELSE IF( .NOT.( lower .OR. lsame( uplo, 'U' ) ) ) THEN
245 info = -2
246 ELSE IF( n.LT.0 ) THEN
247 info = -3
248 ELSE IF( lda.LT.max( 1, n ) ) THEN
249 info = -5
250 END IF
251*
252 IF( info.EQ.0 ) THEN
253 kd = ilaenv2stage( 1, 'CHETRD_2STAGE', jobz, n, -1, -1,
254 $ -1 )
255 ib = ilaenv2stage( 2, 'CHETRD_2STAGE', jobz, n, kd, -1,
256 $ -1 )
257 lhtrd = ilaenv2stage( 3, 'CHETRD_2STAGE', jobz, n, kd, ib,
258 $ -1 )
259 lwtrd = ilaenv2stage( 4, 'CHETRD_2STAGE', jobz, n, kd, ib,
260 $ -1 )
261 lwmin = n + lhtrd + lwtrd
262 work( 1 ) = sroundup_lwork(lwmin)
263*
264 IF( lwork.LT.lwmin .AND. .NOT.lquery )
265 $ info = -8
266 END IF
267*
268 IF( info.NE.0 ) THEN
269 CALL xerbla( 'CHEEV_2STAGE ', -info )
270 RETURN
271 ELSE IF( lquery ) THEN
272 RETURN
273 END IF
274*
275* Quick return if possible
276*
277 IF( n.EQ.0 ) THEN
278 RETURN
279 END IF
280*
281 IF( n.EQ.1 ) THEN
282 w( 1 ) = real( a( 1, 1 ) )
283 work( 1 ) = 1
284 IF( wantz )
285 $ a( 1, 1 ) = cone
286 RETURN
287 END IF
288*
289* Get machine constants.
290*
291 safmin = slamch( 'Safe minimum' )
292 eps = slamch( 'Precision' )
293 smlnum = safmin / eps
294 bignum = one / smlnum
295 rmin = sqrt( smlnum )
296 rmax = sqrt( bignum )
297*
298* Scale matrix to allowable range, if necessary.
299*
300 anrm = clanhe( 'M', uplo, n, a, lda, rwork )
301 iscale = 0
302 IF( anrm.GT.zero .AND. anrm.LT.rmin ) THEN
303 iscale = 1
304 sigma = rmin / anrm
305 ELSE IF( anrm.GT.rmax ) THEN
306 iscale = 1
307 sigma = rmax / anrm
308 END IF
309 IF( iscale.EQ.1 )
310 $ CALL clascl( uplo, 0, 0, one, sigma, n, n, a, lda, info )
311*
312* Call CHETRD_2STAGE to reduce Hermitian matrix to tridiagonal form.
313*
314 inde = 1
315 indtau = 1
316 indhous = indtau + n
317 indwrk = indhous + lhtrd
318 llwork = lwork - indwrk + 1
319*
320 CALL chetrd_2stage( jobz, uplo, n, a, lda, w, rwork( inde ),
321 $ work( indtau ), work( indhous ), lhtrd,
322 $ work( indwrk ), llwork, iinfo )
323*
324* For eigenvalues only, call SSTERF. For eigenvectors, first call
325* CUNGTR to generate the unitary matrix, then call CSTEQR.
326*
327 IF( .NOT.wantz ) THEN
328 CALL ssterf( n, w, rwork( inde ), info )
329 ELSE
330 CALL cungtr( uplo, n, a, lda, work( indtau ),
331 $ work( indwrk ),
332 $ llwork, iinfo )
333 indwrk = inde + n
334 CALL csteqr( jobz, n, w, rwork( inde ), a, lda,
335 $ rwork( indwrk ), info )
336 END IF
337*
338* If matrix was scaled, then rescale eigenvalues appropriately.
339*
340 IF( iscale.EQ.1 ) THEN
341 IF( info.EQ.0 ) THEN
342 imax = n
343 ELSE
344 imax = info - 1
345 END IF
346 CALL sscal( imax, one / sigma, w, 1 )
347 END IF
348*
349* Set WORK(1) to optimal complex workspace size.
350*
351 work( 1 ) = sroundup_lwork(lwmin)
352*
353 RETURN
354*
355* End of CHEEV_2STAGE
356*
357 END
subroutine xerbla(srname, info)
Definition cblat2.f:3285
subroutine cheev_2stage(jobz, uplo, n, a, lda, w, work, lwork, rwork, info)
CHEEV_2STAGE computes the eigenvalues and, optionally, the left and/or right eigenvectors for HE matr...
subroutine chetrd_2stage(vect, uplo, n, a, lda, d, e, tau, hous2, lhous2, work, lwork, info)
CHETRD_2STAGE
subroutine clascl(type, kl, ku, cfrom, cto, m, n, a, lda, info)
CLASCL multiplies a general rectangular matrix by a real scalar defined as cto/cfrom.
Definition clascl.f:142
subroutine sscal(n, sa, sx, incx)
SSCAL
Definition sscal.f:79
subroutine csteqr(compz, n, d, e, z, ldz, work, info)
CSTEQR
Definition csteqr.f:130
subroutine ssterf(n, d, e, info)
SSTERF
Definition ssterf.f:84
subroutine cungtr(uplo, n, a, lda, tau, work, lwork, info)
CUNGTR
Definition cungtr.f:121