SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
All Classes Files Functions Variables Typedefs Macros
pzhegst.f
Go to the documentation of this file.
1*
2*
3 SUBROUTINE pzhegst( IBTYPE, UPLO, N, A, IA, JA, DESCA, B, IB, JB,
4 $ DESCB, SCALE, INFO )
5*
6* -- ScaLAPACK routine (version 1.7) --
7* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
8* and University of California, Berkeley.
9* May 1, 1997
10*
11* .. Scalar Arguments ..
12 CHARACTER UPLO
13 INTEGER IA, IB, IBTYPE, INFO, JA, JB, N
14 DOUBLE PRECISION SCALE
15* ..
16* .. Array Arguments ..
17 INTEGER DESCA( * ), DESCB( * )
18 COMPLEX*16 A( * ), B( * )
19* ..
20*
21* Purpose
22* =======
23*
24* PZHEGST reduces a complex Hermitian-definite generalized eigenproblem
25* to standard form.
26*
27* In the following sub( A ) denotes A( IA:IA+N-1, JA:JA+N-1 ) and
28* sub( B ) denotes B( IB:IB+N-1, JB:JB+N-1 ).
29*
30* If IBTYPE = 1, the problem is sub( A )*x = lambda*sub( B )*x,
31* and sub( A ) is overwritten by inv(U**H)*sub( A )*inv(U) or
32* inv(L)*sub( A )*inv(L**H)
33*
34* If IBTYPE = 2 or 3, the problem is sub( A )*sub( B )*x = lambda*x or
35* sub( B )*sub( A )*x = lambda*x, and sub( A ) is overwritten by
36* U*sub( A )*U**H or L**H*sub( A )*L.
37*
38* sub( B ) must have been previously factorized as U**H*U or L*L**H by
39* PZPOTRF.
40*
41* Notes
42* =====
43*
44* Each global data object is described by an associated description
45* vector. This vector stores the information required to establish
46* the mapping between an object element and its corresponding process
47* and memory location.
48*
49* Let A be a generic term for any 2D block cyclicly distributed array.
50* Such a global array has an associated description vector DESCA.
51* In the following comments, the character _ should be read as
52* "of the global array".
53*
54* NOTATION STORED IN EXPLANATION
55* --------------- -------------- --------------------------------------
56* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
57* DTYPE_A = 1.
58* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
59* the BLACS process grid A is distribu-
60* ted over. The context itself is glo-
61* bal, but the handle (the integer
62* value) may vary.
63* M_A (global) DESCA( M_ ) The number of rows in the global
64* array A.
65* N_A (global) DESCA( N_ ) The number of columns in the global
66* array A.
67* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
68* the rows of the array.
69* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
70* the columns of the array.
71* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
72* row of the array A is distributed.
73* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
74* first column of the array A is
75* distributed.
76* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
77* array. LLD_A >= MAX(1,LOCr(M_A)).
78*
79* Let K be the number of rows or columns of a distributed matrix,
80* and assume that its process grid has dimension p x q.
81* LOCr( K ) denotes the number of elements of K that a process
82* would receive if K were distributed over the p processes of its
83* process column.
84* Similarly, LOCc( K ) denotes the number of elements of K that a
85* process would receive if K were distributed over the q processes of
86* its process row.
87* The values of LOCr() and LOCc() may be determined via a call to the
88* ScaLAPACK tool function, NUMROC:
89* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
90* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
91* An upper bound for these quantities may be computed by:
92* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
93* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
94*
95* Arguments
96* =========
97*
98* IBTYPE (global input) INTEGER
99* = 1: compute inv(U**H)*sub( A )*inv(U) or
100* inv(L)*sub( A )*inv(L**H);
101* = 2 or 3: compute U*sub( A )*U**H or L**H*sub( A )*L.
102*
103* UPLO (global input) CHARACTER
104* = 'U': Upper triangle of sub( A ) is stored and sub( B ) is
105* factored as U**H*U;
106* = 'L': Lower triangle of sub( A ) is stored and sub( B ) is
107* factored as L*L**H.
108*
109* N (global input) INTEGER
110* The order of the matrices sub( A ) and sub( B ). N >= 0.
111*
112* A (local input/local output) COMPLEX*16 pointer into the
113* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
114* On entry, this array contains the local pieces of the
115* N-by-N Hermitian distributed matrix sub( A ). If UPLO = 'U',
116* the leading N-by-N upper triangular part of sub( A ) contains
117* the upper triangular part of the matrix, and its strictly
118* lower triangular part is not referenced. If UPLO = 'L', the
119* leading N-by-N lower triangular part of sub( A ) contains
120* the lower triangular part of the matrix, and its strictly
121* upper triangular part is not referenced.
122*
123* On exit, if INFO = 0, the transformed matrix, stored in the
124* same format as sub( A ).
125*
126* IA (global input) INTEGER
127* A's global row index, which points to the beginning of the
128* submatrix which is to be operated on.
129*
130* JA (global input) INTEGER
131* A's global column index, which points to the beginning of
132* the submatrix which is to be operated on.
133*
134* DESCA (global and local input) INTEGER array of dimension DLEN_.
135* The array descriptor for the distributed matrix A.
136*
137* B (local input) COMPLEX*16 pointer into the local memory
138* to an array of dimension (LLD_B, LOCc(JB+N-1)). On entry,
139* this array contains the local pieces of the triangular factor
140* from the Cholesky factorization of sub( B ), as returned by
141* PZPOTRF.
142*
143* IB (global input) INTEGER
144* B's global row index, which points to the beginning of the
145* submatrix which is to be operated on.
146*
147* JB (global input) INTEGER
148* B's global column index, which points to the beginning of
149* the submatrix which is to be operated on.
150*
151* DESCB (global and local input) INTEGER array of dimension DLEN_.
152* The array descriptor for the distributed matrix B.
153*
154* SCALE (global output) DOUBLE PRECISION
155* Amount by which the eigenvalues should be scaled to
156* compensate for the scaling performed in this routine.
157* At present, SCALE is always returned as 1.0, it is
158* returned here to allow for future enhancement.
159*
160* INFO (global output) INTEGER
161* = 0: successful exit
162* < 0: If the i-th argument is an array and the j-entry had
163* an illegal value, then INFO = -(i*100+j), if the i-th
164* argument is a scalar and had an illegal value, then
165* INFO = -i.
166*
167* =====================================================================
168*
169* .. Parameters ..
170 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
171 $ mb_, nb_, rsrc_, csrc_, lld_
172 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
173 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
174 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
175 DOUBLE PRECISION ONE
176 parameter( one = 1.0d+0 )
177 COMPLEX*16 CONE, HALF
178 parameter( cone = ( 1.0d+0, 0.0d+0 ),
179 $ half = ( 0.5d+0, 0.0d+0 ) )
180* ..
181* .. Local Scalars ..
182 LOGICAL UPPER
183 INTEGER IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
184 $ ictxt, iroffa, iroffb, k, kb, mycol, myrow, nb,
185 $ npcol, nprow
186* ..
187* .. Local Arrays ..
188 INTEGER IDUM1( 2 ), IDUM2( 2 )
189* ..
190* .. External Subroutines ..
191 EXTERNAL blacs_gridinfo, chk1mat, pchk2mat, pxerbla,
192 $ pzhegs2, pzhemm, pzher2k, pztrmm, pztrsm
193* ..
194* .. Intrinsic Functions ..
195 INTRINSIC ichar, min, mod
196* ..
197* .. External Functions ..
198 LOGICAL LSAME
199 INTEGER ICEIL, INDXG2P
200 EXTERNAL lsame, iceil, indxg2p
201* ..
202* .. Executable Statements ..
203* This is just to keep ftnchek happy
204 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
205 $ rsrc_.LT.0 )RETURN
206*
207* Get grid parameters
208*
209 scale = one
210*
211 ictxt = desca( ctxt_ )
212 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
213*
214* Test the input parameters
215*
216 info = 0
217 IF( nprow.EQ.-1 ) THEN
218 info = -( 700+ctxt_ )
219 ELSE
220 upper = lsame( uplo, 'U' )
221 CALL chk1mat( n, 3, n, 3, ia, ja, desca, 7, info )
222 CALL chk1mat( n, 3, n, 3, ib, jb, descb, 11, info )
223 IF( info.EQ.0 ) THEN
224 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
225 $ nprow )
226 ibrow = indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
227 $ nprow )
228 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
229 $ npcol )
230 ibcol = indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
231 $ npcol )
232 iroffa = mod( ia-1, desca( mb_ ) )
233 icoffa = mod( ja-1, desca( nb_ ) )
234 iroffb = mod( ib-1, descb( mb_ ) )
235 icoffb = mod( jb-1, descb( nb_ ) )
236 IF( ibtype.LT.1 .OR. ibtype.GT.3 ) THEN
237 info = -1
238 ELSE IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
239 info = -2
240 ELSE IF( n.LT.0 ) THEN
241 info = -3
242 ELSE IF( iroffa.NE.0 ) THEN
243 info = -5
244 ELSE IF( icoffa.NE.0 ) THEN
245 info = -6
246 ELSE IF( desca( mb_ ).NE.desca( nb_ ) ) THEN
247 info = -( 700+nb_ )
248 ELSE IF( iroffb.NE.0 .OR. ibrow.NE.iarow ) THEN
249 info = -9
250 ELSE IF( icoffb.NE.0 .OR. ibcol.NE.iacol ) THEN
251 info = -10
252 ELSE IF( descb( mb_ ).NE.desca( mb_ ) ) THEN
253 info = -( 1100+mb_ )
254 ELSE IF( descb( nb_ ).NE.desca( nb_ ) ) THEN
255 info = -( 1100+nb_ )
256 ELSE IF( ictxt.NE.descb( ctxt_ ) ) THEN
257 info = -( 1100+ctxt_ )
258 END IF
259 END IF
260 idum1( 1 ) = ibtype
261 idum2( 1 ) = 1
262 IF( upper ) THEN
263 idum1( 2 ) = ichar( 'U' )
264 ELSE
265 idum1( 2 ) = ichar( 'L' )
266 END IF
267 idum2( 2 ) = 2
268 CALL pchk2mat( n, 3, n, 3, ia, ja, desca, 7, n, 3, n, 3, ib,
269 $ jb, descb, 11, 2, idum1, idum2, info )
270 END IF
271*
272 IF( info.NE.0 ) THEN
273 CALL pxerbla( ictxt, 'PZHEGST', -info )
274 RETURN
275 END IF
276*
277* Quick return if possible
278*
279 IF( n.EQ.0 )
280 $ RETURN
281*
282 IF( ibtype.EQ.1 ) THEN
283 IF( upper ) THEN
284*
285* Compute inv(U')*sub( A )*inv(U)
286*
287 k = 1
288 nb = desca( nb_ )
289 kb = min( iceil( ja, nb )*nb, ja+n-1 ) - ja + 1
290*
291 10 CONTINUE
292*
293* Update the upper triangle of A(ia+k-1:ia+n-1,ja+k-1:ja+n-1)
294*
295 CALL pzhegs2( ibtype, uplo, kb, a, ia+k-1, ja+k-1, desca, b,
296 $ ib+k-1, ib+k-1, descb, info )
297 IF( k+kb.LE.n ) THEN
298 CALL pztrsm( 'Left', uplo, 'Conjugate Transpose',
299 $ 'Non-unit', kb, n-k-kb+1, cone, b, ib+k-1,
300 $ jb+k-1, descb, a, ia+k-1, ja+k+kb-1, desca )
301 CALL pzhemm( 'Left', uplo, kb, n-k-kb+1, -half, a,
302 $ ia+k-1, ja+k-1, desca, b, ib+k-1, jb+k+kb-1,
303 $ descb, cone, a, ia+k-1, ja+k+kb-1, desca )
304 CALL pzher2k( uplo, 'Conjugate Transpose', n-k-kb+1, kb,
305 $ -cone, a, ia+k-1, ja+k+kb-1, desca, b,
306 $ ib+k-1, jb+k+kb-1, descb, one, a,
307 $ ia+k+kb-1, ja+k+kb-1, desca )
308 CALL pzhemm( 'Left', uplo, kb, n-k-kb+1, -half, a,
309 $ ia+k-1, ja+k-1, desca, b, ib+k-1, jb+k+kb-1,
310 $ descb, cone, a, ia+k-1, ja+k+kb-1, desca )
311 CALL pztrsm( 'Right', uplo, 'No transpose', 'Non-unit',
312 $ kb, n-k-kb+1, cone, b, ib+k+kb-1, jb+k+kb-1,
313 $ descb, a, ia+k-1, ja+k+kb-1, desca )
314 END IF
315 k = k + kb
316 kb = min( n-k+1, nb )
317*
318 IF( k.LE.n )
319 $ GO TO 10
320*
321 ELSE
322*
323* Compute inv(L)*sub( A )*inv(L')
324*
325 k = 1
326 nb = desca( mb_ )
327 kb = min( iceil( ia, nb )*nb, ia+n-1 ) - ia + 1
328*
329 20 CONTINUE
330*
331* Update the lower triangle of A(ia+k-1:ia+n-1,ja+k-1:ja+n-1)
332*
333 CALL pzhegs2( ibtype, uplo, kb, a, ia+k-1, ja+k-1, desca, b,
334 $ ib+k-1, jb+k-1, descb, info )
335 IF( k+kb.LE.n ) THEN
336 CALL pztrsm( 'Right', uplo, 'Conjugate transpose',
337 $ 'Non-unit', n-k-kb+1, kb, cone, b, ib+k-1,
338 $ jb+k-1, descb, a, ia+k+kb-1, ja+k-1, desca )
339 CALL pzhemm( 'Right', uplo, n-k-kb+1, kb, -half, a,
340 $ ia+k-1, ja+k-1, desca, b, ib+k+kb-1, jb+k-1,
341 $ descb, cone, a, ia+k+kb-1, ja+k-1, desca )
342 CALL pzher2k( uplo, 'No transpose', n-k-kb+1, kb, -cone,
343 $ a, ia+k+kb-1, ja+k-1, desca, b, ib+k+kb-1,
344 $ jb+k-1, descb, one, a, ia+k+kb-1,
345 $ ja+k+kb-1, desca )
346 CALL pzhemm( 'Right', uplo, n-k-kb+1, kb, -half, a,
347 $ ia+k-1, ja+k-1, desca, b, ib+k+kb-1, jb+k-1,
348 $ descb, cone, a, ia+k+kb-1, ja+k-1, desca )
349 CALL pztrsm( 'Left', uplo, 'No transpose', 'Non-unit',
350 $ n-k-kb+1, kb, cone, b, ib+k+kb-1, jb+k+kb-1,
351 $ descb, a, ia+k+kb-1, ja+k-1, desca )
352 END IF
353 k = k + kb
354 kb = min( n-k+1, nb )
355*
356 IF( k.LE.n )
357 $ GO TO 20
358*
359 END IF
360*
361 ELSE
362*
363 IF( upper ) THEN
364*
365* Compute U*sub( A )*U'
366*
367 k = 1
368 nb = desca( nb_ )
369 kb = min( iceil( ja, nb )*nb, ja+n-1 ) - ja + 1
370*
371 30 CONTINUE
372*
373* Update the upper triangle of A(ia:ia+k+kb-2,ja:ja+k+kb-2)
374*
375 CALL pztrmm( 'Left', uplo, 'No transpose', 'Non-unit', k-1,
376 $ kb, cone, b, ib, jb, descb, a, ia, ja+k-1,
377 $ desca )
378 CALL pzhemm( 'Right', uplo, k-1, kb, half, a, ia+k-1,
379 $ ja+k-1, desca, b, ib, jb+k-1, descb, cone, a,
380 $ ia, ja+k-1, desca )
381 CALL pzher2k( uplo, 'No transpose', k-1, kb, cone, a, ia,
382 $ ja+k-1, desca, b, ib, jb+k-1, descb, one, a,
383 $ ia, ja, desca )
384 CALL pzhemm( 'Right', uplo, k-1, kb, half, a, ia+k-1,
385 $ ja+k-1, desca, b, ib, jb+k-1, descb, cone, a,
386 $ ia, ja+k-1, desca )
387 CALL pztrmm( 'Right', uplo, 'Conjugate transpose',
388 $ 'Non-unit', k-1, kb, cone, b, ib+k-1, jb+k-1,
389 $ descb, a, ia, ja+k-1, desca )
390 CALL pzhegs2( ibtype, uplo, kb, a, ia+k-1, ja+k-1, desca, b,
391 $ ib+k-1, jb+k-1, descb, info )
392*
393 k = k + kb
394 kb = min( n-k+1, nb )
395*
396 IF( k.LE.n )
397 $ GO TO 30
398*
399 ELSE
400*
401* Compute L'*sub( A )*L
402*
403 k = 1
404 nb = desca( mb_ )
405 kb = min( iceil( ia, nb )*nb, ia+n-1 ) - ia + 1
406*
407 40 CONTINUE
408*
409* Update the lower triangle of A(ia:ia+k+kb-2,ja:ja+k+kb-2)
410*
411 CALL pztrmm( 'Right', uplo, 'No transpose', 'Non-unit', kb,
412 $ k-1, cone, b, ib, jb, descb, a, ia+k-1, ja,
413 $ desca )
414 CALL pzhemm( 'Left', uplo, kb, k-1, half, a, ia+k-1, ja+k-1,
415 $ desca, b, ib+k-1, jb, descb, cone, a, ia+k-1,
416 $ ja, desca )
417 CALL pzher2k( uplo, 'Conjugate transpose', k-1, kb, cone, a,
418 $ ia+k-1, ja, desca, b, ib+k-1, jb, descb, one,
419 $ a, ia, ja, desca )
420 CALL pzhemm( 'Left', uplo, kb, k-1, half, a, ia+k-1, ja+k-1,
421 $ desca, b, ib+k-1, jb, descb, cone, a, ia+k-1,
422 $ ja, desca )
423 CALL pztrmm( 'Left', uplo, 'Conjugate transpose',
424 $ 'Non-unit', kb, k-1, cone, b, ib+k-1, jb+k-1,
425 $ descb, a, ia+k-1, ja, desca )
426 CALL pzhegs2( ibtype, uplo, kb, a, ia+k-1, ja+k-1, desca, b,
427 $ ib+k-1, jb+k-1, descb, info )
428*
429 k = k + kb
430 kb = min( n-k+1, nb )
431*
432 IF( k.LE.n )
433 $ GO TO 40
434*
435 END IF
436*
437 END IF
438*
439 RETURN
440*
441* End of PZHEGST
442*
443 END
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition chk1mat.f:3
#define min(A, B)
Definition pcgemr.c:181
subroutine pchk2mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, mb, mbpos0, nb, nbpos0, ib, jb, descb, descbpos0, nextra, ex, expos, info)
Definition pchkxmat.f:175
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
subroutine pzhegs2(ibtype, uplo, n, a, ia, ja, desca, b, ib, jb, descb, info)
Definition pzhegs2.f:5
subroutine pzhegst(ibtype, uplo, n, a, ia, ja, desca, b, ib, jb, descb, scale, info)
Definition pzhegst.f:5