14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 int N,
int KA,
int * DESCA,
int K,
char * Y,
int IY,
22 int JY,
int * DESCY,
char * YROC,
char * * YAPTR,
23 int * DYA,
int * YAFREE,
int * YASUM,
int * YAPBY )
25 void PB_CInOutV2(
TYPE, CONJUG, ROWCOL, M, N, KA, DESCA, K, Y, IY, JY,
26 DESCY, YROC, YAPTR, DYA, YAFREE, YASUM, YAPBY )
30 char * CONJUG, * ROWCOL, * YROC;
31 int * YAPBY, * YAFREE, IY, JY, K, KA, M, N, * YASUM;
36 int * DESCA, * DESCY, * DYA;
229 int Acol, Acoldst, Aimb, Ainb, AisD, AisR, Amb, Amp, Anb, Anq,
230 Arow, Arowdst, Ycol, Yii, Yimb, Yimb1, Yinb, Yinb1, YisD,
231 YisR, YisRow, Yjj, Yld, Ymb, Ymp, Ynb, Ynq, Yrow, ctxt,
232 izero=0, nprow, myrow, npcol, mycol;
247 if( ( M <= 0 ) || ( N <= 0 ) || ( K <= 0 ) )
268 Minfog2l( IY, JY, DESCY, nprow, npcol, myrow, mycol, Yii, Yjj, Yrow, Ycol );
272 if( ( YisRow = (
Mupcase( YROC[0] ) ==
CROW ) ) != 0 )
274 YisD = ( ( Ycol >= 0 ) && ( npcol > 1 ) );
275 YisR = ( ( Yrow == -1 ) || ( nprow == 1 ) );
279 YisD = ( ( Yrow >= 0 ) && ( nprow > 1 ) );
280 YisR = ( ( Ycol == -1 ) || ( npcol == 1 ) );
283 Aimb = DESCA[
IMB_ ]; Ainb = DESCA[
INB_ ];
284 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ];
292 AisR = ( ( Arow < 0 ) || ( nprow == 1 ) );
296 Arowdst =
PB_Cindxg2p( KA, Aimb, Amb, Arow, Arow, nprow );
304 AisD = ( ( Acol >= 0 ) && ( npcol > 1 ) );
306 Yinb = DESCY[
INB_]; Ynb = DESCY[
NB_];
314 if( ( !AisD && !YisD ) ||
315 ( ( AisD && YisD ) &&
316 ( ( Acol == Ycol ) &&
317 ( ( ( Ainb >= N ) && ( Yinb1 >= N ) ) ||
318 ( ( Ainb == Yinb1 ) && ( Anb == Ynb ) ) ) ) ) )
320 Ynq =
PB_Cnumroc( N, 0, Yinb1, Ynb, mycol, Ycol, npcol );
321 Ymp = ( YisR ? K : ( ( myrow == Yrow ) ? K : 0 ) );
331 *YASUM = ( AisR ? 0 : ( nprow > 1 ) );
336 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
337 if( !AisR && ( myrow != Arowdst ) )
339 &Ynq, &izero,
TYPE->zero,
TYPE->zero, *YAPTR,
358 DESCA[
RSRC_ ] = Yrow;
359 if( ( Ynq > 0 ) && ( Ymp > 0 ) )
360 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
364 if(
PB_Cspan( M, 0, Aimb, Amb, Arow, nprow ) )
370 *YASUM = ( nprow > 1 );
382 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
383 if( Yrow != Arowdst )
385 TYPE->Cgesd2d( ctxt, K, Ynq, *YAPTR, Yld, Arowdst,
405 if( ( Yrow != Arowdst ) && ( myrow == Arowdst ) )
406 TYPE->Cgerv2d( ctxt, K, Ynq, *YAPTR, Yld, Yrow,
429 if( ( myrow == Yrow ) && ( Ynq > 0 ) )
430 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
447 TYPE->Cgesd2d( ctxt, K, Ynq,
Mptr( Y, Yii, Yjj,
448 Yld,
TYPE->size ), Yld, Arowdst,
451 else if( myrow == Arowdst )
456 TYPE->Cgerv2d( ctxt, K, Ynq, *YAPTR, Yld, Yrow,
470 PB_Cdescset( DYA, K, N, K, Yinb1, 1, Ynb, Yrow, Ycol, ctxt, Yld );
478 Anq =
PB_Cnumroc( N, 0, Ainb, Anb, mycol, Acol, npcol );
489 *YASUM = ( AisR ? 0 : ( nprow > 1 ) );
494 if( ( Arowdst >= 0 ) && ( myrow != Arowdst ) )
496 &izero,
TYPE->zero,
TYPE->zero, *YAPTR, &Yld );
524 if( ( myrow == ( Arowdst = DESCA[
RSRC_] ) ) && ( Anq > 0 ) )
532 if(
PB_Cspan( M, 0, Aimb, Amb, Arow, nprow ) )
538 *YASUM = ( nprow > 1 );
543 if( myrow != Arowdst )
545 &Anq, &izero,
TYPE->zero,
TYPE->zero, *YAPTR,
556 if( ( myrow == Arowdst ) && ( Anq > 0 ) )
569 PB_Cdescset( DYA, K, N, K, Ainb, 1, Anb, Arowdst, Acol, ctxt, Yld );
575 PB_Cpaxpby(
TYPE, CONJUG, K, N,
TYPE->one, Y, IY, JY, DESCY,
ROW,
576 TYPE->zero, *YAPTR, 0, 0, DYA,
ROW );
580 PB_Cpaxpby(
TYPE, CONJUG, N, K,
TYPE->one, Y, IY, JY, DESCY,
COLUMN,
581 TYPE->zero, *YAPTR, 0, 0, DYA,
ROW );
589 AisR = ( ( Acol < 0 ) || ( npcol == 1 ) );
593 Acoldst =
PB_Cindxg2p( KA, Ainb, Anb, Acol, Acol, npcol );
601 AisD = ( ( Arow >= 0 ) && ( nprow > 1 ) );
603 Yimb = DESCY[
IMB_]; Ymb = DESCY[
MB_];
611 if( ( !AisD && !YisD ) ||
612 ( ( AisD && YisD ) &&
613 ( ( Arow == Yrow ) &&
614 ( ( ( Aimb >= M ) && ( Yimb1 >= M ) ) ||
615 ( ( Aimb == Yimb1 ) && ( Amb == Ymb ) ) ) ) ) )
617 Ymp =
PB_Cnumroc( M, 0, Yimb1, Ymb, myrow, Yrow, nprow );
618 Ynq = ( YisR ? K : ( ( mycol == Ycol ) ? K : 0 ) );
628 *YASUM = ( AisR ? 0 : ( npcol > 1 ) );
633 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
634 if( !AisR && ( mycol != Acoldst ) )
636 &K, &izero,
TYPE->zero,
TYPE->zero, *YAPTR,
655 DESCA[
CSRC_ ] = Ycol;
656 if( ( Ymp > 0 ) && ( Ynq > 0 ) )
657 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
661 if(
PB_Cspan( N, 0, Ainb, Anb, Acol, npcol ) )
667 *YASUM = ( npcol > 1 );
679 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
680 if( Ycol != Acoldst )
682 TYPE->Cgesd2d( ctxt, Ymp, K, *YAPTR, Yld, myrow,
702 if( ( Ycol != Acoldst ) && ( mycol == Acoldst ) )
703 TYPE->Cgerv2d( ctxt, Ymp, K, *YAPTR, Yld, myrow,
726 if( ( mycol == Ycol ) && ( Ymp > 0 ) )
727 *YAPTR =
Mptr( Y, Yii, Yjj, Yld,
TYPE->size );
744 TYPE->Cgesd2d( ctxt, Ymp, K,
Mptr( Y, Yii, Yjj,
745 Yld,
TYPE->size ), Yld, myrow,
748 else if( mycol == Acoldst )
750 Yld =
MAX( 1, Ymp ) ;
753 TYPE->Cgerv2d( ctxt, Ymp, K, *YAPTR, Yld, myrow,
767 PB_Cdescset( DYA, M, K, Yimb1, K, Ymb, 1, Yrow, Ycol, ctxt, Yld );
775 Amp =
PB_Cnumroc( M, 0, Aimb, Amb, myrow, Arow, nprow );
786 *YASUM = ( AisR ? 0 : ( npcol > 1 ) );
791 if( ( Acoldst >= 0 ) && ( mycol != Acoldst ) )
793 &izero,
TYPE->zero,
TYPE->zero, *YAPTR, &Yld );
821 if( ( mycol == ( Acoldst = DESCA[
CSRC_] ) ) && ( Amp > 0 ) )
829 if(
PB_Cspan( N, 0, Ainb, Anb, Acol, npcol ) )
835 *YASUM = ( npcol > 1 );
840 if( mycol != Acoldst )
842 &K, &izero,
TYPE->zero,
TYPE->zero, *YAPTR,
853 if( ( mycol == Acoldst ) && ( Amp > 0 ) )
866 PB_Cdescset( DYA, M, K, Aimb, K, Amb, 1, Arow, Acoldst, ctxt, Yld );
872 PB_Cpaxpby(
TYPE, CONJUG, K, M,
TYPE->one, Y, IY, JY, DESCY,
ROW,
877 PB_Cpaxpby(
TYPE, CONJUG, M, K,
TYPE->one, Y, IY, JY, DESCY,
COLUMN,