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;
176 complex xwork[1], ywork[1], zero;
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,
"PCROT", info );
return; }
273
274
275
276
277
278
279
280
281
282
285 if( *n == 0 ) return;
286
287
288
289 if( *n == 1 )
290 {
291 if( ( myrow == ixrow ) && ( mycol == ixcol ) )
292 {
293 buff = &X[iix-1+(jjx-1)*desc_X[
LLD_]];
294 if( ( myrow != iyrow ) || ( mycol != iycol ) )
295 {
296 cgesd2d_( &ictxt, n, n, buff, n, &iyrow, &iycol );
297 cgerv2d_( &ictxt, n, n, ywork, n, &iyrow, &iycol );
298 }
299 else
300 *ywork = Y[iiy-1+(jjy-1)*desc_Y[
LLD_]];
301 crot_( n, buff, n, ywork, n, c, s );
302 X[iix-1+(jjx-1)*desc_X[
LLD_]] = *buff;
303 if( ( myrow == iyrow ) && ( mycol == iycol ) )
304 Y[iiy-1+(jjy-1)*desc_Y[
LLD_]] = *ywork;
305 }
306 else if( ( myrow == iyrow ) && ( mycol == iycol ) )
307 {
308 cgesd2d_( &ictxt, n, n, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], n,
309 &ixrow, &ixcol );
310 cgerv2d_( &ictxt, n, n, xwork, n, &ixrow, &ixcol );
311 crot_( n, xwork, n, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], n, c, s );
312 }
313 return;
314 }
315
316 if( ( *incx == desc_X[
M_] ) && ( *incy == desc_Y[
M_] ) )
317 {
318 nz = (*jx-1) % desc_Y[
NB_];
319 nn = *n + nz;
320 nq = numroc_( &nn, &desc_X[
NB_], &mycol, &ixcol, &npcol );
321 if( mycol == ixcol )
322 nq -= nz;
323 if( ixrow == iyrow )
324 {
325 if( myrow == ixrow )
326 {
328 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_], c, s );
329 }
330 }
331 else
332 {
333 if( myrow == ixrow )
334 {
336 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
337 &iyrow, &mycol );
339 cgerv2d_( &ictxt, &nq, &ione, buff, &nq, &iyrow, &mycol );
341 buff, &ione, c, s );
342 }
343 else if( myrow == iyrow )
344 {
346 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
347 &ixrow, &mycol );
349 cgerv2d_( &ictxt, &nq, &ione, buff, &nq, &ixrow, &mycol );
350 crot_( &nq, buff, &ione,
351 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_], c, s );
352 }
353 }
354 }
355 else if( ( *incx == 1 ) && ( *incx != desc_X[
M_] ) &&
356 ( *incy == 1 ) && ( *incy != desc_Y[
M_] ) )
357 {
358 nz = (*ix-1) % desc_X[
MB_];
359 nn = *n + nz;
360 np = numroc_( &nn, &desc_X[
MB_], &myrow, &ixrow, &nprow );
361 if( myrow == ixrow )
362 np -= nz;
363 if( ixcol == iycol )
364 {
365 if( mycol == ixcol )
366 {
367 crot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]], incx,
368 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
369 }
370 }
371 else
372 {
373 if( mycol == ixcol )
374 {
376 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
377 &myrow, &iycol );
379 cgerv2d_( &ictxt, &np, &ione, buff, &np, &myrow, &iycol );
380 crot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]], incx,
381 buff, &ione, c, s );
382 }
383 else if( mycol == iycol )
384 {
386 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
387 &myrow, &ixcol );
389 cgerv2d_( &ictxt, &np, &ione, buff, &np, &myrow, &ixcol );
390 crot_( &np, buff, &ione,
391 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
392 }
393 }
394 }
395 else
396 {
397 lcm = ilcm_( &nprow, &npcol );
398 if( ( *incx == 1 ) && ( *incx != desc_X[
M_] ) )
399 {
400 lcmp = lcm / nprow;
401 nz = (*jy-1) % desc_Y[
NB_];
402 nn = *n + nz;
403 tmp1 = nn / desc_Y[
MB_];
404 np = numroc_( &nn, &desc_X[
MB_], &myrow, &ixrow, &nprow );
405 np0 =
MYROC0( tmp1, nn, desc_X[
MB_], nprow );
406 tmp1 = np0 / desc_X[
MB_];
407 wksz =
MYROC0( tmp1, np0, desc_X[
MB_], lcmp );
408 wksz = np + wksz;
409
411
412 if( mycol == iycol )
413 jjy -= nz;
414 if( myrow == ixrow )
415 np -= nz;
417 &desc_Y[
NB_], &nz, &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]],
418 &desc_Y[
LLD_], &zero, buff, &ione, &iyrow, &iycol,
419 &ixrow, &ixcol, buff+np );
420 if( mycol == ixcol )
421 {
422 crot_( &np, &X[iix-1+(jjx-1)*desc_X[
LLD_]],
423 incx, buff, &ione, c, s );
424 }
426 &desc_Y[
NB_], &nz, buff, &ione, &zero,
427 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], &desc_Y[
LLD_],
428 &ixrow, &ixcol, &iyrow, &iycol, buff+np );
429 }
430 else
431 {
432 lcmp = lcm / nprow;
433 nz = (*jx-1) % desc_X[
NB_];
434 nn = *n + nz;
435 tmp1 = nn / desc_X[
MB_];
436 np = numroc_( &nn, desc_Y+
MB_, &myrow, &iyrow, &nprow );
437 np0 =
MYROC0( tmp1, nn, desc_Y[
MB_], nprow );
438 tmp1 = np0 / desc_Y[
MB_];
439 wksz =
MYROC0( tmp1, np0, desc_Y[
MB_], lcmp );
440 wksz = np + wksz;
441
443
444 if( myrow == iyrow )
445 np -= nz;
447 &desc_X[
NB_], &nz, &X[iix-1+(jjx-1)*desc_X[
LLD_]],
448 &desc_X[
LLD_], &zero, buff, &ione, &ixrow, &ixcol,
449 &iyrow, &iycol, buff+np );
450 if( mycol == iycol )
451 {
452 crot_( &np, buff, &ione,
453 &Y[iiy-1+(jjy-1)*desc_Y[
LLD_]], incy, c, s );
454 }
456 &desc_X[
NB_], &nz, buff, &ione, &zero,
457 &X[iix-1+(jjx-1)*desc_X[
LLD_]], &desc_X[
LLD_],
458 &iyrow, &iycol, &ixrow, &ixcol, buff+np );
459 }
460 }
461}
#define MYROC0(nblocks, n, nb, nprocs)
F_VOID_FUNC blacs_gridinfo_(Int *ConTxt, Int *nprow, Int *npcol, Int *myrow, Int *mycol)
F_VOID_FUNC cgerv2d_(Int *ConTxt, Int *m, Int *n, float *A, Int *lda, Int *rsrc, Int *csrc)
F_VOID_FUNC cgesd2d_(Int *ConTxt, Int *m, Int *n, float *A, Int *lda, Int *rdest, Int *cdest)
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)