ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
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 * ..
156 * .. External Subroutines ..
157  EXTERNAL blacs_abort, blacs_gridinfo, chk1mat, igebr2d,
158  $ igebs2d, infog2l, pb_topget, pxerbla, zgemv,
159  $ zlacgv, zdscal
160 * ..
161 * .. Intrinsic Functions ..
162  INTRINSIC dble, mod, sqrt
163 * ..
164 * .. External Functions ..
165  LOGICAL LSAME
166  COMPLEX*16 ZDOTC
167  EXTERNAL lsame, zdotc
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  ajj = dble( a( idiag ) ) -
237  $ zdotc( j-ja, a( ioffa ), 1, a( ioffa ), 1 )
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  ajj = dble( a( idiag ) ) -
303  $ zdotc( j-ja, a( ioffa ), lda, a( ioffa ), lda )
304  IF ( ajj.LE.zero ) THEN
305  a( idiag ) = ajj
306  info = j - ja + 1
307  GO TO 40
308  END IF
309  ajj = sqrt( ajj )
310  a( idiag ) = ajj
311 *
312 * Compute elements J+1:JA+N-1 of column J.
313 *
314  IF( j.LT.ja+n-1 ) THEN
315  icurr = idiag + 1
316  CALL zlacgv( j-ja, a( ioffa ), lda )
317  CALL zgemv( 'No transpose', ja+n-j-1, j-ja, -cone,
318  $ a( ioffa+1 ), lda, a( ioffa ), lda,
319  $ cone, a( icurr ), 1 )
320  CALL zlacgv( j-ja, a( ioffa ), lda )
321  CALL zdscal( ja+n-j-1, one / ajj, a( icurr ), 1 )
322  END IF
323  idiag = idiag + lda + 1
324  ioffa = ioffa + 1
325  30 CONTINUE
326 *
327  40 CONTINUE
328 *
329 * Broadcast INFO to everyone in IACOL
330 *
331  CALL igebs2d( ictxt, 'Columnwise', colbtop, 1, 1, info,
332  $ 1 )
333 *
334  ELSE
335 *
336  CALL igebr2d( ictxt, 'Columnwise', colbtop, 1, 1, info,
337  $ 1, iarow, mycol )
338 *
339  END IF
340 *
341 * IACOL bcasts INFO along rows so that everyone has it
342 *
343  CALL igebs2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1 )
344 *
345  ELSE
346 *
347  CALL igebr2d( ictxt, 'Rowwise', rowbtop, 1, 1, info, 1,
348  $ myrow, iacol )
349 *
350  END IF
351 *
352  END IF
353 *
354  RETURN
355 *
356 * End of PZPOTF2
357 *
358  END
infog2l
subroutine infog2l(GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW, MYCOL, LRINDX, LCINDX, RSRC, CSRC)
Definition: infog2l.f:3
chk1mat
subroutine chk1mat(MA, MAPOS0, NA, NAPOS0, IA, JA, DESCA, DESCAPOS0, INFO)
Definition: chk1mat.f:3
pxerbla
subroutine pxerbla(ICTXT, SRNAME, INFO)
Definition: pxerbla.f:2
pzpotf2
subroutine pzpotf2(UPLO, N, A, IA, JA, DESCA, INFO)
Definition: pzpotf2.f:2