SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches
pzpotf2.f
Go to the documentation of this file.
1 SUBROUTINE pzpotf2( 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 1, 1997
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* PZPOTF2 computes the Cholesky factorization of a complex hermitian
21* positive definite distributed matrix sub( A )=A(IA:IA+N-1,JA:JA+N-1).
22*
23* The factorization has the form
24*
25* sub( A ) = U' * U , if UPLO = 'U', or
26*
27* sub( A ) = L * L', if UPLO = 'L',
28*
29* where U is an upper triangular matrix and L is lower triangular.
30*
31* Notes
32* =====
33*
34* Each global data object is described by an associated description
35* vector. This vector stores the information required to establish
36* the mapping between an object element and its corresponding process
37* and memory location.
38*
39* Let A be a generic term for any 2D block cyclicly distributed array.
40* Such a global array has an associated description vector DESCA.
41* In the following comments, the character _ should be read as
42* "of the global array".
43*
44* NOTATION STORED IN EXPLANATION
45* --------------- -------------- --------------------------------------
46* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
47* DTYPE_A = 1.
48* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
49* the BLACS process grid A is distribu-
50* ted over. The context itself is glo-
51* bal, but the handle (the integer
52* value) may vary.
53* M_A (global) DESCA( M_ ) The number of rows in the global
54* array A.
55* N_A (global) DESCA( N_ ) The number of columns in the global
56* array A.
57* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
58* the rows of the array.
59* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
60* the columns of the array.
61* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
62* row of the array A is distributed.
63* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
64* first column of the array A is
65* distributed.
66* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
67* array. LLD_A >= MAX(1,LOCr(M_A)).
68*
69* Let K be the number of rows or columns of a distributed matrix,
70* and assume that its process grid has dimension p x q.
71* LOCr( K ) denotes the number of elements of K that a process
72* would receive if K were distributed over the p processes of its
73* process column.
74* Similarly, LOCc( K ) denotes the number of elements of K that a
75* process would receive if K were distributed over the q processes of
76* its process row.
77* The values of LOCr() and LOCc() may be determined via a call to the
78* ScaLAPACK tool function, NUMROC:
79* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
80* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
81* An upper bound for these quantities may be computed by:
82* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
83* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
84*
85* This routine requires N <= NB_A-MOD(JA-1, NB_A) and square block
86* 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 symmetric 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 (local 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, ZERO
144 parameter( one = 1.0d+0, zero = 0.0d+0 )
145 COMPLEX*16 CONE
146 parameter( cone = 1.0d+0 )
147* ..
148* .. Local Scalars ..
149 LOGICAL UPPER
150 CHARACTER COLBTOP, ROWBTOP
151 INTEGER IACOL, IAROW, ICOFF, ICTXT, ICURR, IDIAG, IIA,
152 $ IOFFA, IROFF, J, JJA, LDA, MYCOL, MYROW,
153 $ NPCOL, NPROW
154 DOUBLE PRECISION AJJ
155 COMPLEX*16 DOT
156* ..
157* .. External Subroutines ..
158 EXTERNAL blacs_abort, blacs_gridinfo, chk1mat, igebr2d,
159 $ igebs2d, infog2l, pb_topget, pxerbla, zgemv,
160 $ zlacgv, zdscal, zzdotc
161* ..
162* .. Intrinsic Functions ..
163 INTRINSIC dble, mod, sqrt
164* ..
165* .. External Functions ..
166 LOGICAL LSAME
167 EXTERNAL lsame
168* ..
169* .. Executable Statements ..
170*
171* Get grid parameters
172*
173 ictxt = desca( ctxt_ )
174 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
175*
176* Test the input parameters.
177*
178 info = 0
179 IF( nprow.EQ.-1 ) THEN
180 info = -(600+ctxt_)
181 ELSE
182 CALL chk1mat( n, 2, n, 2, ia, ja, desca, 6, info )
183 IF( info.EQ.0 ) THEN
184 upper = lsame( uplo, 'U' )
185 iroff = mod( ia-1, desca( mb_ ) )
186 icoff = mod( ja-1, desca( nb_ ) )
187 IF ( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
188 info = -1
189 ELSE IF( n+icoff.GT.desca( nb_ ) ) THEN
190 info = -2
191 ELSE IF( iroff.NE.0 ) THEN
192 info = -4
193 ELSE IF( icoff.NE.0 ) THEN
194 info = -5
195 ELSE IF( desca( mb_ ).NE.desca( nb_ ) ) THEN
196 info = -(600+nb_)
197 END IF
198 END IF
199 END IF
200*
201 IF( info.NE.0 ) THEN
202 CALL pxerbla( ictxt, 'PZPOTF2', -info )
203 CALL blacs_abort( ictxt, 1 )
204 RETURN
205 END IF
206*
207* Quick return if possible
208*
209 IF( n.EQ.0 )
210 $ RETURN
211*
212* Compute local information
213*
214 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
215 $ iarow, iacol )
216 CALL pb_topget( ictxt, 'Broadcast', 'Rowwise', rowbtop )
217 CALL pb_topget( ictxt, 'Broadcast', 'Columnwise', colbtop )
218*
219 IF ( upper ) THEN
220*
221* Process (IAROW, IACOL) owns block to be factorized
222*
223 IF( myrow.EQ.iarow ) THEN
224 IF( mycol.EQ.iacol ) THEN
225*
226* Compute the Cholesky factorization A = U'*U.
227*
228 lda = desca( lld_ )
229 idiag = iia + ( jja - 1 ) * lda
230 ioffa = idiag
231*
232 DO 10 j = ja, ja+n-1
233*
234* Compute U(J,J) and test for non-positive-definiteness.
235*
236 CALL zzdotc( j-ja, dot, a( ioffa ), 1, a( ioffa ), 1 )
237 ajj = dble( a( idiag ) - dot )
238 IF( ajj.LE.zero ) THEN
239 a( idiag ) = ajj
240 info = j - ja + 1
241 GO TO 20
242 END IF
243 ajj = sqrt( ajj )
244 a( idiag ) = ajj
245*
246* Compute elements J+1:JA+N-1 of row J.
247*
248 IF( j.LT.ja+n-1 ) THEN
249 icurr = idiag + lda
250 CALL zlacgv( j-ja, a( ioffa ), 1 )
251 CALL zgemv( 'Transpose', j-ja, ja+n-j-1, -cone,
252 $ a( ioffa+lda ), lda, a( ioffa ), 1,
253 $ cone, a( icurr ), lda )
254 CALL zlacgv( j-ja, a( ioffa ), 1 )
255 CALL zdscal( ja+n-j-1, one / ajj, a( icurr ),
256 $ lda )
257 END IF
258 idiag = idiag + lda + 1
259 ioffa = ioffa + lda
260 10 CONTINUE
261*
262 20 CONTINUE
263*
264* Broadcast INFO to all processes in my IAROW.
265*
266 CALL igebs2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1 )
267*
268 ELSE
269*
270 CALL igebr2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1,
271 $ myrow, iacol )
272 END IF
273*
274* IAROW bcasts along columns so that everyone has INFO
275*
276 CALL igebs2d( ictxt, 'Columnwise', colbtop, 1, 1, info, 1 )
277*
278 ELSE
279*
280 CALL igebr2d( ictxt, 'Columnwise', colbtop, 1, 1, info, 1,
281 $ iarow, mycol )
282*
283 END IF
284*
285 ELSE
286*
287* Process (IAROW, IACOL) owns block to be factorized
288*
289 IF( mycol.EQ.iacol ) THEN
290 IF( myrow.EQ.iarow ) THEN
291*
292* Compute the Cholesky factorization A = L*L'.
293*
294 lda = desca( lld_ )
295 idiag = iia + ( jja - 1 ) * lda
296 ioffa = idiag
297*
298 DO 30 j = ja, ja+n-1
299*
300* Compute L(J,J) and test for non-positive-definiteness.
301*
302 CALL zzdotc( j-ja, dot, a( ioffa ), lda, a( ioffa ),
303 $ lda )
304 ajj = dble( a( idiag ) - dot )
305 IF ( ajj.LE.zero ) THEN
306 a( idiag ) = ajj
307 info = j - ja + 1
308 GO TO 40
309 END IF
310 ajj = sqrt( ajj )
311 a( idiag ) = ajj
312*
313* Compute elements J+1:JA+N-1 of column J.
314*
315 IF( j.LT.ja+n-1 ) THEN
316 icurr = idiag + 1
317 CALL zlacgv( j-ja, a( ioffa ), lda )
318 CALL zgemv( 'No transpose', ja+n-j-1, j-ja, -cone,
319 $ a( ioffa+1 ), lda, a( ioffa ), lda,
320 $ cone, a( icurr ), 1 )
321 CALL zlacgv( j-ja, a( ioffa ), lda )
322 CALL zdscal( ja+n-j-1, one / ajj, a( icurr ), 1 )
323 END IF
324 idiag = idiag + lda + 1
325 ioffa = ioffa + 1
326 30 CONTINUE
327*
328 40 CONTINUE
329*
330* Broadcast INFO to everyone in IACOL
331*
332 CALL igebs2d( ictxt, 'Columnwise', colbtop, 1, 1, info,
333 $ 1 )
334*
335 ELSE
336*
337 CALL igebr2d( ictxt, 'Columnwise', colbtop, 1, 1, info,
338 $ 1, iarow, mycol )
339*
340 END IF
341*
342* IACOL bcasts INFO along rows so that everyone has it
343*
344 CALL igebs2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1 )
345*
346 ELSE
347*
348 CALL igebr2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1,
349 $ myrow, iacol )
350*
351 END IF
352*
353 END IF
354*
355 RETURN
356*
357* End of PZPOTF2
358*
359 END
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition chk1mat.f:3
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition infog2l.f:3
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
subroutine pzpotf2(uplo, n, a, ia, ja, desca, info)
Definition pzpotf2.f:2
subroutine zzdotc(n, dotc, x, incx, y, incy)
Definition zzdotc.f:2