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 Int ictxt, iix, iiy, info, ixcol, ixrow, iycol, iyrow, jjx,
174 jjy, lcm, lcmp, mycol, myrow, nn, np, np0,
175 nprow, npcol, nq, nz, ione=1, tmp1, wksz;
177
178
179
181
182
183
193
194
195
196
197
198 ictxt = desc_X[
CTXT_];
200
201
202
203 info = 0;
204 if( nprow == -1 )
205 info = -(500+
CTXT_+1);
206 else
207 {
208 pbchkvect( *n, 1, *ix, *jx, desc_X, *incx, 5, &iix, &jjx,
209 &ixrow, &ixcol, nprow, npcol, myrow, mycol, &info );
210 pbchkvect( *n, 1, *iy, *jy, desc_Y, *incy, 10, &iiy, &jjy,
211 &iyrow, &iycol, nprow, npcol, myrow, mycol, &info );
212
213 if( info == 0 )
214 {
215 if( *n != 1 )
216 {
217 if( *incx == desc_X[
M_] )
218 {
219 if( *incy == desc_Y[
M_] )
220 {
221 if( ( ixcol != iycol ) ||
222 ( ( (*jx-1) % desc_X[
NB_] ) !=
223 ( (*jy-1) % desc_Y[
NB_] ) ) )
224 info = -9;
225 else if( desc_Y[
NB_] != desc_X[
NB_] )
226 info = -(1000+
NB_+1);
227 }
228 else if( ( *incy == 1 ) && ( *incy != desc_Y[
M_] ) )
229 {
230 if( ( (*jx-1) % desc_X[
NB_] ) != ( (*iy-1) % desc_Y[
MB_] ) )
231 info = -8;
232 else if( desc_Y[
MB_] != desc_X[
NB_] )
233 info = -(1000+
MB_+1);
234 }
235 else
236 {
237 info = -11;
238 }
239 }
240 else if( ( *incx == 1 ) && ( *incx != desc_X[
M_] ) )
241 {
242 if( *incy == desc_Y[
M_] )
243 {
244 if( ( (*ix-1) % desc_X[
MB_] ) != ( (*jy-1) % desc_Y[
NB_] ) )
245 info = -9;
246 else if( desc_Y[
NB_] != desc_X[
MB_] )
247 info = -(1000+
NB_+1);
248 }
249 else if( ( *incy == 1 ) && ( *incy != desc_Y[
M_] ) )
250 {
251 if( ( ixrow != iyrow ) ||
252 ( ( (*ix-1) % desc_X[
MB_] ) !=
253 ( (*iy-1) % desc_Y[
MB_] ) ) )
254 info = -8;
255 else if( desc_Y[
MB_] != desc_X[
MB_] )
256 info = -(1000+
MB_+1);
257 }
258 else
259 {
260 info = -11;
261 }
262 }
263 else
264 {
265 info = -6;
266 }
267 }
268 if( ictxt != desc_Y[
CTXT_] )
269 info = -(1000+
CTXT_+1);
270 }
271 }
272 if( info ) {
PB_Cabort( ictxt,
"PZROT", info );
return; }
273
274
275
276
277
278
279
280
281
282
283
286 if( *n == 0 ) return;
287
288
289
290 if( *n == 1 )
291 {
292 if( ( myrow == ixrow ) && ( mycol == ixcol ) )
293 {
294 buff = &X[iix-1+(jjx-1)*desc_X[
LLD_]];
295 if( ( myrow != iyrow ) || ( mycol != iycol ) )
296 {
297 zgesd2d_( &ictxt, n, n, buff, n, &iyrow, &iycol );
298 zgerv2d_( &ictxt, n, n, ywork, n, &iyrow, &iycol );
299 }
300 else
301 *ywork = Y[iiy-1+(jjy-1)*desc_Y[
LLD_]];
302 zrot_( n, buff, n, ywork, n, c, s );
303 X[iix-1+(jjx-1)*desc_X[
LLD_]] = *buff;
304 if( ( myrow == iyrow ) && ( mycol == iycol ) )
305 Y[iiy-1+(jjy-1)*desc_Y[
LLD_]] = *ywork;
306 }
307 else if( ( myrow == iyrow ) && ( mycol == iycol ) )
308 {
309 zgesd2d_( &ictxt, n, n, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], n,
310 &ixrow, &ixcol );
311 zgerv2d_( &ictxt, n, n, xwork, n, &ixrow, &ixcol );
312 zrot_( n, xwork, n, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], n, c, s );
313 }
314 return;
315 }
316
317 if( ( *incx == desc_X[
M_] ) && ( *incy == desc_Y[
M_] ) )
318 {
319 nz = (*jx-1) % desc_Y[
NB_];
320 nn = *n + nz;
321 nq = numroc_( &nn, &desc_X[
NB_], &mycol, &ixcol, &npcol );
322 if( mycol == ixcol )
323 nq -= nz;
324 if( ixrow == iyrow )
325 {
326 if( myrow == ixrow )
327 {
328 zrot_( &nq, &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
329 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_], c, s );
330 }
331 }
332 else
333 {
334 if( myrow == ixrow )
335 {
337 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
338 &iyrow, &mycol );
340 zgerv2d_( &ictxt, &nq, &ione, buff, &nq, &iyrow, &mycol );
341 zrot_( &nq, &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
342 buff, &ione, c, s );
343 }
344 else if( myrow == iyrow )
345 {
347 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
348 &ixrow, &mycol );
350 zgerv2d_( &ictxt, &nq, &ione, buff, &nq, &ixrow, &mycol );
351 zrot_( &nq, buff, &ione,
352 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_], c, s );
353 }
354 }
355 }
356 else if( ( *incx == 1 ) && ( *incx != desc_X[
M_] ) &&
357 ( *incy == 1 ) && ( *incy != desc_Y[
M_] ) )
358 {
359 nz = (*ix-1) % desc_X[
MB_];
360 nn = *n + nz;
361 np = numroc_( &nn, &desc_X[
MB_], &myrow, &ixrow, &nprow );
362 if( myrow == ixrow )
363 np -= nz;
364 if( ixcol == iycol )
365 {
366 if( mycol == ixcol )
367 {
368 zrot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]], incx,
369 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
370 }
371 }
372 else
373 {
374 if( mycol == ixcol )
375 {
377 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
378 &myrow, &iycol );
380 zgerv2d_( &ictxt, &np, &ione, buff, &np, &myrow, &iycol );
381 zrot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]], incx,
382 buff, &ione, c, s );
383 }
384 else if( mycol == iycol )
385 {
387 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
388 &myrow, &ixcol );
390 zgerv2d_( &ictxt, &np, &ione, buff, &np, &myrow, &ixcol );
391 zrot_( &np, buff, &ione,
392 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
393 }
394 }
395 }
396 else
397 {
398 lcm = ilcm_( &nprow, &npcol );
399 if( ( *incx == 1 ) && ( *incx != desc_X[
M_] ) )
400 {
401 lcmp = lcm / nprow;
402 nz = (*jy-1) % desc_Y[
NB_];
403 nn = *n + nz;
404 tmp1 = nn / desc_Y[
MB_];
405 np = numroc_( &nn, &desc_X[
MB_], &myrow, &ixrow, &nprow );
406 np0 =
MYROC0( tmp1, nn, desc_X[
MB_], nprow );
407 tmp1 = np0 / desc_X[
MB_];
408 wksz =
MYROC0( tmp1, np0, desc_X[
MB_], lcmp );
409 wksz = np + wksz;
410
412
413 if( mycol == iycol )
414 jjy -= nz;
415 if( myrow == ixrow )
416 np -= nz;
418 &desc_Y[
NB_], &nz, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]],
419 &desc_Y[
LLD_], &zero, buff, &ione, &iyrow, &iycol,
420 &ixrow, &ixcol, buff+np );
421 if( mycol == ixcol )
422 {
423 zrot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]],
424 incx, buff, &ione, c, s );
425 }
427 &desc_Y[
NB_], &nz, buff, &ione, &zero,
428 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
429 &ixrow, &ixcol, &iyrow, &iycol, buff+np );
430 }
431 else
432 {
433 lcmp = lcm / nprow;
434 nz = (*jx-1) % desc_X[
NB_];
435 nn = *n + nz;
436 tmp1 = nn / desc_X[
MB_];
437 np = numroc_( &nn, desc_Y+
MB_, &myrow, &iyrow, &nprow );
438 np0 =
MYROC0( tmp1, nn, desc_Y[
MB_], nprow );
439 tmp1 = np0 / desc_Y[
MB_];
440 wksz =
MYROC0( tmp1, np0, desc_Y[
MB_], lcmp );
441 wksz = np + wksz;
442
444
445 if( myrow == iyrow )
446 np -= nz;
448 &desc_X[
NB_], &nz, &X[iix-1+(jjx-1)*desc_X[
LLD_]],
449 &desc_X[
LLD_], &zero, buff, &ione, &ixrow, &ixcol,
450 &iyrow, &iycol, buff+np );
451 if( mycol == iycol )
452 {
453 zrot_( &np, buff, &ione,
454 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
455 }
457 &desc_X[
NB_], &nz, buff, &ione, &zero,
458 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
459 &iyrow, &iycol, &ixrow, &ixcol, buff+np );
460 }
461 }
462}
#define MYROC0(nblocks, n, nb, nprocs)
F_VOID_FUNC blacs_gridinfo_(Int *ConTxt, Int *nprow, Int *npcol, Int *myrow, Int *mycol)
char * getpbbuf(char *mess, Int length)
void pbchkvect(Int n, Int npos0, Int ix, Int jx, Int desc_X[], Int incx, Int dpos0, Int *iix, Int *jjx, Int *ixrow, Int *ixcol, Int nprow, Int npcol, Int myrow, Int mycol, Int *info)
F_VOID_FUNC zgerv2d_(Int *ConTxt, Int *m, Int *n, double *A, Int *lda, Int *rsrc, Int *csrc)
F_VOID_FUNC zgesd2d_(Int *ConTxt, Int *m, Int *n, double *A, Int *lda, Int *rdest, Int *cdest)