OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pzhegs2.f
Go to the documentation of this file.
1*
2*
3 SUBROUTINE pzhegs2( IBTYPE, UPLO, N, A, IA, JA, DESCA, B, IB, JB,
4 $ DESCB, 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* ..
15* .. Array Arguments ..
16 INTEGER DESCA( * ), DESCB( * )
17 COMPLEX*16 A( * ), B( * )
18* ..
19*
20* Purpose
21* =======
22*
23* PZHEGS2 reduces a complex Hermitian-definite generalized eigenproblem
24* to standard form.
25*
26* In the following sub( A ) denotes A( IA:IA+N-1, JA:JA+N-1 ) and
27* sub( B ) denotes B( IB:IB+N-1, JB:JB+N-1 ).
28*
29* If IBTYPE = 1, the problem is sub( A )*x = lambda*sub( B )*x,
30* and sub( A ) is overwritten by inv(U**H)*sub( A )*inv(U) or
31* inv(L)*sub( A )*inv(L**H)
32*
33* If IBTYPE = 2 or 3, the problem is sub( A )*sub( B )*x = lambda*x or
34* sub( B )*sub( A )*x = lambda*x, and sub( A ) is overwritten by
35* U*sub( A )*U**H or L**H*sub( A )*L.
36*
37* sub( B ) must have been previously factorized as U**H*U or L*L**H by
38* PZPOTRF.
39*
40* Notes
41* =====
42*
43* Each global data object is described by an associated description
44* vector. This vector stores the information required to establish
45* the mapping between an object element and its corresponding process
46* and memory location.
47*
48* Let A be a generic term for any 2D block cyclicly distributed array.
49* Such a global array has an associated description vector DESCA.
50* In the following comments, the character _ should be read as
51* "of the global array".
52*
53* NOTATION STORED IN EXPLANATION
54* --------------- -------------- --------------------------------------
55* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
56* DTYPE_A = 1.
57* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
58* the BLACS process grid A is distribu-
59* ted over. The context itself is glo-
60* bal, but the handle (the integer
61* value) may vary.
62* M_A (global) DESCA( M_ ) The number of rows in the global
63* array A.
64* N_A (global) DESCA( N_ ) The number of columns in the global
65* array A.
66* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
67* the rows of the array.
68* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
69* the columns of the array.
70* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
71* row of the array A is distributed.
72* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
73* first column of the array A is
74* distributed.
75* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
76* array. LLD_A >= MAX(1,LOCr(M_A)).
77*
78* Let K be the number of rows or columns of a distributed matrix,
79* and assume that its process grid has dimension p x q.
80* LOCr( K ) denotes the number of elements of K that a process
81* would receive if K were distributed over the p processes of its
82* process column.
83* Similarly, LOCc( K ) denotes the number of elements of K that a
84* process would receive if K were distributed over the q processes of
85* its process row.
86* The values of LOCr() and LOCc() may be determined via a call to the
87* ScaLAPACK tool function, NUMROC:
88* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
89* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
90* An upper bound for these quantities may be computed by:
91* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
92* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
93*
94* Arguments
95* =========
96*
97* IBTYPE (global input) INTEGER
98* = 1: compute inv(U**H)*sub( A )*inv(U) or
99* inv(L)*sub( A )*inv(L**H);
100* = 2 or 3: compute U*sub( A )*U**H or L**H*sub( A )*L.
101*
102* UPLO (global input) CHARACTER
103* = 'U': Upper triangle of sub( A ) is stored and sub( B ) is
104* factored as U**H*U;
105* = 'L': Lower triangle of sub( A ) is stored and sub( B ) is
106* factored as L*L**H.
107*
108* N (global input) INTEGER
109* The order of the matrices sub( A ) and sub( B ). N >= 0.
110*
111* A (local input/local output) COMPLEX*16 pointer into the
112* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
113* On entry, this array contains the local pieces of the
114* N-by-N Hermitian distributed matrix sub( A ). If UPLO = 'U',
115* the leading N-by-N upper triangular part of sub( A ) contains
116* the upper triangular part of the matrix, and its strictly
117* lower triangular part is not referenced. If UPLO = 'L', the
118* leading N-by-N lower triangular part of sub( A ) contains
119* the lower triangular part of the matrix, and its strictly
120* upper triangular part is not referenced.
121*
122* On exit, if INFO = 0, the transformed matrix, stored in the
123* same format as sub( A ).
124*
125* IA (global input) INTEGER
126* A's global row index, which points to the beginning of the
127* submatrix which is to be operated on.
128*
129* JA (global input) INTEGER
130* A's global column index, which points to the beginning of
131* the submatrix which is to be operated on.
132*
133* DESCA (global and local input) INTEGER array of dimension DLEN_.
134* The array descriptor for the distributed matrix A.
135*
136* B (local input) COMPLEX*16 pointer into the local memory
137* to an array of dimension (LLD_B, LOCc(JB+N-1)). On entry,
138* this array contains the local pieces of the triangular factor
139* from the Cholesky factorization of sub( B ), as returned by
140* PZPOTRF.
141*
142* IB (global input) INTEGER
143* B's global row index, which points to the beginning of the
144* submatrix which is to be operated on.
145*
146* JB (global input) INTEGER
147* B's global column index, which points to the beginning of
148* the submatrix which is to be operated on.
149*
150* DESCB (global and local input) INTEGER array of dimension DLEN_.
151* The array descriptor for the distributed matrix B.
152*
153* INFO (global output) INTEGER
154* = 0: successful exit
155* < 0: If the i-th argument is an array and the j-entry had
156* an illegal value, then INFO = -(i*100+j), if the i-th
157* argument is a scalar and had an illegal value, then
158* INFO = -i.
159*
160* =====================================================================
161*
162* .. Parameters ..
163 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
164 $ mb_, nb_, rsrc_, csrc_, lld_
165 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
166 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
167 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
168 DOUBLE PRECISION ONE, HALF
169 parameter( one = 1.0d+0, half = 0.5d+0 )
170 COMPLEX*16 CONE
171 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
172* ..
173* .. Local Scalars ..
174 LOGICAL UPPER
175 INTEGER IACOL, IAROW, IBCOL, IBROW, ICOFFA, ICOFFB,
176 $ ictxt, iia, iib, ioffa, ioffb, iroffa, iroffb,
177 $ jja, jjb, k, lda, ldb, mycol, myrow, npcol,
178 $ nprow
179 DOUBLE PRECISION AKK, BKK
180 COMPLEX*16 CT
181* ..
182* .. External Subroutines ..
183 EXTERNAL blacs_exit, blacs_gridinfo, chk1mat, infog2l,
185 $ ztrsv
186* ..
187* .. Intrinsic Functions ..
188 INTRINSIC dble, mod
189* ..
190* .. External Functions ..
191 LOGICAL LSAME
192 INTEGER INDXG2P
193 EXTERNAL lsame, indxg2p
194* ..
195* .. Executable Statements ..
196* This is just to keep ftnchek happy
197 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
198 $ rsrc_.LT.0 )RETURN
199*
200* Get grid parameters
201*
202 ictxt = desca( ctxt_ )
203 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
204*
205* Test the input parameters.
206*
207 info = 0
208 IF( nprow.EQ.-1 ) THEN
209 info = -( 700+ctxt_ )
210 ELSE
211 upper = lsame( uplo, 'u' )
212 CALL CHK1MAT( N, 3, N, 3, IA, JA, DESCA, 7, INFO )
213 CALL CHK1MAT( N, 3, N, 3, IB, JB, DESCB, 11, INFO )
214.EQ. IF( INFO0 ) THEN
215 IAROW = INDXG2P( IA, DESCA( MB_ ), MYROW, DESCA( RSRC_ ),
216 $ NPROW )
217 IBROW = INDXG2P( IB, DESCB( MB_ ), MYROW, DESCB( RSRC_ ),
218 $ NPROW )
219 IACOL = INDXG2P( JA, DESCA( NB_ ), MYCOL, DESCA( CSRC_ ),
220 $ NPCOL )
221 IBCOL = INDXG2P( JB, DESCB( NB_ ), MYCOL, DESCB( CSRC_ ),
222 $ NPCOL )
223 IROFFA = MOD( IA-1, DESCA( MB_ ) )
224 ICOFFA = MOD( JA-1, DESCA( NB_ ) )
225 IROFFB = MOD( IB-1, DESCB( MB_ ) )
226 ICOFFB = MOD( JB-1, DESCB( NB_ ) )
227.LT..OR..GT. IF( IBTYPE1 IBTYPE3 ) THEN
228 INFO = -1
229.NOT..AND..NOT. ELSE IF( UPPER LSAME( UPLO, 'l' ) ) THEN
230 INFO = -2
231.LT. ELSE IF( N0 ) THEN
232 INFO = -3
233.GT. ELSE IF( N+ICOFFADESCA( NB_ ) ) THEN
234 INFO = -3
235.NE. ELSE IF( IROFFA0 ) THEN
236 INFO = -5
237.NE. ELSE IF( ICOFFA0 ) THEN
238 INFO = -6
239.NE. ELSE IF( DESCA( MB_ )DESCA( NB_ ) ) THEN
240 INFO = -( 700+NB_ )
241.NE..OR..NE. ELSE IF( IROFFB0 IBROWIAROW ) THEN
242 INFO = -9
243.NE..OR..NE. ELSE IF( ICOFFB0 IBCOLIACOL ) THEN
244 INFO = -10
245.NE. ELSE IF( DESCB( MB_ )DESCA( MB_ ) ) THEN
246 INFO = -( 1100+MB_ )
247.NE. ELSE IF( DESCB( NB_ )DESCA( NB_ ) ) THEN
248 INFO = -( 1100+NB_ )
249.NE. ELSE IF( ICTXTDESCB( CTXT_ ) ) THEN
250 INFO = -( 1100+CTXT_ )
251 END IF
252 END IF
253 END IF
254*
255.NE. IF( INFO0 ) THEN
256 CALL PXERBLA( ICTXT, 'pzhegs2', -INFO )
257 CALL BLACS_EXIT( ICTXT )
258 RETURN
259 END IF
260*
261* Quick return if possible
262*
263.EQ..OR..NE..OR..NE. IF( N0 ( MYROWIAROW MYCOLIACOL ) )
264 $ RETURN
265*
266* Compute local information
267*
268 LDA = DESCA( LLD_ )
269 LDB = DESCB( LLD_ )
270 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA,
271 $ IAROW, IACOL )
272 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIB, JJB,
273 $ IBROW, IBCOL )
274*
275.EQ. IF( IBTYPE1 ) THEN
276*
277 IF( UPPER ) THEN
278*
279 IOFFA = IIA + JJA*LDA
280 IOFFB = IIB + JJB*LDB
281*
282* Compute inv(U')*sub( A )*inv(U)
283*
284 DO 10 K = 1, N
285*
286* Update the upper triangle of
287* A(ia+k-1:ia+n-a,ia+k-1:ia+n-1)
288*
289 AKK = DBLE( A( IOFFA-LDA ) )
290 BKK = DBLE( B( IOFFB-LDB ) )
291 AKK = AKK / BKK**2
292 A( IOFFA-LDA ) = AKK
293.LT. IF( KN ) THEN
294 CALL ZDSCAL( N-K, ONE / BKK, A( IOFFA ), LDA )
295 CT = -HALF*AKK
296 CALL ZLACGV( N-K, A( IOFFA ), LDA )
297 CALL ZLACGV( N-K, B( IOFFB ), LDB )
298 CALL ZAXPY( N-K, CT, B( IOFFB ), LDB, A( IOFFA ),
299 $ LDA )
300 CALL ZHER2( UPLO, N-K, -CONE, A( IOFFA ), LDA,
301 $ B( IOFFB ), LDB, A( IOFFA+1 ), LDA )
302 CALL ZAXPY( N-K, CT, B( IOFFB ), LDB, A( IOFFA ),
303 $ LDA )
304 CALL ZLACGV( N-K, B( IOFFB ), LDB )
305 CALL ZTRSV( UPLO, 'conjugate transpose', 'non-unit',
306 $ N-K, B( IOFFB+1 ), LDB, A( IOFFA ), LDA )
307 CALL ZLACGV( N-K, A( IOFFA ), LDA )
308 END IF
309*
310* A( IOFFA ) -> A( K, K+1 )
311* B( IOFFB ) -> B( K, K+1 )
312*
313 IOFFA = IOFFA + LDA + 1
314 IOFFB = IOFFB + LDB + 1
315*
316 10 CONTINUE
317*
318 ELSE
319*
320 IOFFA = IIA + 1 + ( JJA-1 )*LDA
321 IOFFB = IIB + 1 + ( JJB-1 )*LDB
322*
323* Compute inv(L)*sub( A )*inv(L')
324*
325 DO 20 K = 1, N
326*
327* Update the lower triangle of
328* A(ia+k-1:ia+n-a,ia+k-1:ia+n-1)
329*
330 AKK = DBLE( A( IOFFA-1 ) )
331 BKK = DBLE( B( IOFFB-1 ) )
332 AKK = AKK / BKK**2
333 A( IOFFA-1 ) = AKK
334*
335.LT. IF( KN ) THEN
336 CALL ZDSCAL( N-K, ONE / BKK, A( IOFFA ), 1 )
337 CT = -HALF*AKK
338 CALL ZAXPY( N-K, CT, B( IOFFB ), 1, A( IOFFA ), 1 )
339 CALL ZHER2( UPLO, N-K, -CONE, A( IOFFA ), 1,
340 $ B( IOFFB ), 1, A( IOFFA+LDA ), LDA )
341 CALL ZAXPY( N-K, CT, B( IOFFB ), 1, A( IOFFA ), 1 )
342 CALL ZTRSV( UPLO, 'no transpose', 'non-unit', N-K,
343 $ B( IOFFB+LDB ), LDB, A( IOFFA ), 1 )
344 END IF
345*
346* A( IOFFA ) -> A( K+1, K )
347* B( IOFFB ) -> B( K+1, K )
348*
349 IOFFA = IOFFA + LDA + 1
350 IOFFB = IOFFB + LDB + 1
351*
352 20 CONTINUE
353*
354 END IF
355*
356 ELSE
357*
358 IF( UPPER ) THEN
359*
360 IOFFA = IIA + ( JJA-1 )*LDA
361 IOFFB = IIB + ( JJB-1 )*LDB
362*
363* Compute U*sub( A )*U'
364*
365 DO 30 K = 1, N
366*
367* Update the upper triangle of A(ia:ia+k-1,ja:ja+k-1)
368*
369 AKK = DBLE( A( IOFFA+K-1 ) )
370 BKK = DBLE( B( IOFFB+K-1 ) )
371 CALL ZTRMV( UPLO, 'no transpose', 'non-unit', K-1,
372 $ B( IIB+( JJB-1 )*LDB ), LDB, A( IOFFA ), 1 )
373 CT = HALF*AKK
374 CALL ZAXPY( K-1, CT, B( IOFFB ), 1, A( IOFFA ), 1 )
375 CALL ZHER2( UPLO, K-1, CONE, A( IOFFA ), 1, B( IOFFB ),
376 $ 1, A( IIA+( JJA-1 )*LDA ), LDA )
377 CALL ZAXPY( K-1, CT, B( IOFFB ), 1, A( IOFFA ), 1 )
378 CALL ZDSCAL( K-1, BKK, A( IOFFA ), 1 )
379 A( IOFFA+K-1 ) = AKK*BKK**2
380*
381* A( IOFFA ) -> A( 1, K )
382* B( IOFFB ) -> B( 1, K )
383*
384 IOFFA = IOFFA + LDA
385 IOFFB = IOFFB + LDB
386*
387 30 CONTINUE
388*
389 ELSE
390*
391 IOFFA = IIA + ( JJA-1 )*LDA
392 IOFFB = IIB + ( JJB-1 )*LDB
393*
394* Compute L'*sub( A )*L
395*
396 DO 40 K = 1, N
397*
398* Update the lower triangle of A(ia:ia+k-1,ja:ja+k-1)
399*
400 AKK = DBLE( A( IOFFA+( K-1 )*LDA ) )
401 BKK = DBLE( B( IOFFB+( K-1 )*LDB ) )
402 CALL ZLACGV( K-1, A( IOFFA ), LDA )
403 CALL ZTRMV( UPLO, 'conjugate transpose', 'non-unit', K-1,
404 $ B( IIB+( JJB-1 )*LDB ), LDB, A( IOFFA ),
405 $ LDA )
406 CT = HALF*AKK
407 CALL ZLACGV( K-1, B( IOFFB ), LDB )
408 CALL ZAXPY( K-1, CT, B( IOFFB ), LDB, A( IOFFA ), LDA )
409 CALL ZHER2( UPLO, K-1, CONE, A( IOFFA ), LDA, B( IOFFB ),
410 $ LDB, A( IIA+( JJA-1 )*LDA ), LDA )
411 CALL ZAXPY( K-1, CT, B( IOFFB ), LDB, A( IOFFA ), LDA )
412 CALL ZLACGV( K-1, B( IOFFB ), LDB )
413 CALL ZDSCAL( K-1, BKK, A( IOFFA ), LDA )
414 CALL ZLACGV( K-1, A( IOFFA ), LDA )
415 A( IOFFA+( K-1 )*LDA ) = AKK*BKK**2
416*
417* A( IOFFA ) -> A( K, 1 )
418* B( IOFFB ) -> B( K, 1 )
419*
420 IOFFA = IOFFA + 1
421 IOFFB = IOFFB + 1
422*
423 40 CONTINUE
424*
425 END IF
426*
427 END IF
428*
429 RETURN
430*
431* End of PZHEGS2
432*
433 END
subroutine zlacgv(n, x, incx)
ZLACGV conjugates a complex vector.
Definition zlacgv.f:74
subroutine zdscal(n, da, zx, incx)
ZDSCAL
Definition zdscal.f:78
subroutine zaxpy(n, za, zx, incx, zy, incy)
ZAXPY
Definition zaxpy.f:88
subroutine ztrmv(uplo, trans, diag, n, a, lda, x, incx)
ZTRMV
Definition ztrmv.f:147
subroutine zher2(uplo, n, alpha, x, incx, y, incy, a, lda)
ZHER2
Definition zher2.f:150
subroutine ztrsv(uplo, trans, diag, n, a, lda, x, incx)
ZTRSV
Definition ztrsv.f:149
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition mpi.f:1577
subroutine pxerbla(contxt, srname, info)
Definition mpi.f:1600
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition mpi.f:937
subroutine blacs_gridinfo(cntxt, nprow, npcol, myrow, mycol)
Definition mpi.f:754
subroutine pzhegs2(ibtype, uplo, n, a, ia, ja, desca, b, ib, jb, descb, info)
Definition pzhegs2.f:5