21 float * A,
int * IA,
int * JA,
int * DESCA,
22 float * X,
int * IX,
int * JX,
int * DESCX,
25 void pctrsv_( UPLO, TRANS, DIAG, N, A, IA, JA, DESCA, X, IX, JX,
31 int * IA, * INCX, * IX, * JA, * JX, * N;
227 char DiagA, TranOp, UploA, Xroc, btop, ctop, * negone, * one,
229 int Acol, Ai, Aii, Aimb1, Ainb1, Aj, Ajj, Akp, Akq, Ald, Amb, Anb,
230 Anp, Anp0, Anq, Anq0, Arow, Asrc, XACapbX, XACfr, XACld,
231 XACsum, XARapbX, XARfr, XARld, XARsum, Xi, Xj, ctxt, info,
232 ione=1, k, kb, kbnext, kbprev, ktmp, mycol, myrow, nb, notran,
233 nounit, npcol, nprow, size, upper;
239 char * Aptr = NULL, * XAC = NULL, * XAR = NULL;
254 if( !( info = ( ( nprow == -1 ) ? -( 801 +
CTXT_ ) : 0 ) ) )
256 if( ( !upper ) && ( UploA !=
CLOWER ) )
258 PB_Cwarn( ctxt, __LINE__,
"PCTRSV",
"Illegal UPLO = %c\n", UploA );
261 else if( ( !notran ) && ( TranOp !=
CTRAN ) && ( TranOp !=
CCOTRAN ) )
263 PB_Cwarn( ctxt, __LINE__,
"PCTRSV",
"Illegal TRANS = %c\n", TranOp );
266 else if( ( !nounit ) && ( DiagA !=
CUNIT ) )
268 PB_Cwarn( ctxt, __LINE__,
"PCTRSV",
"Illegal DIAG = %c\n", DiagA );
271 PB_Cchkmat( ctxt,
"PCTRSV",
"A", *N, 4, *N, 4, Ai, Aj, Ad, 8, &info );
272 PB_Cchkvec( ctxt,
"PCTRSV",
"X", *N, 4, Xi, Xj, Xd, *INCX, 12, &info );
274 if( info ) {
PB_Cabort( ctxt,
"PCTRSV", info );
return; }
279 if( *N == 0 )
return;
294 PB_Cdescribe( *N, *N, Ai, Aj, Ad, nprow, npcol, myrow, mycol, &Aii, &Ajj,
295 &Ald, &Aimb1, &Ainb1, &Amb, &Anb, &Arow, &Acol, Ad0 );
301 PB_Clcm( ( Arow >= 0 ? nprow : 1 ), ( Acol >= 0 ? npcol : 1 ) );
325 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAC, XACd,
326 &XACfr, &XACsum, &XACapbX );
330 PB_COutV( type,
ROW,
INIT, *N, *N, Ad0, 1, &XAR, XARd, &XARfr,
335 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
336 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
338 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
339 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
340 if( ( Anp > 0 ) && ( Anq > 0 ) )
341 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
343 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
345 for( k = ( ( *N - 1 ) / nb ) * nb; k >= 0; k -= nb )
347 ktmp = *N - k; kb =
MIN( ktmp, nb );
352 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
353 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
354 PB_Cptrsv( type, XARsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
355 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
356 Akq, XARld, size ), XARld );
364 Anq0 =
PB_Cnumroc( kb, k, Ainb1, Anb, mycol, Acol, npcol );
367 kbprev =
MIN( k, nb );
368 ktmp =
PB_Cnumroc( kbprev, k-kbprev, Aimb1, Amb, myrow,
375 cgemv_( TRANS, &ktmp, &Anq0, negone,
376 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
377 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
378 Mptr( XAC, Akp, 0, XACld, size ), &ione );
379 Asrc =
PB_Cindxg2p( k-1, Ainb1, Anb, Acol, Acol, npcol );
381 0, XACld, size ), XACld, myrow, Asrc );
383 cset_( &ktmp, zero,
Mptr( XAC, Akp, 0, XACld,
386 if( Akp > 0 && Anq0 > 0 )
387 cgemv_( TRANS, &Akp, &Anq0, negone,
388 Mptr( Aptr, 0, Akq, Ald, size ), &Ald,
389 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
395 cgemv_( TRANS, &Akp, &Anq0, negone,
396 Mptr( Aptr, 0, Akq, Ald, size ), &Ald,
397 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
405 if( XACsum && ( Anp > 0 ) )
407 Ccgsum2d( ctxt,
ROW, &ctop, Anp, 1, XAC, XACld, myrow,
415 PB_Cpaxpby( type,
NOCONJG, *N, 1, one, XAC, 0, 0, XACd,
COLUMN,
416 zero, ((
char *) X), Xi, Xj, Xd, &Xroc );
442 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAC, XACd,
443 &XACfr, &XACsum, &XACapbX );
447 PB_COutV( type,
ROW,
INIT, *N, *N, Ad0, 1, &XAR, XARd, &XARfr,
452 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
453 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
455 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
456 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
457 if( ( Anp > 0 ) && ( Anq > 0 ) )
458 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
460 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
462 for( k = 0; k < *N; k += nb )
464 ktmp = *N - k; kb =
MIN( ktmp, nb );
469 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
470 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
471 PB_Cptrsv( type, XARsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
472 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
473 Akq, XARld, size ), XARld );
479 Akp =
PB_Cnumroc( k+kb, 0, Aimb1, Amb, myrow, Arow, nprow );
480 if( ( Anp0 = Anp - Akp ) > 0 )
482 Anq0 =
PB_Cnumroc( kb, k, Ainb1, Anb, mycol, Acol, npcol );
485 kbnext = ktmp - kb; kbnext =
MIN( kbnext, nb );
486 ktmp =
PB_Cnumroc( kbnext, k+kb, Aimb1, Amb, myrow, Arow,
493 cgemv_( TRANS, &ktmp, &Anq0, negone,
494 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
495 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
496 Mptr( XAC, Akp, 0, XACld, size ), &ione );
497 Asrc =
PB_Cindxg2p( k+kb, Ainb1, Anb, Acol, Acol, npcol );
499 0, XACld, size ), XACld, myrow, Asrc );
501 cset_( &ktmp, zero,
Mptr( XAC, Akp, 0, XACld,
504 if( Anp0 > 0 && Anq0 > 0 )
505 cgemv_( TRANS, &Anp0, &Anq0, negone,
506 Mptr( Aptr, Akp+ktmp, Akq, Ald, size ), &Ald,
507 Mptr( XAR, 0, Akq, XARld, size ), &XARld,
509 Mptr( XAC, Akp+ktmp, 0, XACld, size ), &ione );
514 cgemv_( TRANS, &Anp0, &Anq0, negone,
515 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
516 Mptr( XAR, 0, Akq, XARld, size ), &XARld,
518 Mptr( XAC, Akp, 0, XACld, size ), &ione );
525 if( XACsum && ( Anp > 0 ) )
527 Ccgsum2d( ctxt,
ROW, &ctop, Anp, 1, XAC, XACld, myrow,
536 COLUMN, zero, ((
char *) X), Xi, Xj, Xd, &Xroc );
565 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAR, XARd,
566 &XARfr, &XARsum, &XARapbX );
570 PB_COutV( type,
COLUMN,
INIT, *N, *N, Ad0, 1, &XAC, XACd, &XACfr,
575 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
576 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
578 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
579 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
580 if( ( Anp > 0 ) && ( Anq > 0 ) )
581 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
583 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
585 for( k = 0; k < *N; k += nb )
587 ktmp = *N - k; kb =
MIN( ktmp, nb );
592 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
593 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
594 PB_Cptrsv( type, XACsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
595 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
596 Akq, XARld, size ), XARld );
602 Akq =
PB_Cnumroc( k+kb, 0, Ainb1, Anb, mycol, Acol, npcol );
603 if( ( Anq0 = Anq - Akq ) > 0 )
605 Anp0 =
PB_Cnumroc( kb, k, Aimb1, Amb, myrow, Arow, nprow );
608 kbnext = ktmp - kb; kbnext =
MIN( kbnext, nb );
609 ktmp =
PB_Cnumroc( kbnext, k+kb, Ainb1, Anb, mycol, Acol,
616 cgemv_( TRANS, &Anp0, &ktmp, negone,
617 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
618 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
619 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
620 Asrc =
PB_Cindxg2p( k+kb, Aimb1, Amb, Arow, Arow, nprow );
622 Akq, XARld, size ), XARld, Asrc, mycol );
624 cset_( &ktmp, zero,
Mptr( XAR, 0, Akq, XARld,
627 if( Anp0 > 0 && Anq0 > 0 )
628 cgemv_( TRANS, &Anp0, &Anq0, negone,
629 Mptr( Aptr, Akp, Akq+ktmp, Ald, size ), &Ald,
630 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
631 Mptr( XAR, 0, Akq+ktmp, XARld, size ), &XARld );
636 cgemv_( TRANS, &Anp0, &Anq0, negone,
637 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
638 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
639 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
646 if( XARsum && ( Anq > 0 ) )
656 PB_Cpaxpby( type,
NOCONJG, 1, *N, one, XAR, 0, 0, XARd,
ROW, zero,
657 ((
char *) X), Xi, Xj, Xd, &Xroc );
683 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAR, XARd,
684 &XARfr, &XARsum, &XARapbX );
688 PB_COutV( type,
COLUMN,
INIT, *N, *N, Ad0, 1, &XAC, XACd, &XACfr,
693 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
694 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
696 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
697 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
698 if( ( Anp > 0 ) && ( Anq > 0 ) )
699 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
701 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
703 for( k = ( ( *N - 1 ) / nb ) * nb; k >= 0; k -= nb )
705 ktmp = *N - k; kb =
MIN( ktmp, nb );
710 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
711 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
712 PB_Cptrsv( type, XACsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
713 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
714 Akq, XARld, size ), XARld );
722 Anp0 =
PB_Cnumroc( kb, k, Aimb1, Amb, myrow, Arow, nprow );
725 kbprev =
MIN( k, nb );
726 ktmp =
PB_Cnumroc( kbprev, k-kbprev, Ainb1, Anb, mycol,
733 cgemv_( TRANS, &Anp0, &ktmp, negone,
734 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
735 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
736 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
737 Asrc =
PB_Cindxg2p( k-1, Aimb1, Amb, Arow, Arow, nprow );
739 Akq, XARld, size ), XARld, Asrc, mycol );
741 cset_( &ktmp, zero,
Mptr( XAR, 0, Akq, XARld,
744 if( Anp0 > 0 && Akq > 0 )
745 cgemv_( TRANS, &Anp0, &Akq, negone,
746 Mptr( Aptr, Akp, 0, Ald, size ), &Ald,
747 Mptr( XAC, Akp, 0, XACld, size ), &ione,
753 cgemv_( TRANS, &Anp0, &Akq, negone,
754 Mptr( Aptr, Akp, 0, Ald, size ), &Ald,
755 Mptr( XAC, Akp, 0, XACld, size ), &ione,
763 if( XARsum && ( Anq > 0 ) )
773 PB_Cpaxpby( type,
NOCONJG, 1, *N, one, XAR, 0, 0, XARd,
ROW, zero,
774 ((
char *) X), Xi, Xj, Xd, &Xroc );
783 if( XACfr ) free( XAC );
784 if( XARfr ) free( XAR );