14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
20 void PB_Cinfog2l(
int I,
int J,
int * DESC,
int NPROW,
int NPCOL,
21 int MYROW,
int MYCOL,
int * II,
int * JJ,
22 int * PROW,
int * PCOL )
24 void PB_Cinfog2l( I, J, DESC, NPROW, NPCOL, MYROW, MYCOL, II, JJ,
26 int I, * II, J, * JJ, MYCOL, MYROW, NPCOL, NPROW, * PCOL,
172 int ilocblk, imb, inb, mb, mydist, nb, nblocks, csrc, rsrc;
183 if( ( *PROW == -1 ) || ( NPROW == 1 ) )
195 *II = ( MYROW == *PROW ? I : 0 );
220 nblocks = ( I - imb ) / mb + 1;
222 *PROW -= ( *PROW / NPROW ) * NPROW;
241 if( nblocks < NPROW )
247 ilocblk = nblocks / NPROW;
248 if( ilocblk * NPROW >= nblocks )
250 *II = ( ( MYROW == *PROW ) ? I + ( ilocblk - nblocks ) * mb :
251 imb + ( ilocblk - 1 ) * mb );
255 *II = imb + ilocblk * mb;
265 nblocks = ( I -= imb ) / mb + 1;
267 *PROW -= ( *PROW / NPROW ) * NPROW;
272 if( ( mydist = MYROW - rsrc ) < 0 ) mydist += NPROW;
281 if( nblocks < NPROW )
284 *II = ( ( mydist < 0 ) ? mb :
285 ( ( MYROW == *PROW ) ? I + ( 1 - nblocks ) * mb : 0 ) );
289 ilocblk = nblocks / NPROW;
290 mydist -= nblocks - ilocblk * NPROW;
291 *II = ( ( mydist < 0 ) ? ( ilocblk + 1 ) * mb :
292 ( ( MYROW == *PROW ) ?
293 ( ilocblk - nblocks + 1 ) * mb + I : ilocblk * mb ) );
303 if( ( *PCOL == -1 ) || ( NPCOL == 1 ) )
309 *JJ = ( MYCOL == *PCOL ? J : 0 );
318 nblocks = ( J - inb ) / nb + 1;
320 *PCOL -= ( *PCOL / NPCOL ) * NPCOL;
322 if( nblocks < NPCOL )
328 ilocblk = nblocks / NPCOL;
329 if( ilocblk * NPCOL >= nblocks )
331 *JJ = ( ( MYCOL == *PCOL ) ? J + ( ilocblk - nblocks ) * nb :
332 inb + ( ilocblk - 1 ) * nb );
336 *JJ = inb + ilocblk * nb;
342 nblocks = ( J -= inb ) / nb + 1;
344 *PCOL -= ( *PCOL / NPCOL ) * NPCOL;
346 if( ( mydist = MYCOL - csrc ) < 0 ) mydist += NPCOL;
348 if( nblocks < NPCOL )
351 *JJ = ( ( mydist < 0 ) ? nb : ( ( MYCOL == *PCOL ) ?
352 J + ( 1 - nblocks )*nb : 0 ) );
356 ilocblk = nblocks / NPCOL;
357 mydist -= nblocks - ilocblk * NPCOL;
358 *JJ = ( ( mydist < 0 ) ? ( ilocblk + 1 ) * nb :
359 ( ( MYCOL == *PCOL ) ?
360 ( ilocblk - nblocks + 1 ) * nb + J : ilocblk * nb ) );