OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
pzpotrf.f
Go to the documentation of this file.
1 SUBROUTINE pzpotrf( UPLO, N, A, IA, JA, DESCA, INFO )
2*
3* -- ScaLAPACK routine (version 1.7) --
4* University of Tennessee, Knoxville, Oak Ridge National Laboratory,
5* and University of California, Berkeley.
6* May 25, 2001
7*
8* .. Scalar Arguments ..
9 CHARACTER UPLO
10 INTEGER IA, INFO, JA, N
11* ..
12* .. Array Arguments ..
13 INTEGER DESCA( * )
14 COMPLEX*16 A( * )
15* ..
16*
17* Purpose
18* =======
19*
20* PZPOTRF computes the Cholesky factorization of an N-by-N complex
21* hermitian positive definite distributed matrix sub( A ) denoting
22* A(IA:IA+N-1, JA:JA+N-1).
23*
24* The factorization has the form
25*
26* sub( A ) = U' * U , if UPLO = 'U', or
27*
28* sub( A ) = L * L', if UPLO = 'L',
29*
30* where U is an upper triangular matrix and L is lower triangular.
31*
32* Notes
33* =====
34*
35* Each global data object is described by an associated description
36* vector. This vector stores the information required to establish
37* the mapping between an object element and its corresponding process
38* and memory location.
39*
40* Let A be a generic term for any 2D block cyclicly distributed array.
41* Such a global array has an associated description vector DESCA.
42* In the following comments, the character _ should be read as
43* "of the global array".
44*
45* NOTATION STORED IN EXPLANATION
46* --------------- -------------- --------------------------------------
47* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
48* DTYPE_A = 1.
49* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
50* the BLACS process grid A is distribu-
51* ted over. The context itself is glo-
52* bal, but the handle (the integer
53* value) may vary.
54* M_A (global) DESCA( M_ ) The number of rows in the global
55* array A.
56* N_A (global) DESCA( N_ ) The number of columns in the global
57* array A.
58* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
59* the rows of the array.
60* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
61* the columns of the array.
62* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
63* row of the array A is distributed.
64* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
65* first column of the array A is
66* distributed.
67* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
68* array. LLD_A >= MAX(1,LOCr(M_A)).
69*
70* Let K be the number of rows or columns of a distributed matrix,
71* and assume that its process grid has dimension p x q.
72* LOCr( K ) denotes the number of elements of K that a process
73* would receive if K were distributed over the p processes of its
74* process column.
75* Similarly, LOCc( K ) denotes the number of elements of K that a
76* process would receive if K were distributed over the q processes of
77* its process row.
78* The values of LOCr() and LOCc() may be determined via a call to the
79* ScaLAPACK tool function, NUMROC:
80* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
81* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
82* An upper bound for these quantities may be computed by:
83* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
84* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
85*
86* This routine requires square block decomposition ( MB_A = NB_A ).
87*
88* Arguments
89* =========
90*
91* UPLO (global input) CHARACTER
92* = 'U': Upper triangle of sub( A ) is stored;
93* = 'L': Lower triangle of sub( A ) is stored.
94*
95* N (global input) INTEGER
96* The number of rows and columns to be operated on, i.e. the
97* order of the distributed submatrix sub( A ). N >= 0.
98*
99* A (local input/local output) COMPLEX*16 pointer into the
100* local memory to an array of dimension (LLD_A, LOCc(JA+N-1)).
101* On entry, this array contains the local pieces of the
102* N-by-N Hermitian distributed matrix sub( A ) to be factored.
103* If UPLO = 'U', the leading N-by-N upper triangular part of
104* sub( A ) contains the upper triangular part of the matrix,
105* and its strictly lower triangular part is not referenced.
106* If UPLO = 'L', the leading N-by-N lower triangular part of
107* sub( A ) contains the lower triangular part of the distribu-
108* ted matrix, and its strictly upper triangular part is not
109* referenced. On exit, if UPLO = 'U', the upper triangular
110* part of the distributed matrix contains the Cholesky factor
111* U, if UPLO = 'L', the lower triangular part of the distribu-
112* ted matrix contains the Cholesky factor L.
113*
114* IA (global input) INTEGER
115* The row index in the global array A indicating the first
116* row of sub( A ).
117*
118* JA (global input) INTEGER
119* The column index in the global array A indicating the
120* first column of sub( A ).
121*
122* DESCA (global and local input) INTEGER array of dimension DLEN_.
123* The array descriptor for the distributed matrix A.
124*
125* INFO (global output) INTEGER
126* = 0: successful exit
127* < 0: If the i-th argument is an array and the j-entry had
128* an illegal value, then INFO = -(i*100+j), if the i-th
129* argument is a scalar and had an illegal value, then
130* INFO = -i.
131* > 0: If INFO = K, the leading minor of order K,
132* A(IA:IA+K-1,JA:JA+K-1) is not positive definite, and
133* the factorization could not be completed.
134*
135* =====================================================================
136*
137* .. Parameters ..
138 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
139 $ LLD_, MB_, M_, NB_, N_, RSRC_
140 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
141 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
142 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
143 DOUBLE PRECISION ONE
144 parameter( one = 1.0d+0 )
145 COMPLEX*16 CONE
146 parameter( cone = ( 1.0d+0, 0.0d+0 ) )
147* ..
148* .. Local Scalars ..
149 LOGICAL UPPER
150 CHARACTER COLBTOP, ROWBTOP
151 INTEGER I, ICOFF, ICTXT, IROFF, J, JB, JN, MYCOL,
152 $ MYROW, NPCOL, NPROW
153* ..
154* .. Local Arrays ..
155 INTEGER IDUM1( 1 ), IDUM2( 1 )
156* ..
157* .. External Subroutines ..
158 EXTERNAL blacs_gridinfo, chk1mat, pchk1mat, pb_topget,
159 $ pb_topset, pxerbla, pzpotf2, pzherk,
160 $ pztrsm
161* ..
162* .. External Functions ..
163 LOGICAL LSAME
164 INTEGER ICEIL
165 EXTERNAL iceil, lsame
166* ..
167* .. Intrinsic Functions ..
168 INTRINSIC ichar, min, mod
169* ..
170* .. Executable Statements ..
171*
172* Get grid parameters
173*
174 ictxt = desca( ctxt_ )
175 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
176*
177* Test the input parameters
178*
179 info = 0
180 IF( nprow.EQ.-1 ) THEN
181 info = -(600+ctxt_)
182 ELSE
183 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
184 upper = lsame( uplo, 'U' )
185 IF( info.EQ.0 ) THEN
186 iroff = mod( ia-1, desca( mb_ ) )
187 icoff = mod( ja-1, desca( nb_ ) )
188 IF ( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
189 info = -1
190 ELSE IF( iroff.NE.0 ) THEN
191 info = -4
192 ELSE IF( icoff.NE.0 ) THEN
193 info = -5
194 ELSE IF( desca( mb_ ).NE.desca( nb_ ) ) THEN
195 info = -(600+nb_)
196 END IF
197 END IF
198 IF( upper ) THEN
199 idum1( 1 ) = ichar( 'U' )
200 ELSE
201 idum1( 1 ) = ichar( 'L' )
202 END IF
203 idum2( 1 ) = 1
204 CALL pchk1mat( n, 2, n, 2, ia, ja, desca, 6, 1, idum1, idum2,
205 $ info )
206 END IF
207*
208 IF( info.NE.0 ) THEN
209 CALL pxerbla( ictxt, 'PZPOTRF', -info )
210 RETURN
211 END IF
212*
213* Quick return if possible
214*
215 IF( n.EQ.0 )
216 $ RETURN
217*
218 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
219 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
220*
221 IF( upper ) THEN
222*
223* Split-ring topology for the communication along process
224* columns, 1-tree topology along process rows.
225*
226 CALL pb_topset( ictxt, 'Broadcast', 'Rowwise', ' ' )
227 CALL pb_topset( ictxt, 'Broadcast', 'Columnwise', 'S-ring' )
228*
229* A is upper triangular, compute Cholesky factorization A = U'*U.
230*
231* Handle the first block of columns separately
232*
233 jn = min( iceil( ja, desca( nb_ ) )*desca(nb_), ja+n-1 )
234 jb = jn - ja + 1
235*
236* Perform unblocked Cholesky factorization on JB block
237*
238 CALL pzpotf2( uplo, jb, a, ia, ja, desca, info )
239 IF( info.NE.0 )
240 $ GO TO 30
241*
242 IF( jb+1.LE.n ) THEN
243*
244* Form the row panel of U using the triangular solver
245*
246 CALL pztrsm( 'Left', uplo, 'conjugate transpose',
247 $ 'non-unit', JB, N-JB, CONE, A, IA, JA, DESCA,
248 $ A, IA, JA+JB, DESCA )
249*
250* Update the trailing matrix, A = A - U'*U
251*
252 CALL PZHERK( UPLO, 'conjugate transpose', N-JB, JB, -ONE, A,
253 $ IA, JA+JB, DESCA, ONE, A, IA+JB, JA+JB, DESCA )
254 END IF
255*
256* Loop over remaining block of columns
257*
258 DO 10 J = JN+1, JA+N-1, DESCA( NB_ )
259 JB = MIN( N-J+JA, DESCA( NB_ ) )
260 I = IA + J - JA
261*
262* Perform unblocked Cholesky factorization on JB block
263*
264 CALL PZPOTF2( UPLO, JB, A, I, J, DESCA, INFO )
265.NE. IF( INFO0 ) THEN
266 INFO = INFO + J - JA
267 GO TO 30
268 END IF
269*
270.LE. IF( J-JA+JB+1N ) THEN
271*
272* Form the row panel of U using the triangular solver
273*
274 CALL PZTRSM( 'left', UPLO, 'conjugate transpose',
275 $ 'non-unit', JB, N-J-JB+JA, CONE, A, I, J,
276 $ DESCA, A, I, J+JB, DESCA )
277*
278* Update the trailing matrix, A = A - U'*U
279*
280 CALL PZHERK( UPLO, 'conjugate transpose', N-J-JB+JA, JB,
281 $ -ONE, A, I, J+JB, DESCA, ONE, A, I+JB,
282 $ J+JB, DESCA )
283 END IF
284 10 CONTINUE
285*
286 ELSE
287*
288* 1-tree topology for the communication along process columns,
289* Split-ring topology along process rows.
290*
291 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', 's-ring' )
292 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', ' ' )
293*
294* A is lower triangular, compute Cholesky factorization A = L*L'
295* (right-looking)
296*
297* Handle the first block of columns separately
298*
299 JN = MIN( ICEIL( JA, DESCA( NB_ ) )*DESCA( NB_ ), JA+N-1 )
300 JB = JN - JA + 1
301*
302* Perform unblocked Cholesky factorization on JB block
303*
304 CALL PZPOTF2( UPLO, JB, A, IA, JA, DESCA, INFO )
305.NE. IF( INFO0 )
306 $ GO TO 30
307*
308.LE. IF( JB+1N ) THEN
309*
310* Form the column panel of L using the triangular solver
311*
312 CALL PZTRSM( 'right', UPLO, 'conjugate transpose',
313 $ 'non-unit', N-JB, JB, CONE, A, IA, JA, DESCA,
314 $ A, IA+JB, JA, DESCA )
315*
316* Update the trailing matrix, A = A - L*L'
317*
318 CALL PZHERK( UPLO, 'no transpose', N-JB, JB, -ONE, A, IA+JB,
319 $ JA, DESCA, ONE, A, IA+JB, JA+JB, DESCA )
320*
321 END IF
322*
323 DO 20 J = JN+1, JA+N-1, DESCA( NB_ )
324 JB = MIN( N-J+JA, DESCA( NB_ ) )
325 I = IA + J - JA
326*
327* Perform unblocked Cholesky factorization on JB block
328*
329 CALL PZPOTF2( UPLO, JB, A, I, J, DESCA, INFO )
330.NE. IF( INFO0 ) THEN
331 INFO = INFO + J - JA
332 GO TO 30
333 END IF
334*
335.LE. IF( J-JA+JB+1N ) THEN
336*
337* Form the column panel of L using the triangular solver
338*
339 CALL PZTRSM( 'right', UPLO, 'conjugate transpose',
340 $ 'non-unit', N-J-JB+JA, JB, CONE, A, I, J,
341 $ DESCA, A, I+JB, J, DESCA )
342*
343* Update the trailing matrix, A = A - L*L'
344*
345 CALL PZHERK( UPLO, 'no transpose', N-J-JB+JA, JB, -ONE,
346 $ A, I+JB, J, DESCA, ONE, A, I+JB, J+JB,
347 $ DESCA )
348*
349 END IF
350 20 CONTINUE
351*
352 END IF
353*
354 30 CONTINUE
355*
356 CALL PB_TOPSET( ICTXT, 'broadcast', 'rowwise', ROWBTOP )
357 CALL PB_TOPSET( ICTXT, 'broadcast', 'columnwise', COLBTOP )
358*
359 RETURN
360*
361* End of PZPOTRF
362*
363 END
#define min(a, b)
Definition macros.h:20
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 pztrsm(side, uplo, transa, diag, m, n, alpha, a, ia, ja, desca, b, ib, jb, descb)
Definition mpi.f:1483
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 pzpotf2(uplo, n, a, ia, ja, desca, info)
Definition pzpotf2.f:2
subroutine pzpotrf(uplo, n, a, ia, ja, desca, info)
Definition pzpotrf.f:2