21 float * A,
int * IA,
int * JA,
int * DESCA,
22 float * X,
int * IX,
int * JX,
int * DESCX,
25 void pstrsv_( UPLO, TRANS, DIAG, N, A, IA, JA, DESCA, X, IX, JX,
31 int * IA, * INCX, * IX, * JA, * JX, * N;
225 char DiagA, TranOp, UploA, Xroc, btop, ctop, * negone, * one,
227 int Acol, Ai, Aii, Aimb1, Ainb1, Aj, Ajj, Akp, Akq, Ald, Amb, Anb,
228 Anp, Anp0, Anq, Anq0, Arow, Asrc, XACapbX, XACfr, XACld,
229 XACsum, XARapbX, XARfr, XARld, XARsum, Xi, Xj, ctxt, info,
230 ione=1, k, kb, kbnext, kbprev, ktmp, mycol, myrow, nb, notran,
231 nounit, npcol, nprow, size, upper;
237 char * Aptr = NULL, * XAC = NULL, * XAR = NULL;
252 if( !( info = ( ( nprow == -1 ) ? -( 801 +
CTXT_ ) : 0 ) ) )
254 if( ( !upper ) && ( UploA !=
CLOWER ) )
256 PB_Cwarn( ctxt, __LINE__,
"PSTRSV",
"Illegal UPLO = %c\n", UploA );
259 else if( ( !notran ) && ( TranOp !=
CTRAN ) && ( TranOp !=
CCOTRAN ) )
261 PB_Cwarn( ctxt, __LINE__,
"PSTRSV",
"Illegal TRANS = %c\n", TranOp );
264 else if( ( !nounit ) && ( DiagA !=
CUNIT ) )
266 PB_Cwarn( ctxt, __LINE__,
"PSTRSV",
"Illegal DIAG = %c\n", DiagA );
269 PB_Cchkmat( ctxt,
"PSTRSV",
"A", *N, 4, *N, 4, Ai, Aj, Ad, 8, &info );
270 PB_Cchkvec( ctxt,
"PSTRSV",
"X", *N, 4, Xi, Xj, Xd, *INCX, 12, &info );
272 if( info ) {
PB_Cabort( ctxt,
"PSTRSV", info );
return; }
277 if( *N == 0 )
return;
292 PB_Cdescribe( *N, *N, Ai, Aj, Ad, nprow, npcol, myrow, mycol, &Aii, &Ajj,
293 &Ald, &Aimb1, &Ainb1, &Amb, &Anb, &Arow, &Acol, Ad0 );
299 PB_Clcm( ( Arow >= 0 ? nprow : 1 ), ( Acol >= 0 ? npcol : 1 ) );
323 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAC, XACd,
324 &XACfr, &XACsum, &XACapbX );
328 PB_COutV( type,
ROW,
INIT, *N, *N, Ad0, 1, &XAR, XARd, &XARfr,
333 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
334 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
336 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
337 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
338 if( ( Anp > 0 ) && ( Anq > 0 ) )
339 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
341 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
343 for( k = ( ( *N - 1 ) / nb ) * nb; k >= 0; k -= nb )
345 ktmp = *N - k; kb =
MIN( ktmp, nb );
350 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
351 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
352 PB_Cptrsv( type, XARsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
353 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
354 Akq, XARld, size ), XARld );
362 Anq0 =
PB_Cnumroc( kb, k, Ainb1, Anb, mycol, Acol, npcol );
365 kbprev =
MIN( k, nb );
366 ktmp =
PB_Cnumroc( kbprev, k-kbprev, Aimb1, Amb, myrow,
373 sgemv_( TRANS, &ktmp, &Anq0, negone,
374 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
375 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
376 Mptr( XAC, Akp, 0, XACld, size ), &ione );
377 Asrc =
PB_Cindxg2p( k-1, Ainb1, Anb, Acol, Acol, npcol );
379 0, XACld, size ), XACld, myrow, Asrc );
381 sset_( &ktmp, zero,
Mptr( XAC, Akp, 0, XACld,
384 if( Akp > 0 && Anq0 > 0 )
385 sgemv_( TRANS, &Akp, &Anq0, negone,
386 Mptr( Aptr, 0, Akq, Ald, size ), &Ald,
387 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
393 sgemv_( TRANS, &Akp, &Anq0, negone,
394 Mptr( Aptr, 0, Akq, Ald, size ), &Ald,
395 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
403 if( XACsum && ( Anp > 0 ) )
405 Csgsum2d( ctxt,
ROW, &ctop, Anp, 1, XAC, XACld, myrow,
413 PB_Cpaxpby( type,
NOCONJG, *N, 1, one, XAC, 0, 0, XACd,
COLUMN,
414 zero, ((
char *) X), Xi, Xj, Xd, &Xroc );
440 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAC, XACd,
441 &XACfr, &XACsum, &XACapbX );
445 PB_COutV( type,
ROW,
INIT, *N, *N, Ad0, 1, &XAR, XARd, &XARfr,
450 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
451 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
453 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
454 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
455 if( ( Anp > 0 ) && ( Anq > 0 ) )
456 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
458 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
460 for( k = 0; k < *N; k += nb )
462 ktmp = *N - k; kb =
MIN( ktmp, nb );
467 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
468 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
469 PB_Cptrsv( type, XARsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
470 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
471 Akq, XARld, size ), XARld );
477 Akp =
PB_Cnumroc( k+kb, 0, Aimb1, Amb, myrow, Arow, nprow );
478 if( ( Anp0 = Anp - Akp ) > 0 )
480 Anq0 =
PB_Cnumroc( kb, k, Ainb1, Anb, mycol, Acol, npcol );
483 kbnext = ktmp - kb; kbnext =
MIN( kbnext, nb );
484 ktmp =
PB_Cnumroc( kbnext, k+kb, Aimb1, Amb, myrow, Arow,
491 sgemv_( TRANS, &ktmp, &Anq0, negone,
492 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
493 Mptr( XAR, 0, Akq, XARld, size ), &XARld, one,
494 Mptr( XAC, Akp, 0, XACld, size ), &ione );
495 Asrc =
PB_Cindxg2p( k+kb, Ainb1, Anb, Acol, Acol, npcol );
497 0, XACld, size ), XACld, myrow, Asrc );
499 sset_( &ktmp, zero,
Mptr( XAC, Akp, 0, XACld,
502 if( Anp0 > 0 && Anq0 > 0 )
503 sgemv_( TRANS, &Anp0, &Anq0, negone,
504 Mptr( Aptr, Akp+ktmp, Akq, Ald, size ), &Ald,
505 Mptr( XAR, 0, Akq, XARld, size ), &XARld,
507 Mptr( XAC, Akp+ktmp, 0, XACld, size ), &ione );
512 sgemv_( TRANS, &Anp0, &Anq0, negone,
513 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
514 Mptr( XAR, 0, Akq, XARld, size ), &XARld,
516 Mptr( XAC, Akp, 0, XACld, size ), &ione );
523 if( XACsum && ( Anp > 0 ) )
525 Csgsum2d( ctxt,
ROW, &ctop, Anp, 1, XAC, XACld, myrow,
534 COLUMN, zero, ((
char *) X), Xi, Xj, Xd, &Xroc );
563 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAR, XARd,
564 &XARfr, &XARsum, &XARapbX );
568 PB_COutV( type,
COLUMN,
INIT, *N, *N, Ad0, 1, &XAC, XACd, &XACfr,
573 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
574 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
576 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
577 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
578 if( ( Anp > 0 ) && ( Anq > 0 ) )
579 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
581 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
583 for( k = 0; k < *N; k += nb )
585 ktmp = *N - k; kb =
MIN( ktmp, nb );
590 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
591 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
592 PB_Cptrsv( type, XACsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
593 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
594 Akq, XARld, size ), XARld );
600 Akq =
PB_Cnumroc( k+kb, 0, Ainb1, Anb, mycol, Acol, npcol );
601 if( ( Anq0 = Anq - Akq ) > 0 )
603 Anp0 =
PB_Cnumroc( kb, k, Aimb1, Amb, myrow, Arow, nprow );
606 kbnext = ktmp - kb; kbnext =
MIN( kbnext, nb );
607 ktmp =
PB_Cnumroc( kbnext, k+kb, Ainb1, Anb, mycol, Acol,
614 sgemv_( TRANS, &Anp0, &ktmp, negone,
615 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
616 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
617 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
618 Asrc =
PB_Cindxg2p( k+kb, Aimb1, Amb, Arow, Arow, nprow );
620 Akq, XARld, size ), XARld, Asrc, mycol );
622 sset_( &ktmp, zero,
Mptr( XAR, 0, Akq, XARld,
625 if( Anp0 > 0 && Anq0 > 0 )
626 sgemv_( TRANS, &Anp0, &Anq0, negone,
627 Mptr( Aptr, Akp, Akq+ktmp, Ald, size ), &Ald,
628 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
629 Mptr( XAR, 0, Akq+ktmp, XARld, size ), &XARld );
634 sgemv_( TRANS, &Anp0, &Anq0, negone,
635 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
636 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
637 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
644 if( XARsum && ( Anq > 0 ) )
654 PB_Cpaxpby( type,
NOCONJG, 1, *N, one, XAR, 0, 0, XARd,
ROW, zero,
655 ((
char *) X), Xi, Xj, Xd, &Xroc );
681 ((
char *) X), Xi, Xj, Xd, &Xroc, &XAR, XARd,
682 &XARfr, &XARsum, &XARapbX );
686 PB_COutV( type,
COLUMN,
INIT, *N, *N, Ad0, 1, &XAC, XACd, &XACfr,
691 Aimb1 = Ad0[
IMB_ ]; Ainb1 = Ad0[
INB_ ];
692 Amb = Ad0[
MB_ ]; Anb = Ad0[
NB_ ];
694 Anp =
PB_Cnumroc( *N, 0, Aimb1, Amb, myrow, Arow, nprow );
695 Anq =
PB_Cnumroc( *N, 0, Ainb1, Anb, mycol, Acol, npcol );
696 if( ( Anp > 0 ) && ( Anq > 0 ) )
697 Aptr =
Mptr( ((
char *) A), Aii, Ajj, Ald, size );
699 XACld = XACd[
LLD_]; XARld = XARd[
LLD_];
701 for( k = ( ( *N - 1 ) / nb ) * nb; k >= 0; k -= nb )
703 ktmp = *N - k; kb =
MIN( ktmp, nb );
708 Akp =
PB_Cnumroc( k, 0, Aimb1, Amb, myrow, Arow, nprow );
709 Akq =
PB_Cnumroc( k, 0, Ainb1, Anb, mycol, Acol, npcol );
710 PB_Cptrsv( type, XACsum, &UploA, &TranOp, &DiagA, kb, Aptr, k, k,
711 Ad0,
Mptr( XAC, Akp, 0, XACld, size ), 1,
Mptr( XAR, 0,
712 Akq, XARld, size ), XARld );
720 Anp0 =
PB_Cnumroc( kb, k, Aimb1, Amb, myrow, Arow, nprow );
723 kbprev =
MIN( k, nb );
724 ktmp =
PB_Cnumroc( kbprev, k-kbprev, Ainb1, Anb, mycol,
731 sgemv_( TRANS, &Anp0, &ktmp, negone,
732 Mptr( Aptr, Akp, Akq, Ald, size ), &Ald,
733 Mptr( XAC, Akp, 0, XACld, size ), &ione, one,
734 Mptr( XAR, 0, Akq, XARld, size ), &XARld );
735 Asrc =
PB_Cindxg2p( k-1, Aimb1, Amb, Arow, Arow, nprow );
737 Akq, XARld, size ), XARld, Asrc, mycol );
739 sset_( &ktmp, zero,
Mptr( XAR, 0, Akq, XARld,
742 if( Anp0 > 0 && Akq > 0 )
743 sgemv_( TRANS, &Anp0, &Akq, negone,
744 Mptr( Aptr, Akp, 0, Ald, size ), &Ald,
745 Mptr( XAC, Akp, 0, XACld, size ), &ione,
751 sgemv_( TRANS, &Anp0, &Akq, negone,
752 Mptr( Aptr, Akp, 0, Ald, size ), &Ald,
753 Mptr( XAC, Akp, 0, XACld, size ), &ione,
761 if( XARsum && ( Anq > 0 ) )
771 PB_Cpaxpby( type,
NOCONJG, 1, *N, one, XAR, 0, 0, XARd,
ROW, zero,
772 ((
char *) X), Xi, Xj, Xd, &Xroc );
781 if( XACfr ) free( XAC );
782 if( XARfr ) free( XAR );