SCALAPACK 2.2.2
LAPACK: Linear Algebra PACKage
Loading...
Searching...
No Matches

◆ pdtrtri()

subroutine pdtrtri ( character  uplo,
character  diag,
integer  n,
double precision, dimension( * )  a,
integer  ia,
integer  ja,
integer, dimension( * )  desca,
integer  info 
)

Definition at line 1 of file pdtrtri.f.

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 DIAG, UPLO
10 INTEGER IA, INFO, JA, N
11* ..
12* .. Array Arguments ..
13 INTEGER DESCA( * )
14 DOUBLE PRECISION A( * )
15* ..
16*
17* Purpose
18* =======
19*
20* PDTRTRI computes the inverse of a upper or lower triangular
21* distributed matrix sub( A ) = A(IA:IA+N-1,JA:JA+N-1).
22*
23* Notes
24* =====
25*
26* Each global data object is described by an associated description
27* vector. This vector stores the information required to establish
28* the mapping between an object element and its corresponding process
29* and memory location.
30*
31* Let A be a generic term for any 2D block cyclicly distributed array.
32* Such a global array has an associated description vector DESCA.
33* In the following comments, the character _ should be read as
34* "of the global array".
35*
36* NOTATION STORED IN EXPLANATION
37* --------------- -------------- --------------------------------------
38* DTYPE_A(global) DESCA( DTYPE_ )The descriptor type. In this case,
39* DTYPE_A = 1.
40* CTXT_A (global) DESCA( CTXT_ ) The BLACS context handle, indicating
41* the BLACS process grid A is distribu-
42* ted over. The context itself is glo-
43* bal, but the handle (the integer
44* value) may vary.
45* M_A (global) DESCA( M_ ) The number of rows in the global
46* array A.
47* N_A (global) DESCA( N_ ) The number of columns in the global
48* array A.
49* MB_A (global) DESCA( MB_ ) The blocking factor used to distribute
50* the rows of the array.
51* NB_A (global) DESCA( NB_ ) The blocking factor used to distribute
52* the columns of the array.
53* RSRC_A (global) DESCA( RSRC_ ) The process row over which the first
54* row of the array A is distributed.
55* CSRC_A (global) DESCA( CSRC_ ) The process column over which the
56* first column of the array A is
57* distributed.
58* LLD_A (local) DESCA( LLD_ ) The leading dimension of the local
59* array. LLD_A >= MAX(1,LOCr(M_A)).
60*
61* Let K be the number of rows or columns of a distributed matrix,
62* and assume that its process grid has dimension p x q.
63* LOCr( K ) denotes the number of elements of K that a process
64* would receive if K were distributed over the p processes of its
65* process column.
66* Similarly, LOCc( K ) denotes the number of elements of K that a
67* process would receive if K were distributed over the q processes of
68* its process row.
69* The values of LOCr() and LOCc() may be determined via a call to the
70* ScaLAPACK tool function, NUMROC:
71* LOCr( M ) = NUMROC( M, MB_A, MYROW, RSRC_A, NPROW ),
72* LOCc( N ) = NUMROC( N, NB_A, MYCOL, CSRC_A, NPCOL ).
73* An upper bound for these quantities may be computed by:
74* LOCr( M ) <= ceil( ceil(M/MB_A)/NPROW )*MB_A
75* LOCc( N ) <= ceil( ceil(N/NB_A)/NPCOL )*NB_A
76*
77* Arguments
78* =========
79*
80* UPLO (global input) CHARACTER
81* Specifies whether the distributed matrix sub( A ) is upper
82* or lower triangular:
83* = 'U': Upper triangular,
84* = 'L': Lower triangular.
85*
86* DIAG (global input) CHARACTER
87* Specifies whether or not the distributed matrix sub( A )
88* is unit triangular:
89* = 'N': Non-unit triangular,
90* = 'U': Unit triangular.
91*
92* N (global input) INTEGER
93* The number of rows and columns to be operated on, i.e. the
94* order of the distributed submatrix sub( A ). N >= 0.
95*
96* A (local input/local output) DOUBLE PRECISION pointer into the
97* local memory to an array of dimension (LLD_A,LOCc(JA+N-1)).
98* On entry, this array contains the local pieces of the
99* triangular matrix sub( A ). If UPLO = 'U', the leading
100* N-by-N upper triangular part of the matrix sub( A ) contains
101* the upper triangular matrix to be inverted, and the strictly
102* lower triangular part of sub( A ) is not referenced.
103* If UPLO = 'L', the leading N-by-N lower triangular part of
104* the matrix sub( A ) contains the lower triangular matrix,
105* and the strictly upper triangular part of sub( A ) is not
106* referenced.
107* On exit, the (triangular) inverse of the original matrix.
108*
109* IA (global input) INTEGER
110* The row index in the global array A indicating the first
111* row of sub( A ).
112*
113* JA (global input) INTEGER
114* The column index in the global array A indicating the
115* first column of sub( A ).
116*
117* DESCA (global and local input) INTEGER array of dimension DLEN_.
118* The array descriptor for the distributed matrix A.
119*
120* INFO (global output) INTEGER
121* = 0: successful exit
122* < 0: If the i-th argument is an array and the j-entry had
123* an illegal value, then INFO = -(i*100+j), if the i-th
124* argument is a scalar and had an illegal value, then
125* INFO = -i.
126* > 0: If INFO = K, A(IA+K-1,JA+K-1) is exactly zero. The
127* triangular matrix sub( A ) is singular and its
128* inverse can not be computed.
129*
130* ====================================================================
131*
132* .. Parameters ..
133 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
134 $ LLD_, MB_, M_, NB_, N_, RSRC_
135 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
136 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
137 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
138 DOUBLE PRECISION ZERO, ONE
139 parameter( zero = 0.0d+0, one = 1.0d+0 )
140* ..
141* .. Local Scalars ..
142 LOGICAL NOUNIT, UPPER
143 INTEGER I, ICOFF, ICTXT, IROFF, ICURCOL, ICURROW,
144 $ IDUMMY, II, IOFFA, J, JB, JJ, JN, LDA, MYCOL,
145 $ MYROW, NN, NPCOL, NPROW
146* ..
147* .. Local Arrays ..
148 INTEGER IDUM1( 2 ), IDUM2( 2 )
149* ..
150* .. External Subroutines ..
151 EXTERNAL blacs_gridinfo, chk1mat, igamx2d, infog2l,
152 $ pchk1mat, pdtrti2, pdtrmm, pdtrsm,
153 $ pxerbla
154* ..
155* .. External Functions ..
156 LOGICAL LSAME
157 INTEGER ICEIL
158 EXTERNAL iceil, lsame
159* ..
160* .. Intrinsic Functions ..
161 INTRINSIC ichar, min, mod
162* ..
163* .. Executable Statements ..
164*
165* Get grid parameters
166*
167 ictxt = desca( ctxt_ )
168 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
169*
170* Test input parameters
171*
172 info = 0
173 IF( nprow.EQ.-1 ) THEN
174 info = -(700+ctxt_)
175 ELSE
176 upper = lsame( uplo, 'U' )
177 nounit = lsame( diag, 'N' )
178*
179 CALL chk1mat( n, 3, n, 3, ia, ja, desca, 7, info )
180 IF( info.EQ.0 ) THEN
181 iroff = mod( ia-1, desca( mb_ ) )
182 icoff = mod( ja-1, desca( nb_ ) )
183 IF( .NOT.upper .AND. .NOT.lsame( uplo, 'L' ) ) THEN
184 info = -1
185 ELSE IF( .NOT.nounit .AND. .NOT.lsame( diag, 'U' ) ) THEN
186 info = -2
187 ELSE IF( iroff.NE.icoff .OR. iroff.NE.0 ) THEN
188 info = -6
189 ELSE IF( desca( mb_ ).NE.desca( nb_ ) ) THEN
190 info = -(700+nb_)
191 END IF
192 END IF
193*
194 IF( upper ) THEN
195 idum1( 1 ) = ichar( 'U' )
196 ELSE
197 idum1( 1 ) = ichar( 'L' )
198 END IF
199 idum2( 1 ) = 1
200 IF( nounit ) THEN
201 idum1( 2 ) = ichar( 'N' )
202 ELSE
203 idum1( 2 ) = ichar( 'U' )
204 END IF
205 idum2( 2 ) = 2
206*
207 CALL pchk1mat( n, 3, n, 3, ia, ja, desca, 7, 2, idum1, idum2,
208 $ info )
209 END IF
210*
211 IF( info.NE.0 ) THEN
212 CALL pxerbla( ictxt, 'PDTRTRI', -info )
213 RETURN
214 END IF
215*
216* Quick return if possible
217*
218 IF( n.EQ.0 )
219 $ RETURN
220*
221* Check for singularity if non-unit.
222*
223 jn = min( iceil( ja, desca( nb_ ) ) * desca( nb_ ), ja+n-1 )
224 IF( nounit ) THEN
225 CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol,
226 $ ii, jj, icurrow, icurcol )
227*
228* Handle first block separately
229*
230 jb = jn-ja+1
231 lda = desca( lld_ )
232 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol ) THEN
233 ioffa = ii+(jj-1)*lda
234 DO 10 i = 0, jb-1
235 IF( a( ioffa ).EQ.zero .AND. info.EQ.0 )
236 $ info = i + 1
237 ioffa = ioffa + lda + 1
238 10 CONTINUE
239 END IF
240 IF( myrow.EQ.icurrow )
241 $ ii = ii + jb
242 IF( mycol.EQ.icurcol )
243 $ jj = jj + jb
244 icurrow = mod( icurrow+1, nprow )
245 icurcol = mod( icurcol+1, npcol )
246*
247* Loop over remaining blocks of columns
248*
249 DO 30 j = jn+1, ja+n-1, desca( nb_ )
250 jb = min( ja+n-j, desca( nb_ ) )
251 IF( myrow.EQ.icurrow .AND. mycol.EQ.icurcol ) THEN
252 ioffa = ii+(jj-1)*lda
253 DO 20 i = 0, jb-1
254 IF( a( ioffa ).EQ.zero .AND. info.EQ.0 )
255 $ info = j + i - ja + 1
256 ioffa = ioffa + lda + 1
257 20 CONTINUE
258 END IF
259 IF( myrow.EQ.icurrow )
260 $ ii = ii + jb
261 IF( mycol.EQ.icurcol )
262 $ jj = jj + jb
263 icurrow = mod( icurrow+1, nprow )
264 icurcol = mod( icurcol+1, npcol )
265 30 CONTINUE
266 CALL igamx2d( ictxt, 'All', ' ', 1, 1, info, 1, idummy,
267 $ idummy, -1, -1, mycol )
268 IF( info.NE.0 )
269 $ RETURN
270 END IF
271*
272* Use blocked code
273*
274 IF( upper ) THEN
275*
276* Compute inverse of upper triangular matrix
277*
278 jb = jn-ja+1
279*
280* Handle first block of column separately
281*
282 CALL pdtrti2( uplo, diag, jb, a, ia, ja, desca, info )
283*
284* Loop over remaining block of columns
285*
286 DO 40 j = jn+1, ja+n-1, desca( nb_ )
287 jb = min( desca( nb_ ), ja+n-j )
288 i = ia + j - ja
289*
290* Compute rows 1:j-1 of current block column
291*
292 CALL pdtrmm( 'Left', uplo, 'No transpose', diag, j-ja, jb,
293 $ one, a, ia, ja, desca, a, ia, j, desca )
294 CALL pdtrsm( 'Right', uplo, 'No transpose', diag, j-ja,
295 $ jb, -one, a, i, j, desca, a, ia, j, desca )
296*
297* Compute inverse of current diagonal block
298*
299 CALL pdtrti2( uplo, diag, jb, a, i, j, desca, info )
300*
301 40 CONTINUE
302*
303 ELSE
304*
305* Compute inverse of lower triangular matrix
306*
307 nn = ( ( ja+n-2 ) / desca( nb_ ) )*desca( nb_ ) + 1
308 DO 50 j = nn, jn+1, -desca( nb_ )
309 jb = min( desca( nb_ ), ja+n-j )
310 i = ia + j - ja
311 IF( j+jb.LE.ja+n-1 ) THEN
312*
313* Compute rows j+jb:ja+n-1 of current block column
314*
315 CALL pdtrmm( 'Left', uplo, 'No transpose', diag,
316 $ ja+n-j-jb, jb, one, a, i+jb, j+jb, desca,
317 $ a, i+jb, j, desca )
318 CALL pdtrsm( 'Right', uplo, 'No transpose', diag,
319 $ ja+n-j-jb, jb, -one, a, i, j, desca,
320 $ a, i+jb, j, desca )
321 END IF
322*
323* Compute inverse of current diagonal block
324*
325 CALL pdtrti2( uplo, diag, jb, a, i, j, desca, info )
326*
327 50 CONTINUE
328*
329* Handle the last block of columns separately
330*
331 jb = jn-ja+1
332 IF( ja+jb.LE.ja+n-1 ) THEN
333*
334* Compute rows ja+jb:ja+n-1 of current block column
335*
336 CALL pdtrmm( 'Left', uplo, 'No transpose', diag, n-jb, jb,
337 $ one, a, ia+jb, ja+jb, desca, a, ia+jb, ja,
338 $ desca )
339 CALL pdtrsm( 'Right', uplo, 'No transpose', diag, n-jb, jb,
340 $ -one, a, ia, ja, desca, a, ia+jb, ja, desca )
341 END IF
342*
343* Compute inverse of current diagonal block
344*
345 CALL pdtrti2( uplo, diag, jb, a, ia, ja, desca, info )
346*
347 END IF
348*
349 RETURN
350*
351* End PDTRTRI
352*
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
Definition chk1mat.f:3
integer function iceil(inum, idenom)
Definition iceil.f:2
subroutine infog2l(grindx, gcindx, desc, nprow, npcol, myrow, mycol, lrindx, lcindx, rsrc, csrc)
Definition infog2l.f:3
#define min(A, B)
Definition pcgemr.c:181
subroutine pchk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, nextra, ex, expos, info)
Definition pchkxmat.f:3
subroutine pdtrti2(uplo, diag, n, a, ia, ja, desca, info)
Definition pdtrti2.f:2
subroutine pxerbla(ictxt, srname, info)
Definition pxerbla.f:2
logical function lsame(ca, cb)
Definition tools.f:1724
Here is the call graph for this function:
Here is the caller graph for this function: