5
6
7
8
9
10
11
12 CHARACTER TRANS
13 INTEGER IA, IB, IRESID, IX, JA, JB, JX, M, N, NRHS
14
15
16 INTEGER DESCA( * ), DESCB( * ), DESCX( * )
17 COMPLEX*16 A( * ), B( * ), WORK( * ), X( * )
18 DOUBLE PRECISION RWORK( * )
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201 INTEGER BLOCK_CYCLIC_2D, CSRC_, CTXT_, DLEN_, DTYPE_,
202 $ LLD_, MB_, M_, NB_, N_, RSRC_
203 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
204 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
205 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
206 DOUBLE PRECISION ZERO, ONE
207 parameter( zero = 0.0d0, one = 1.0d0 )
208
209
210 INTEGER IACOL, IBCOL, IBROW, ICOFFB, ICTXT, INFO,
211 $ IOFFA, IROFFB, ISCL, IW, IW2, JW, JW2, MYCOL,
212 $ NRHSQ, NRHSP, MYROW, NCOLS, NPCOL, NPROW,
213 $ NROWS, NROWSP
214 DOUBLE PRECISION ERR, NORMA, NORMB, NORMRS, NORMX, SMLNUM
215
216
217 INTEGER DESCW( DLEN_ ), DESCW2( DLEN_ )
218
219
220 LOGICAL LSAME
221 INTEGER INDXG2P, NUMROC
222 DOUBLE PRECISION PDLAMCH, PZLANGE
224
225
228
229
230 INTRINSIC dble, dcmplx,
max
231
232
233
235
236
237
238 ictxt = desca( ctxt_ )
239 CALL blacs_gridinfo( ictxt, nprow, npcol, myrow, mycol )
240
241 info = 0
242 IF(
lsame( trans,
'N' ) )
THEN
243 nrows = m
244 ncols = n
245 ioffa = mod( ja-1, desca( nb_ ) )
246 ELSE IF(
lsame( trans,
'C' ) )
THEN
247 nrows = n
248 ncols = m
249 ioffa = mod( ia-1, desca( mb_ ) )
250 ELSE
251 CALL pxerbla( ictxt,
'PZQRT17', -1 )
252 RETURN
253 END IF
254
255 IF( m.LE.0 .OR. n.LE.0 .OR. nrhs.LE.0 )
256 $ RETURN
257
258 iroffb = mod( ia-1, desca( mb_ ) )
259 icoffb = mod( ja-1, desca( nb_ ) )
260 ibrow =
indxg2p( ib, descb( mb_ ), myrow, descb( rsrc_ ),
261 $ nprow )
262 iacol =
indxg2p( ja, desca( nb_ ), mycol, desca( csrc_ ),
263 $ npcol )
264 ibcol =
indxg2p( jb, descb( nb_ ), mycol, descb( csrc_ ),
265 $ npcol )
266
267 nrhsq =
numroc( nrhs+icoffb, descb( nb_ ), mycol, ibcol, npcol )
268 nrhsp =
numroc( nrhs+iroffb, descb( nb_ ), myrow, ibrow, nprow )
269 nrowsp =
numroc( nrows+iroffb, desca( mb_ ), myrow, ibrow, nprow )
270
271
272
273
274 CALL descset( descw, nrows+iroffb, nrhs+icoffb, descb( mb_ ),
275 $ descb( nb_ ), ibrow, ibcol, ictxt,
max( 1,
276 $ nrowsp ) )
277
278
279
280
281 CALL descset( descw2, nrhs+icoffb, ncols+ioffa, descx( nb_ ),
282 $ descx( mb_ ), ibrow, iacol, ictxt,
max( 1,
283 $ nrhsp ) )
284
285 norma =
pzlange(
'One-norm', m, n, a, ia, ja, desca, rwork )
286 smlnum =
pdlamch( ictxt,
'Safe minimum' )
287 smlnum = smlnum /
pdlamch( ictxt,
'Precision' )
288 iscl = 0
289
290
291
292 iw = 1 + iroffb
293 jw = 1 + icoffb
294 CALL pzlacpy(
'All', nrows, nrhs, b, ib, jb, descb, work, iw, jw,
295 $ descw )
296 CALL pzgemm( trans, 'No transpose', nrows, nrhs, ncols,
297 $ dcmplx( -one ), a, ia, ja, desca, x, ix, jx, descx,
298 $ dcmplx( one ), work, iw, jw, descw )
299 normrs =
pzlange(
'Max', nrows, nrhs, work, iw, jw, descw,
300 $ rwork )
301 IF( normrs.GT.smlnum ) THEN
302 iscl = 1
303 CALL pzlascl(
'General', normrs, one, nrows, nrhs, work,
304 $ iw, jw, descw, info )
305 END IF
306
307
308
309 iw2 = 1 + icoffb
310 jw2 = 1 + ioffa
311 CALL pzgemm( 'Conjugate transpose', trans, nrhs, ncols, nrows,
312 $ dcmplx( one ), work, iw, jw, descw, a, ia, ja, desca,
313 $ dcmplx( zero ), work( nrowsp*nrhsq+1 ), iw2, jw2,
314 $ descw2 )
315
316
317
318 err =
pzlange(
'One-norm', nrhs, ncols, work( nrowsp*nrhsq+1 ),
319 $ iw2, jw2, descw2, rwork )
320 IF( norma.NE.zero )
321 $ err = err / norma
322
323 IF( iscl.EQ.1 )
324 $ err = err*normrs
325
326 IF( iresid.EQ.1 ) THEN
327 normb =
pzlange(
'One-norm', nrows, nrhs, b, ib, jb, descb,
328 $ rwork )
329 IF( normb.NE.zero )
330 $ err = err / normb
331 ELSE
332 normx =
pzlange(
'One-norm', ncols, nrhs, x, ix, jx, descx,
333 $ rwork )
334 IF( normx.NE.zero )
335 $ err = err / normx
336 END IF
337
339 $ dble(
max( m, n, nrhs ) ) )
340
341 RETURN
342
343
344
subroutine descset(desc, m, n, mb, nb, irsrc, icsrc, ictxt, lld)
integer function indxg2p(indxglob, nb, iproc, isrcproc, nprocs)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
double precision function pdlamch(ictxt, cmach)
subroutine pxerbla(ictxt, srname, info)
subroutine pzlacpy(uplo, m, n, a, ia, ja, desca, b, ib, jb, descb)
double precision function pzlange(norm, m, n, a, ia, ja, desca, work)
subroutine pzlascl(type, cfrom, cto, m, n, a, ia, ja, desca, info)
double precision function pzqrt17(trans, iresid, m, n, nrhs, a, ia, ja, desca, x, ix, jx, descx, b, ib, jb, descb, work, rwork)