14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 char * X,
int IX,
int JX,
int * DESCX,
int INCX,
22 char * Y,
int IY,
int JY,
int * DESCY,
int INCY )
24 void PB_CpswapNN(
TYPE, N, X, IX, JX, DESCX, INCX, Y, IY, JY, DESCY, INCY )
28 int INCX, INCY, IX, IY, JX, JY, N;
185 char Xscope, Yscope, * top;
186 int RRorCC, XYm, XYn, Xcol, Xii, XisR, XisRow, Xjj, Xld, Xlinc,
187 XmyprocD, XmyprocR, XnprocsR, XprocR, Xrow, Ycol, Yii, YisR,
188 YisRow, Yjj, Yld, Ylinc, YmyprocD, YmyprocR, YnprocsR, YprocR,
189 Yrow, csrc, ctxt, mycol, myrow, npcol, nprow, rsrc, size;
201 PB_Cinfog2l( IX, JX, DESCX, nprow, npcol, myrow, mycol, &Xii, &Xjj,
203 if( ( XisRow = ( INCX == DESCX[
M_] ) ) != 0 )
205 Xld = DESCX[
LLD_]; Xlinc = Xld;
206 XmyprocD = mycol; XprocR = Xrow; XmyprocR = myrow; XnprocsR = nprow;
207 XisR = ( ( Xrow == -1 ) || ( XnprocsR == 1 ) );
211 Xld = DESCX[
LLD_]; Xlinc = 1;
212 XmyprocD = myrow; XprocR = Xcol; XmyprocR = mycol; XnprocsR = npcol;
213 XisR = ( ( Xcol == -1 ) || ( XnprocsR == 1 ) );
218 PB_Cinfog2l( IY, JY, DESCY, nprow, npcol, myrow, mycol, &Yii, &Yjj,
220 if( ( YisRow = ( INCY == DESCY[
M_] ) ) != 0 )
222 Yld = DESCY[
LLD_]; Ylinc = Yld;
223 YmyprocD = mycol; YprocR = Yrow; YmyprocR = myrow; YnprocsR = nprow;
224 YisR = ( ( Yrow == -1 ) || ( YnprocsR == 1 ) );
228 Yld = DESCY[
LLD_]; Ylinc = 1;
229 YmyprocD = myrow; YprocR = Ycol; YmyprocR = mycol; YnprocsR = npcol;
230 YisR = ( ( Ycol == -1 ) || ( YnprocsR == 1 ) );
235 RRorCC = ( ( XisRow && YisRow ) || ( !( XisRow ) && !( YisRow ) ) );
249 if( ( XmyprocR != XprocR ) && ( YmyprocR != YprocR ) )
262 if( XprocR == YprocR )
267 TYPE->Fswap( &N,
Mptr( X, Xii, Xjj, Xld, size ), &Xlinc,
Mptr( Y,
268 Yii, Yjj, Yld, size ), &Ylinc );
275 if( XmyprocR == XprocR )
283 TYPE->Cgesd2d( ctxt, 1, N,
Mptr( X, Xii, Xjj, Xld, size ),
284 Xld, YprocR, XmyprocD );
285 TYPE->Cgerv2d( ctxt, 1, N,
Mptr( X, Xii, Xjj, Xld, size ),
286 Xld, YprocR, XmyprocD );
290 TYPE->Cgesd2d( ctxt, N, 1,
Mptr( X, Xii, Xjj, Xld, size ),
291 Xld, XmyprocD, YprocR );
292 TYPE->Cgerv2d( ctxt, N, 1,
Mptr( X, Xii, Xjj, Xld, size ),
293 Xld, XmyprocD, YprocR );
297 if( YmyprocR == YprocR )
305 TYPE->Cgesd2d( ctxt, 1, N,
Mptr( Y, Yii, Yjj, Yld, size ),
306 Yld, XprocR, YmyprocD );
307 TYPE->Cgerv2d( ctxt, 1, N,
Mptr( Y, Yii, Yjj, Yld, size ),
308 Yld, XprocR, YmyprocD );
312 TYPE->Cgesd2d( ctxt, N, 1,
Mptr( Y, Yii, Yjj, Yld, size ),
313 Yld, YmyprocD, XprocR );
314 TYPE->Cgerv2d( ctxt, N, 1,
Mptr( Y, Yii, Yjj, Yld, size ),
315 Yld, YmyprocD, XprocR );
329 rsrc = XprocR; csrc = YprocR;
335 rsrc = YprocR; csrc = XprocR;
338 if( ( XmyprocR == XprocR ) && ( YmyprocR == YprocR ) )
344 TYPE->Fswap( &N,
Mptr( X, Xii, Xjj, Xld, size ), &Xlinc,
345 Mptr( Y, Yii, Yjj, Yld, size ), &Ylinc );
347 TYPE->Cgebs2d( ctxt, &Xscope, top, XYm, XYn,
Mptr( X, Xii, Xjj,
350 TYPE->Cgebs2d( ctxt, &Yscope, top, XYn, XYm,
Mptr( Y, Yii, Yjj,
353 else if( XmyprocR == XprocR )
356 TYPE->Cgebr2d( ctxt, &Xscope, top, XYm, XYn,
Mptr( X, Xii, Xjj,
357 Xld, size ), Xld, rsrc, csrc );
359 else if( YmyprocR == YprocR )
362 TYPE->Cgebr2d( ctxt, &Yscope, top, XYn, XYm,
Mptr( Y, Yii, Yjj,
363 Yld, size ), Yld, rsrc, csrc );
374 if( YisRow ) { XYm = 1; XYn = N; }
375 else { XYm = N; XYn = 1; }
377 if( XmyprocR == XprocR )
383 TYPE->Fswap( &N,
Mptr( X, Xii, Xjj, Xld, size ), &Xlinc,
Mptr( Y,
384 Yii, Yjj, Yld, size ), &Ylinc );
395 TYPE->Cgebs2d( ctxt,
ROW, top, XYm, XYn,
Mptr( Y, Yii, Yjj,
408 Yld, size ), Yld, XprocR, XmyprocD );
413 TYPE->Cgebr2d( ctxt,
ROW, top, XYm, XYn,
Mptr( Y, Yii, Yjj,
414 Yld, size ), Yld, XmyprocD, XprocR );
426 if( YisR || ( YmyprocR == YprocR ) )
431 TYPE->Fswap( &N,
Mptr( X, Xii, Xjj, Xld, size ), &Xlinc,
Mptr( Y, Yii,
432 Yjj, Yld, size ), &Ylinc );
442 if( XisRow ) { XYm = 1; XYn = N; }
443 else { XYm = N; XYn = 1; }
448 if( YmyprocR == YprocR )
453 Xld, size ), Xld, YprocR, YmyprocD );
458 if( YmyprocR == YprocR )
459 TYPE->Cgebs2d( ctxt,
ROW, top, XYm, XYn,
Mptr( X, Xii, Xjj,
462 TYPE->Cgebr2d( ctxt,
ROW, top, XYm, XYn,
Mptr( X, Xii, Xjj,
463 Xld, size ), Xld, YmyprocD, YprocR );