6
7
8
9
10
11
12
13 INTEGER IC, INFO, IQ, JC, JQ, LWORK, MS, NV, RES
14 DOUBLE PRECISION QTQNRM, THRESH
15
16
17
18 INTEGER DESCC( * ), DESCQ( * ), ICLUSTR( * ),
19 $ PROCDIST( * )
20 DOUBLE PRECISION C( * ), GAP( * ), Q( * ), WORK( * )
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 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
175 $ MB_, NB_, RSRC_, CSRC_, LLD_
176 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
177 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
178 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
179 DOUBLE PRECISION ZERO, ONE, NEGONE
180 parameter( zero = 0.0d+0, one = 1.0d+0,
181 $ negone = -1.0d+0 )
182
183
184
186
187
188 INTEGER CLUSTER, FIRSTP, IMAX, IMIN, JMAX, JMIN, LWMIN,
189 $ MQ0, MYCOL, MYROW, NEXTP, NP0, NPCOL, NPROW
190 DOUBLE PRECISION NORM, QTQNRM2, ULP
191
192
193 INTEGER NUMROC
194 DOUBLE PRECISION PDLAMCH, PDLANGE
196
197
200
201
202
203 IF( block_cyclic_2d*csrc_*ctxt_*dlen_*dtype_*lld_*mb_*m_*nb_*n_*
204 $ rsrc_.LT.0 )RETURN
205
206
207 res = 0
208 ulp =
pdlamch( descc( ctxt_ ),
'P' )
209
210 CALL blacs_gridinfo( descc( ctxt_ ), nprow, npcol, myrow, mycol )
211 info = 0
212 CALL chk1mat( ms, 1, ms, 2, iq, jq, descq, 7, info )
213 CALL chk1mat( nv, 1, ms, 2, ic, jc, descc, 11, info )
214
215 IF( info.EQ.0 ) THEN
216 np0 =
numroc( nv, descc( mb_ ), 0, 0, nprow )
217 mq0 =
numroc( nv, descc( nb_ ), 0, 0, npcol )
218
219 lwmin = 2 +
max( descc( mb_ ), 2 )*( 2*np0+mq0 )
220
221 IF( iq.NE.1 ) THEN
222 info = -5
223 ELSE IF( jq.NE.1 ) THEN
224 info = -6
225 ELSE IF( ic.NE.1 ) THEN
226 info = -9
227 ELSE IF( jc.NE.1 ) THEN
228 info = -10
229 ELSE IF( lwork.LT.lwmin ) THEN
230 info = -16
231 END IF
232 END IF
233
234 IF( info.NE.0 ) THEN
235 CALL pxerbla( descc( ctxt_ ),
'PDSEPQTQ', -info )
236 RETURN
237 END IF
238
239
240
241 CALL pdlaset(
'A', nv, nv, zero, one, c, ic, jc, descc )
242
243
244
245 IF( nv*ms.GT.0 ) THEN
246 CALL pdgemm( 'Transpose', 'N', nv, nv, ms, negone, q, 1, 1,
247 $ descq, q, 1, 1, descq, one, c, 1, 1, descc )
248 END IF
249
250
251
252 norm =
pdlange(
'1', nv, nv, c, 1, 1, descc, work )
253 qtqnrm = norm / ( dble(
max( ms, 1 ) )*ulp )
254
255 cluster = 1
256 10 CONTINUE
257 DO 20 firstp = 1, nprow*npcol
258 IF( procdist( firstp ).GE.iclustr( 2*( cluster-1 )+1 ) )
259 $ GO TO 30
260 20 CONTINUE
261 30 CONTINUE
262
263 imin = iclustr( 2*cluster-1 )
264 jmax = iclustr( 2*cluster )
265
266
267 IF( imin.EQ.0 )
268 $ GO TO 60
269
270 DO 40 nextp = firstp, nprow*npcol
271 imax = procdist( nextp )
272 jmin = imax + 1
273
274
275 CALL pdmatadd( imax-imin+1, jmax-jmin+1, zero, c, imin, jmin,
276 $ descc, gap( cluster ) / 0.01d+0, c, imin, jmin,
277 $ descc )
278 CALL pdmatadd( jmax-jmin+1, imax-imin+1, zero, c, jmin, imin,
279 $ descc, gap( cluster ) / 0.01d+0, c, jmin, imin,
280 $ descc )
281 imin = imax
282
283 IF( iclustr( 2*cluster ).LT.procdist( nextp+1 ) )
284 $ GO TO 50
285 40 CONTINUE
286 50 CONTINUE
287
288 cluster = cluster + 1
289 GO TO 10
290 60 CONTINUE
291
292
293
294 norm =
pdlange(
'1', nv, nv, c, 1, 1, descc, work )
295
296 qtqnrm2 = norm / ( dble(
max( ms, 1 ) )*ulp )
297
298 IF( qtqnrm2.GT.thresh ) THEN
299 res = 1
300 qtqnrm = qtqnrm2
301 END IF
302 RETURN
303
304
305
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
subroutine pdlaset(uplo, m, n, alpha, beta, a, ia, ja, desca)
double precision function pdlamch(ictxt, cmach)
double precision function pdlange(norm, m, n, a, ia, ja, desca, work)
subroutine pdmatadd(m, n, alpha, a, ia, ja, desca, beta, c, ic, jc, descc)
subroutine pxerbla(ictxt, srname, info)