ScaLAPACK 2.1  2.1
ScaLAPACK: Scalable Linear Algebra PACKage
pzpblaschk.f
Go to the documentation of this file.
1  SUBROUTINE pzpblaschk( SYMM, UPLO, N, BWL, BWU, NRHS, X, IX, JX,
2  $ DESCX, IASEED, A, IA, JA, DESCA, IBSEED,
3  $ ANORM, RESID, WORK, WORKSIZ )
4 *
5 *
6 * -- ScaLAPACK routine (version 1.7) --
7 * University of Tennessee, Knoxville, Oak Ridge National Laboratory,
8 * and University of California, Berkeley.
9 * November 15, 1997
10 *
11 * .. Scalar Arguments ..
12  CHARACTER SYMM, UPLO
13  INTEGER BWL, BWU, IA, IASEED, IBSEED,
14  $ ix, ja, jx, n, nrhs, worksiz
15  DOUBLE PRECISION ANORM, RESID
16 * ..
17 * .. Array Arguments ..
18  INTEGER DESCA( * ), DESCX( * )
19  COMPLEX*16 A( * ), WORK( * ), X( * )
20 * .. External Functions ..
21  LOGICAL LSAME
22 * ..
23 *
24 * Purpose
25 * =======
26 *
27 * PZPBLASCHK computes the residual
28 * || sub( A )*sub( X ) - B || / (|| sub( A ) ||*|| sub( X ) ||*eps*N)
29 * to check the accuracy of the factorization and solve steps in the
30 * LU and Cholesky decompositions, where sub( A ) denotes
31 * A(IA:IA+N-1,JA,JA+N-1), sub( X ) denotes X(IX:IX+N-1, JX:JX+NRHS-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 * SYMM (global input) CHARACTER
91 * if SYMM = 'H', sub( A ) is a hermitian distributed band
92 * matrix, otherwise sub( A ) is a general distributed matrix.
93 *
94 * UPLO (global input) CHARACTER
95 * if SYMM = 'H', then
96 * if UPLO = 'L', the lower half of the matrix is stored
97 * if UPLO = 'U', the upper half of the matrix is stored
98 * if SYMM != 'S' or 'H', then
99 * if UPLO = 'D', the matrix is stable during factorization
100 * without interchanges
101 * if UPLO != 'D', the matrix is general
102 *
103 * N (global input) INTEGER
104 * The number of columns to be operated on, i.e. the number of
105 * columns of the distributed submatrix sub( A ). N >= 0.
106 *
107 * NRHS (global input) INTEGER
108 * The number of right-hand-sides, i.e the number of columns
109 * of the distributed matrix sub( X ). NRHS >= 1.
110 *
111 * X (local input) COMPLEX*16 pointer into the local memory
112 * to an array of dimension (LLD_X,LOCq(JX+NRHS-1). This array
113 * contains the local pieces of the answer vector(s) sub( X ) of
114 * sub( A ) sub( X ) - B, split up over a column of processes.
115 *
116 * IX (global input) INTEGER
117 * The row index in the global array X indicating the first
118 * row of sub( X ).
119 *
120 * DESCX (global and local input) INTEGER array of dimension DLEN_.
121 * The array descriptor for the distributed matrix X.
122 *
123 * IASEED (global input) INTEGER
124 * The seed number to generate the original matrix Ao.
125 *
126 * JA (global input) INTEGER
127 * The column index in the global array A indicating the
128 * first column of sub( A ).
129 *
130 * DESCA (global and local input) INTEGER array of dimension DLEN_.
131 * The array descriptor for the distributed matrix A.
132 *
133 * IBSEED (global input) INTEGER
134 * The seed number to generate the original matrix B.
135 *
136 * ANORM (global input) DOUBLE PRECISION
137 * The 1-norm or infinity norm of the distributed matrix
138 * sub( A ).
139 *
140 * RESID (global output) DOUBLE PRECISION
141 * The residual error:
142 * ||sub( A )*sub( X )-B|| / (||sub( A )||*||sub( X )||*eps*N).
143 *
144 * WORK (local workspace) COMPLEX*16 array, dimension (LWORK)
145 * IF SYMM='S'
146 * LWORK >= max(5,max(bw*(bw+2),NB))+2*NB
147 * IF SYMM!='S' or 'H'
148 * LWORK >= max(5,max(bw*(bw+2),NB))+2*NB
149 *
150 * WORKSIZ (local input) size of WORK.
151 *
152 * =====================================================================
153 *
154 * Code Developer: Andrew J. Cleary, University of Tennessee.
155 * Current address: Lawrence Livermore National Labs.
156 * This version released: August, 2001.
157 *
158 * =====================================================================
159 *
160 * .. Parameters ..
161  COMPLEX*16 ZERO, ONE
162  PARAMETER ( ONE = ( 1.0d+0, 0.0d+0 ),
163  $ zero = ( 0.0d+0, 0.0d+0 ) )
164  INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
165  $ LLD_, MB_, M_, NB_, N_, RSRC_
166  parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
167  $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
168  $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
169  INTEGER INT_ONE
170  PARAMETER ( INT_ONE = 1 )
171 * ..
172 * .. Local Scalars ..
173  INTEGER IACOL, IAROW, ICTXT,
174  $ IIA, IIX, IPB, IPW,
175  $ ixcol, ixrow, j, jja, jjx, lda,
176  $ mycol, myrow, nb, np, npcol, nprow, nq
177  INTEGER BW, INFO, IPPRODUCT, WORK_MIN
178  DOUBLE PRECISION DIVISOR, EPS, RESID1, NORMX
179 * ..
180 * .. Local Arrays ..
181 * ..
182 * .. External Subroutines ..
183  EXTERNAL blacs_gridinfo, dgebr2d, dgebs2d,
184  $ dgerv2d, dgesd2d, pbztran,
185  $ pzmatgen, zgamx2d, zgemm, zgsum2d,
186  $ zlaset
187 * ..
188 * .. External Functions ..
189  INTEGER IZAMAX, NUMROC
190  DOUBLE PRECISION PDLAMCH
191  EXTERNAL izamax, numroc, pdlamch
192 * ..
193 * .. Intrinsic Functions ..
194  INTRINSIC abs, dble, max, min, mod
195 * ..
196 * .. Executable Statements ..
197 *
198 * Get needed initial parameters
199 *
200  ictxt = desca( ctxt_ )
201  nb = desca( nb_ )
202 *
203  IF( lsame( symm, 'H' ) ) THEN
204  bw = bwl
205  work_min = max(5,max(bw*(bw+2),nb))+2*nb
206  ELSE
207  bw = max(bwl, bwu)
208  work_min = max(5,max(bw*(bw+2),nb))+2*nb
209  ENDIF
210 *
211  IF ( worksiz .LT. work_min ) THEN
212  CALL pxerbla( ictxt, 'PZBLASCHK', -18 )
213  RETURN
214  END IF
215 *
216  CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
217 *
218  eps = pdlamch( ictxt, 'eps' )
219  resid = 0.0d+0
220  divisor = anorm * eps * dble( n )
221 *
222  CALL infog2l( ia, ja, desca, nprow, npcol, myrow, mycol, iia, jja,
223  $ iarow, iacol )
224  CALL infog2l( ix, jx, descx, nprow, npcol, myrow, mycol, iix, jjx,
225  $ ixrow, ixcol )
226  np = numroc( (bw+1), desca( mb_ ), myrow, 0, nprow )
227  nq = numroc( n, desca( nb_ ), mycol, 0, npcol )
228 *
229  ipb = 1
230  ipproduct = 1 + desca( nb_ )
231  ipw = 1 + 2*desca( nb_ )
232 *
233  lda = desca( lld_ )
234 *
235 * Regenerate A
236 *
237  IF( lsame( symm, 'H' )) THEN
238  CALL pzbmatgen( ictxt, uplo, 'D', bw, bw, n, bw+1,
239  $ desca( nb_ ), a, desca( lld_ ), 0, 0,
240  $ iaseed, myrow, mycol, nprow, npcol )
241  ELSE
242 *
243  CALL pzbmatgen( ictxt, 'N', uplo, bwl, bwu, n,
244  $ desca( mb_ ), desca( nb_ ), a,
245  $ desca( lld_ ), 0, 0, iaseed, myrow,
246  $ mycol, nprow, npcol )
247  ENDIF
248 *
249 * Loop over the rhs
250 *
251  resid = 0.0
252 *
253  DO 40 j = 1, nrhs
254 *
255 * Multiply A * current column of X
256 *
257 *
258  CALL pzpbdcmv( bw+1, bw, uplo, n, a, 1, desca,
259  $ 1, x( 1 + (j-1)*descx( lld_ )), 1, descx,
260  $ work( ipproduct ), work( ipw ), (bw+2)*bw, info )
261 *
262 *
263 * Regenerate column of B
264 *
265  CALL pzmatgen( descx( ctxt_ ), 'No', 'No', descx( m_ ),
266  $ descx( n_ ), descx( mb_ ), descx( nb_ ),
267  $ work( ipb ), descx( lld_ ), descx( rsrc_ ),
268  $ descx( csrc_ ), ibseed, 0, nq, j-1, 1, mycol,
269  $ myrow, npcol, nprow )
270 *
271 * Figure || A * X - B || & || X ||
272 *
273  CALL pzaxpy( n, -one, work( ipproduct ), 1, 1, descx, 1,
274  $ work( ipb ), 1, 1, descx, 1 )
275 *
276  CALL pdznrm2( n, normx,
277  $ x, 1, j, descx, 1 )
278 *
279  CALL pdznrm2( n, resid1,
280  $ work( ipb ), 1, 1, descx, 1 )
281 *
282 *
283 * Calculate residual = ||Ax-b|| / (||x||*||A||*eps*N)
284 *
285  resid1 = resid1 / ( normx*divisor )
286 *
287  resid = max( resid, resid1 )
288 *
289  40 CONTINUE
290 *
291  RETURN
292 *
293 * End of PZBLASCHK
294 *
295  END
pzpbdcmv
subroutine pzpbdcmv(LDBW, BW, UPLO, N, A, JA, DESCA, NRHS, B, IB, DESCB, X, WORK, LWORK, INFO)
Definition: pzpbmv1.f:3
pbztran
subroutine pbztran(ICONTXT, ADIST, TRANS, M, N, NB, A, LDA, BETA, C, LDC, IAROW, IACOL, ICROW, ICCOL, WORK)
Definition: pbztran.f:3
max
#define max(A, B)
Definition: pcgemr.c:180
infog2l
subroutine infog2l(GRINDX, GCINDX, DESC, NPROW, NPCOL, MYROW, MYCOL, LRINDX, LCINDX, RSRC, CSRC)
Definition: infog2l.f:3
pzbmatgen
subroutine pzbmatgen(ICTXT, AFORM, AFORM2, BWL, BWU, N, MB, NB, A, LDA, IAROW, IACOL, ISEED, MYROW, MYCOL, NPROW, NPCOL)
Definition: pzbmatgen.f:5
pzmatgen
subroutine pzmatgen(ICTXT, AFORM, DIAG, M, N, MB, NB, A, LDA, IAROW, IACOL, ISEED, IROFF, IRNUM, ICOFF, ICNUM, MYROW, MYCOL, NPROW, NPCOL)
Definition: pzmatgen.f:4
pzpblaschk
subroutine pzpblaschk(SYMM, UPLO, N, BWL, BWU, NRHS, X, IX, JX, DESCX, IASEED, A, IA, JA, DESCA, IBSEED, ANORM, RESID, WORK, WORKSIZ)
Definition: pzpblaschk.f:4
pxerbla
subroutine pxerbla(ICTXT, SRNAME, INFO)
Definition: pxerbla.f:2
min
#define min(A, B)
Definition: pcgemr.c:181