OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pzgecon.f
Go to the documentation of this file.
1 SUBROUTINE pzgecon( NORM, N, A, IA, JA, DESCA, ANORM, RCOND, WORK,
2 $ LWORK, RWORK, LRWORK, INFO )
3*
4* -- ScaLAPACK routine (version 1.7) --
5* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
6* and University of California, Berkeley.
7* May 25, 2001
8*
9* .. Scalar Arguments ..
10 CHARACTER NORM
11 INTEGER IA, INFO, JA, LRWORK, LWORK, N
12 DOUBLE PRECISION ANORM, RCOND
13* ..
14* .. Array Arguments ..
15 INTEGER DESCA( * )
16 DOUBLE PRECISION RWORK( * )
17 COMPLEX*16 A( * ), WORK( * )
18* ..
19*
20* Purpose
21* =======
22*
23* PZGECON estimates the reciprocal of the condition number of a general
24* distributed complex matrix A(IA:IA+N-1,JA:JA+N-1), in either the
25* 1-norm or the infinity-norm, using the LU factorization computed by
26* PZGETRF.
27*
28* An estimate is obtained for norm(inv(A(IA:IA+N-1,JA:JA+N-1))), and
29* the reciprocal of the condition number is computed as
30* RCOND = 1 / ( norm( A(IA:IA+N-1,JA:JA+N-1) ) *
31* norm( inv(A(IA:IA+N-1,JA:JA+N-1)) ) ).
32*
33* Notes
34* =====
35*
36* Each global data object is described by an associated description
37* vector. This vector stores the information required to establish
38* the mapping between an object element and its corresponding process
39* and memory location.
40*
41* Let A be a generic term for any 2D block cyclicly distributed array.
42* Such a global array has an associated description vector DESCA.
43* In the following comments, the character _ should be read as
44* "of the global array".
45*
46* NOTATION STORED IN EXPLANATION
47* --------------- -------------- --------------------------------------
48* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
49* DTYPE_A = 1.
50* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
51* the BLACS process grid A is distribu-
52* ted over. The context itself is glo-
53* bal, but the handle (the integer
54* value) may vary.
55* M_A (global) DESCA( M_ ) The number of rows in the global
56* array A.
57* N_A (global) DESCA( N_ ) The number of columns in the global
58* array A.
59* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
60* the rows of the array.
61* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
62* the columns of the array.
63* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
64* row of the array A is distributed.
65* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
66* first column of the array A is
67* distributed.
68* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
69* array. LLD_A >= MAX(1,LOCr(M_A)).
70*
71* Let K be the number of rows or columns of a distributed matrix,
72* and assume that its process grid has dimension p x q.
73* LOCr( K ) denotes the number of elements of K that a process
74* would receive if K were distributed over the p processes of its
75* process column.
76* Similarly, LOCc( K ) denotes the number of elements of K that a
77* process would receive if K were distributed over the q processes of
78* its process row.
79* The values of LOCr() and LOCc() may be determined via a call to the
80* ScaLAPACK tool function, NUMROC:
81* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
82* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
83* An upper bound for these quantities may be computed by:
84* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
85* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
86*
87* Arguments
88* =========
89*
90* NORM (global input) CHARACTER
91* Specifies whether the 1-norm condition number or the
92* infinity-norm condition number is required:
93* = '1' or 'O': 1-norm
94* = 'I': Infinity-norm
95*
96* N (global input) INTEGER
97* The order of the distributed matrix A(IA:IA+N-1,JA:JA+N-1).
98* N >= 0.
99*
100* A (local input) COMPLEX*16 pointer into the local memory
101* to an array of dimension ( LLD_A, LOCc(JA+N-1) ). On entry,
102* this array contains the local pieces of the factors L and U
103* from the factorization A(IA:IA+N-1,JA:JA+N-1) = P*L*U; the
104* unit diagonal elements of L are not stored.
105*
106* IA (global input) INTEGER
107* The row index in the global array A indicating the first
108* row of sub( A ).
109*
110* JA (global input) INTEGER
111* The column index in the global array A indicating the
112* first column of sub( A ).
113*
114* DESCA (global and local input) INTEGER array of dimension DLEN_.
115* The array descriptor for the distributed matrix A.
116*
117* ANORM (global input) DOUBLE PRECISION
118* If NORM = '1' or 'O', the 1-norm of the original distributed
119* matrix A(IA:IA+N-1,JA:JA+N-1).
120* If NORM = 'I', the infinity-norm of the original distributed
121* matrix A(IA:IA+N-1,JA:JA+N-1).
122*
123* RCOND (global output) DOUBLE PRECISION
124* The reciprocal of the condition number of the distributed
125* matrix A(IA:IA+N-1,JA:JA+N-1), computed as
126* RCOND = 1 / ( norm( A(IA:IA+N-1,JA:JA+N-1) ) *
127* norm( inv(A(IA:IA+N-1,JA:JA+N-1)) ) ).
128*
129* WORK (local workspace/local output) COMPLEX*16 array,
130* dimension (LWORK)
131* On exit, WORK(1) returns the minimal and optimal LWORK.
132*
133* LWORK (local or global input) INTEGER
134* The dimension of the array WORK.
135* LWORK is local input and must be at least
136* LWORK >= 2*LOCr(N+MOD(IA-1,MB_A)) +
137* MAX( 2, MAX(NB_A*CEIL(NPROW-1,NPCOL),LOCc(N+MOD(JA-1,NB_A)) +
138* NB_A*CEIL(NPCOL-1,NPROW)) ).
139*
140* LOCr and LOCc values can be computed using the ScaLAPACK
141* tool function NUMROC; NPROW and NPCOL can be determined by
142* calling the subroutine BLACS_GRIDINFO.
143*
144* If LWORK = -1, then LWORK is global input and a workspace
145* query is assumed; the routine only calculates the minimum
146* and optimal size for all work arrays. Each of these
147* values is returned in the first entry of the corresponding
148* work array, and no error message is issued by PXERBLA.
149*
150* RWORK (local workspace/local output) DOUBLE PRECISION array,
151* dimension (LRWORK)
152* On exit, RWORK(1) returns the minimal and optimal LRWORK.
153*
154* LRWORK (local or global input) INTEGER
155* The dimension of the array RWORK.
156* LRWORK is local input and must be at least
157* LRWORK >= MAX( 1, 2*LOCc(N+MOD(JA-1,NB_A)) ).
158*
159* If LRWORK = -1, then LRWORK is global input and a workspace
160* query is assumed; the routine only calculates the minimum
161* and optimal size for all work arrays. Each of these
162* values is returned in the first entry of the corresponding
163* work array, and no error message is issued by PXERBLA.
164*
165*
166* INFO (global output) INTEGER
167* = 0: successful exit
168* < 0: If the i-th argument is an array and the j-entry had
169* an illegal value, then INFO = -(i*100+j), if the i-th
170* argument is a scalar and had an illegal value, then
171* INFO = -i.
172*
173* =====================================================================
174*
175* .. Parameters ..
176 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
177 $ lld_, mb_, m_, nb_, n_, rsrc_
178 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
179 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
180 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
181 DOUBLE PRECISION ONE, ZERO
182 parameter( one = 1.0d+0, zero = 0.0d+0 )
183* ..
184* .. Local Scalars ..
185 LOGICAL LQUERY, ONENRM
186 CHARACTER CBTOP, COLCTOP, NORMIN, ROWCTOP
187 INTEGER IACOL, IAROW, ICOFF, ICTXT, IIA, IPNL, IPNU,
188 $ ipv, ipw, ipx, iroff, iv, ix, ixx, jja, jv, jx,
189 $ kase, kase1, lrwmin, lwmin, mycol, myrow, np,
190 $ npcol, npmod, nprow, nq, nqmod
191 DOUBLE PRECISION AINVNM, SCALE, SL, SMLNUM, SU
192 COMPLEX*16 WMAX, ZDUM
193* ..
194* .. Local Arrays ..
195 INTEGER DESCV( DLEN_ ), DESCX( DLEN_ ), IDUM1( 3 ),
196 $ idum2( 3 )
197* ..
198* .. External Subroutines ..
200 $ pchk1mat, pb_topget, pb_topset, pxerbla,
201 $ pzamax, pzlatrs, pzlacon, pzdrscl,
203* ..
204* .. External Functions ..
205 LOGICAL LSAME
206 INTEGER ICEIL, INDXG2P, NUMROC
207 DOUBLE PRECISION PDLAMCH
208 EXTERNAL iceil, indxg2p, lsame, numroc, pdlamch
209* ..
210* .. Intrinsic Functions ..
211 INTRINSIC abs, dble, dimag, ichar, max, mod
212* ..
213* .. Statement Functions ..
214 DOUBLE PRECISION CABS1
215* ..
216* .. Statement Function definitions ..
217 cabs1( zdum ) = abs( dble( zdum ) ) + abs( dimag( zdum ) )
218* ..
219* .. Executable Statements ..
220*
221* Get grid parameters
222*
223 ictxt = desca( ctxt_ )
224 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
225*
226* Test the input parameters
227*
228 info = 0
229 IF( nprow.EQ.-1 ) THEN
230 info = -( 600 + ctxt_ )
231 ELSE
232 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
233 IF( info.EQ.0 ) THEN
234 onenrm = norm.EQ.'1' .OR. lsame( norm, 'O' )
235 iarow = indxg2p( ia, desca( mb_ ), myrow, desca( rsrc_ ),
236 $ nprow )
237 iacol = indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
238 $ npcol )
239 npmod = numroc( n + mod( ia-1, desca( mb_ ) ), desca( mb_ ),
240 $ myrow, iarow, nprow )
241 nqmod = numroc( n + mod( ja-1, desca( nb_ ) ), desca( nb_ ),
242 $ mycol, iacol, npcol )
243 lwmin = 2*npmod +
244 $ max( 2, max( desca( nb_ )*
245 $ max( 1, iceil( nprow-1, npcol ) ), nqmod +
246 $ desca( nb_ )*
247 $ max( 1, iceil( npcol-1, nprow ) ) ) )
248 work( 1 ) = dble( lwmin )
249 lrwmin = max( 1, 2*nqmod )
250 rwork( 1 ) = dble( lrwmin )
251 lquery = ( lwork.EQ.-1 .OR. lrwork.EQ.-1 )
252*
253 IF( .NOT.onenrm .AND. .NOT.lsame( norm, 'i' ) ) THEN
254 INFO = -1
255.LT. ELSE IF( ANORMZERO ) THEN
256 INFO = -7
257.LT..AND..NOT. ELSE IF( LWORKLWMIN LQUERY ) THEN
258 INFO = -10
259.LT..AND..NOT. ELSE IF( LRWORKLRWMIN LQUERY ) THEN
260 INFO = -12
261 END IF
262 END IF
263*
264 IF( ONENRM ) THEN
265 IDUM1( 1 ) = ICHAR( '1' )
266 ELSE
267 IDUM1( 1 ) = ICHAR( 'i' )
268 END IF
269 IDUM2( 1 ) = 1
270.EQ. IF( LWORK-1 ) THEN
271 IDUM1( 2 ) = -1
272 ELSE
273 IDUM1( 2 ) = 1
274 END IF
275 IDUM2( 2 ) = 10
276.EQ. IF( LRWORK-1 ) THEN
277 IDUM1( 3 ) = -1
278 ELSE
279 IDUM1( 3 ) = 1
280 END IF
281 IDUM2( 3 ) = 12
282 CALL PCHK1MAT( N, 2, N, 2, IA, JA, DESCA, 6, 3, IDUM1, IDUM2,
283 $ INFO )
284 END IF
285*
286.NE. IF( INFO0 ) THEN
287 CALL PXERBLA( ICTXT, 'pzgecon', -INFO )
288 RETURN
289 ELSE IF( LQUERY ) THEN
290 RETURN
291 END IF
292*
293* Quick return if possible
294*
295 RCOND = ZERO
296.EQ. IF( N0 ) THEN
297 RCOND = ONE
298 RETURN
299.EQ. ELSE IF( ANORMZERO ) THEN
300 RETURN
301.EQ. ELSE IF( N1 ) THEN
302 RCOND = ONE
303 RETURN
304 END IF
305*
306 CALL PB_TOPGET( ICTXT, 'combine', 'columnwise', COLCTOP )
307 CALL PB_TOPGET( ICTXT, 'combine', 'rowwise', ROWCTOP )
308 CALL PB_TOPSET( ICTXT, 'combine', 'columnwise', '1-tree' )
309 CALL PB_TOPSET( ICTXT, 'combine', 'rowwise', '1-tree' )
310*
311 SMLNUM = PDLAMCH( ICTXT, 'safe minimum' )
312 IROFF = MOD( IA-1, DESCA( MB_ ) )
313 ICOFF = MOD( JA-1, DESCA( NB_ ) )
314 CALL INFOG2L( IA, JA, DESCA, NPROW, NPCOL, MYROW, MYCOL, IIA, JJA,
315 $ IAROW, IACOL )
316 NP = NUMROC( N+IROFF, DESCA( MB_ ), MYROW, IAROW, NPROW )
317 NQ = NUMROC( N+ICOFF, DESCA( NB_ ), MYCOL, IACOL, NPCOL )
318 IV = IROFF + 1
319 IX = IV
320 JV = ICOFF + 1
321 JX = JV
322*
323 IPX = 1
324 IPV = IPX + NP
325 IPW = IPV + NP
326 IPNL = 1
327 IPNU = IPNL + NQ
328*
329 CALL DESCSET( DESCV, N+IROFF, 1, DESCA( MB_ ), 1, IAROW, MYCOL,
330 $ ICTXT, MAX( 1, NP ) )
331 CALL DESCSET( DESCX, N+IROFF, 1, DESCA( MB_ ), 1, IAROW, MYCOL,
332 $ ICTXT, MAX( 1, NP ) )
333*
334* Estimate the norm of inv(A).
335*
336 AINVNM = ZERO
337 NORMIN = 'n'
338 IF( ONENRM ) THEN
339 KASE1 = 1
340 ELSE
341 KASE1 = 2
342 END IF
343 KASE = 0
344*
345 10 CONTINUE
346 CALL PZLACON( N, WORK( IPV ), IV, JV, DESCV, WORK( IPX ), IX, JX,
347 $ DESCX, AINVNM, KASE )
348.NE. IF( KASE0 ) THEN
349.EQ. IF( KASEKASE1 ) THEN
350*
351* Multiply by inv(L).
352*
353 DESCX( CSRC_ ) = IACOL
354 CALL PZLATRS( 'lower', 'no transpose', 'unit', NORMIN,
355 $ N, A, IA, JA, DESCA, WORK( IPX ), IX, JX,
356 $ DESCX, SL, RWORK( IPNL ), WORK( IPW ) )
357 DESCX( CSRC_ ) = MYCOL
358*
359* Multiply by inv(U).
360*
361 DESCX( CSRC_ ) = IACOL
362 CALL PZLATRS( 'upper', 'no transpose', 'non-unit', NORMIN,
363 $ N, A, IA, JA, DESCA, WORK( IPX ), IX, JX,
364 $ DESCX, SU, RWORK( IPNU ), WORK( IPW ) )
365 DESCX( CSRC_ ) = MYCOL
366 ELSE
367*
368* Multiply by inv(U').
369*
370 DESCX( CSRC_ ) = IACOL
371 CALL PZLATRS( 'upper', 'conjugate transpose', 'non-unit',
372 $ NORMIN, N, A, IA, JA, DESCA, WORK( IPX ), IX,
373 $ JX, DESCX, SU, RWORK( IPNU ), WORK( IPW ) )
374 DESCX( CSRC_ ) = MYCOL
375*
376* Multiply by inv(L').
377*
378 DESCX( CSRC_ ) = IACOL
379 CALL PZLATRS( 'lower', 'conjugate transpose', 'unit',
380 $ NORMIN, N, A, IA, JA, DESCA, WORK( IPX ),
381 $ IX, JX, DESCX, SL, RWORK( IPNL ),
382 $ WORK( IPW ) )
383 DESCX( CSRC_ ) = MYCOL
384 END IF
385*
386* Divide X by 1/(SL*SU) if doing so will not cause overflow.
387*
388 SCALE = SL*SU
389 NORMIN = 'y'
390.NE. IF( SCALEONE ) THEN
391 CALL PZAMAX( N, WMAX, IXX, WORK( IPX ), IX, JX, DESCX, 1 )
392.EQ..AND..EQ. IF( DESCX( M_ )1 N1 ) THEN
393 CALL PB_TOPGET( ICTXT, 'broadcast', 'columnwise', CBTOP )
394.EQ. IF( MYROWIAROW ) THEN
395 CALL ZGEBS2D( ICTXT, 'column', CBTOP, 1, 1, WMAX, 1 )
396 ELSE
397 CALL ZGEBR2D( ICTXT, 'column', CBTOP, 1, 1, WMAX, 1,
398 $ IAROW, MYCOL )
399 END IF
400 END IF
401.LT..OR..EQ. IF( SCALECABS1( WMAX )*SMLNUM SCALEZERO )
402 $ GO TO 20
403 CALL PZDRSCL( N, SCALE, WORK( IPX ), IX, JX, DESCX, 1 )
404 END IF
405 GO TO 10
406 END IF
407*
408* Compute the estimate of the reciprocal condition number.
409*
410.NE. IF( AINVNMZERO )
411 $ RCOND = ( ONE / AINVNM ) / ANORM
412*
413 20 CONTINUE
414*
415 CALL PB_TOPSET( ICTXT, 'combine', 'columnwise', COLCTOP )
416 CALL PB_TOPSET( ICTXT, 'combine', 'rowwise', ROWCTOP )
417*
418 RETURN
419*
420* End of PZGECON
421*
422 END
#define max(a, b)
Definition macros.h:21
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
Definition mpi.f:947
subroutine zgebr2d(contxt, scope, top, m, n, a, lda)
Definition mpi.f:1092
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition mpi.f:1577
subroutine zgebs2d(contxt, scope, top, m, n, a, lda)
Definition mpi.f:1051
subroutine pxerbla(contxt, srname, info)
Definition mpi.f:1600
subroutine descset(desc, m, n, mb, nb, irsrc, icsrc, ictxt, lld)
Definition mpi.f:1610
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 pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
Definition pchkxmat.f:3
subroutine pzdrscl(n, sa, sx, ix, jx, descx, incx)
Definition pzdrscl.f:2
subroutine pzgecon(norm, n, a, ia, ja, desca, anorm, rcond, work, lwork, rwork, lrwork, info)
Definition pzgecon.f:3
subroutine pzlacon(n, v, iv, jv, descv, x, ix, jx, descx, est, kase)
Definition pzlacon.f:3
subroutine pzlatrs(uplo, trans, diag, normin, n, a, ia, ja, desca, x, ix, jx, descx, scale, cnorm, work)
Definition pzlatrs.f:4