4
5
6
7
8
9
10
11 INTEGER IU, IVT, JOBTYPE, JU, JVT, LWORK, M, N
12 DOUBLE PRECISION DELTA, THRESH
13
14
15 INTEGER DESCU( * ), DESCVT( * ), RESULT( * )
16 DOUBLE PRECISION S( * ), SC( * ), U( * ), UC( * ), VT( * ),
17 $ VTC( * ), WORK( * )
18
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 INTEGER BLOCK_CYCLIC_2D, DLEN_, DTYPE_, CTXT_, M_, N_,
177 $ MB_, NB_, RSRC_, CSRC_, LLD_
178 parameter( block_cyclic_2d = 1, dlen_ = 9, dtype_ = 1,
179 $ ctxt_ = 2, m_ = 3, n_ = 4, mb_ = 5, nb_ = 6,
180 $ rsrc_ = 7, csrc_ = 8, lld_ = 9 )
181
182
183 INTEGER COLPTR, I, INFO, J, LWMIN, MYCOL, MYROW, NPCOL,
184 $ NPROW, NQ, RESULTS, SIZE, SIZEPOS, SIZEQ
185 DOUBLE PRECISION ACCUR, CMP, NORMDIFS, NORMDIFU, NORMDIFV,
186 $ NORMS, ULP
187
188
189 INTEGER NUMROC
190 DOUBLE PRECISION DLANGE, PDLAMCH, PDLANGE
192
193
195
196
198
199
200
201 IF( block_cyclic_2d*csrc_*dlen_*dtype_*mb_*m_*n_*rsrc_.LT.0 )
202 $ RETURN
203
204 results = 0
205 normdifs = 0
206 normdifu = 0
207 normdifv = 0
209
210
211
212
213 sizepos = 17
214 info = 0
215 CALL blacs_gridinfo( descu( ctxt_ ), nprow, npcol, myrow, mycol )
216 IF( nprow.EQ.-1 ) THEN
217 info = -607
218 ELSE
219 CALL chk1mat( m, 1,
SIZE, sizepos, 1, 1, descu, 8, info )
220 CALL chk1mat(
SIZE, sizepos, n, 2, 1, 1, descvt, 11, info )
221 END IF
222
223 IF( info.EQ.0 ) THEN
224
225
226
227 sizeq =
numroc(
SIZE, descu( nb_ ), mycol, 0, npcol )
228 nq =
numroc( n, descvt( nb_ ), mycol, 0, npcol )
229 lwmin =
max( sizeq, nq ) + 4
230 work( 1 ) = lwmin
231 IF( lwork.EQ.-1 )
232 $ GO TO 60
233 IF( lwork.LT.lwmin ) THEN
234 info = -16
235 ELSE IF( thresh.LE.0 ) THEN
236 info = -12
237 END IF
238 END IF
239
240 IF( info.NE.0 ) THEN
241 CALL pxerbla( descu( ctxt_ ),
'PDSVDCMP', -info )
242 RETURN
243 END IF
244
245 ulp =
pdlamch( descu( ctxt_ ),
'P' )
246
247
248
249 norms = dlange( '1', SIZE, 1, s, SIZE, work )
250 DO 10 i = 1, SIZE
251 sc( i ) = s( i ) - sc( i )
252 10 CONTINUE
253
254 normdifs = dlange( '1', SIZE, 1, sc, SIZE, work )
255 accur = ulp*size*norms*thresh
256
257 IF( normdifs.GT.accur )
258 $ results = 1
259 IF( normdifs.EQ.0 .AND. accur.EQ.0 ) THEN
260 normdifs = 0
261 ELSE
262 normdifs = normdifs / accur
263 END IF
264
265 IF( jobtype.EQ.2 ) THEN
266
267 result( 5 ) = results
268 accur = ulp*m*thresh
269 DO 30 j = 1, sizeq
270 colptr = descu( lld_ )*( j-1 )
271 DO 20 i = 1, descu( lld_ )
272 uc( i+colptr ) = u( i+colptr ) - uc( i+colptr )
273 20 CONTINUE
274 30 CONTINUE
275
276 normdifu =
pdlange(
'1', m,
SIZE, uc, iu, ju, descu, work )
277
278 IF( normdifu.GE.accur )
279 $ result( 6 ) = 1
280 IF( normdifu.EQ.0 .AND. accur.EQ.0 ) THEN
281 normdifu = 0
282 ELSE
283 normdifu = normdifu / accur
284 END IF
285
286 ELSE IF( jobtype.EQ.3 ) THEN
287
288 result( 7 ) = results
289 accur = ulp*n*thresh
290 DO 50 j = 1, nq
291 colptr = descvt( lld_ )*( j-1 )
292 DO 40 i = 1, descvt( lld_ )
293 vtc( i+colptr ) = vt( i+colptr ) - vtc( i+colptr )
294 40 CONTINUE
295 50 CONTINUE
296
297 normdifv =
pdlange(
'1',
SIZE, n, vtc, ivt, jvt, descvt, work )
298
299 IF( normdifv.GE.accur )
300 $ result( 8 ) = 1
301
302 IF( normdifv.EQ.0 .AND. accur.EQ.0 ) THEN
303 normdifv = 0
304 ELSE
305 normdifv = normdifv / accur
306 END IF
307
308 ELSE IF( jobtype.EQ.4 ) THEN
309
310 result( 9 ) = results
311
312 END IF
313
314 cmp =
max( normdifv, normdifu )
315 delta =
max( cmp, normdifs )
316
317 60 CONTINUE
318
319
320
321 RETURN
subroutine chk1mat(ma, mapos0, na, napos0, ia, ja, desca, descapos0, info)
integer function numroc(n, nb, iproc, isrcproc, nprocs)
double precision function pdlamch(ictxt, cmach)
double precision function pdlange(norm, m, n, a, ia, ja, desca, work)
subroutine pxerbla(ictxt, srname, info)