14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 int N,
int * DESCA,
int K,
char * X,
int IX,
int JX,
22 int * DESCX,
char * XROC,
char * * XAPTR,
int * DXA,
25 void PB_CInV(
TYPE, CONJUG, ROWCOL, M, N, DESCA, K, X, IX, JX, DESCX,
26 XROC, XAPTR, DXA, XAFREE )
30 char * CONJUG, * ROWCOL, * XROC;
31 int * XAFREE, IX, JX, K, M, N;
36 int * DESCA, * DESCX, * DXA;
205 int AColSpan, ARowSpan, Acol, Aimb, Ainb, AisD, Amb, Amp, Anb,
206 Anq, Arow, Xcol, Xii, Ximb, Ximb1, Xinb, Xinb1, XisD, XisR,
207 XisRow, Xjj, Xld=1, Xmb, Xmp, Xnb, Xnq, Xrow, ctxt, mycol,
221 if( ( M <= 0 ) || ( N <= 0 ) || ( K <= 0 ) )
242 Minfog2l( IX, JX, DESCX, nprow, npcol, myrow, mycol, Xii, Xjj, Xrow, Xcol );
246 if( ( XisRow = (
Mupcase( XROC[0] ) ==
CROW ) ) != 0 )
248 XisD = ( ( Xcol >= 0 ) && ( npcol > 1 ) );
249 XisR = ( ( Xrow == -1 ) || ( nprow == 1 ) );
253 XisD = ( ( Xrow >= 0 ) && ( nprow > 1 ) );
254 XisR = ( ( Xcol == -1 ) || ( npcol == 1 ) );
264 Ainb = DESCA[
INB_ ]; Anb = DESCA[
NB_ ];
265 Mnumroc( Anq, N, 0, Ainb, Anb, mycol, Acol, npcol );
269 ARowSpan = ( Arow < 0 ) ||
278 AisD = ( ( Acol >= 0 ) && ( npcol > 1 ) );
280 Xinb = DESCX[
INB_ ]; Xnb = DESCX[
NB_ ];
281 Mfirstnb( Xinb1, N, JX, Xinb, Xnb );
288 if( ( !AisD && !XisD ) ||
289 ( ( AisD && XisD ) &&
290 ( ( Acol == Xcol ) &&
291 ( ( ( Ainb >= N ) && ( Xinb1 >= N ) ) ||
292 ( ( Ainb == Xinb1 ) && ( Anb == Xnb ) ) ) ) ) )
297 Ximb = DESCX[
IMB_ ]; Xmb = DESCX[
MB_ ];
298 Mfirstnb( Ximb1, K, IX, Ximb, Xmb );
300 if( XisR || ( !ARowSpan && ( Arow == Xrow ) ) )
310 if( ARowSpan || ( myrow == Arow ) )
311 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
317 MDescSet( DXA, K, N, K, Xinb1, 1, Xnb, ( ARowSpan ? -1 : Arow ),
332 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
334 TYPE->Cgebs2d( ctxt,
COLUMN, top, K, Anq, *XAPTR, Xld );
345 TYPE->Cgebr2d( ctxt,
COLUMN, top, K, Anq, *XAPTR, Xld,
349 PB_Cdescset( DXA, K, N, K, Xinb1, 1, Xnb, -1, Xcol, ctxt, Xld );
362 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
363 TYPE->Cgesd2d( ctxt, K, Anq, *XAPTR, Xld, Arow, mycol );
366 else if( myrow == Arow )
373 TYPE->Cgerv2d( ctxt, K, Anq, *XAPTR, Xld, Xrow, mycol );
376 PB_Cdescset( DXA, K, N, K, Xinb1, 1, Xnb, Arow, Xcol, ctxt,
385 PB_Cdescset( DXA, K, N, K, Ainb, 1, Anb, ( ARowSpan ? -1 : Arow ), Acol,
387 Xmp = ( ARowSpan ? K : ( ( myrow == Arow ) ? K : 0 ) );
388 if( Xmp > 0 && Anq > 0 )
395 PB_Cpaxpby(
TYPE, CONJUG, K, N,
TYPE->one, X, IX, JX, DESCX, XROC,
396 TYPE->zero, *XAPTR, 0, 0, DXA,
ROW );
400 PB_Cpaxpby(
TYPE, CONJUG, N, K,
TYPE->one, X, IX, JX, DESCX, XROC,
401 TYPE->zero, *XAPTR, 0, 0, DXA,
ROW );
409 Aimb = DESCA[
IMB_]; Amb = DESCA[
MB_];
410 Mnumroc( Amp, M, 0, Aimb, Amb, myrow, Arow, nprow );
414 AColSpan = ( Acol < 0 ) ||
423 AisD = ( ( Arow >= 0 ) && ( nprow > 1 ) );
425 Ximb = DESCX[
IMB_ ]; Xmb = DESCX[
MB_ ];
426 Mfirstnb( Ximb1, M, IX, Ximb, Xmb );
433 if( ( !AisD && !XisD ) ||
434 ( ( AisD && XisD ) &&
435 ( ( Arow == Xrow ) &&
436 ( ( ( Aimb >= M ) && ( Ximb1 >= M ) ) ||
437 ( ( Aimb == Ximb1 ) && ( Amb == Xmb ) ) ) ) ) )
442 Xinb = DESCX[
INB_ ]; Xnb = DESCX[
NB_ ];
443 Mfirstnb( Xinb1, K, JX, Xinb, Xnb );
445 if( XisR || ( !AColSpan && ( Acol == Xcol ) ) )
455 if( AColSpan || ( mycol == Acol ) )
456 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
462 MDescSet( DXA, M, K, Ximb1, K, Xmb, 1, Xrow,
463 ( AColSpan ? -1 : Acol ), ctxt, Xld );
477 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
479 TYPE->Cgebs2d( ctxt,
ROW, top, Amp, K, *XAPTR, Xld );
490 TYPE->Cgebr2d( ctxt,
ROW, top, Amp, K, *XAPTR, Xld, myrow,
494 PB_Cdescset( DXA, M, K, Ximb1, K, Xmb, 1, Xrow, -1, ctxt, Xld );
507 *XAPTR =
Mptr( X, Xii, Xjj, Xld,
TYPE->size );
508 TYPE->Cgesd2d( ctxt, Amp, K, *XAPTR, Xld, myrow, Acol );
511 else if( mycol == Acol )
518 TYPE->Cgerv2d( ctxt, Amp, K, *XAPTR, Xld, myrow, Xcol );
521 PB_Cdescset( DXA, M, K, Ximb1, K, Xmb, 1, Xrow, Acol, ctxt,
530 PB_Cdescset( DXA, M, K, Aimb, K, Amb, 1, Arow, ( AColSpan ? -1 : Acol ),
531 ctxt,
MAX( 1, Amp ) );
532 Xnq = ( AColSpan ? K : ( ( mycol == Acol ) ? K : 0 ) );
533 if( Xnq > 0 && Amp > 0 )
540 PB_Cpaxpby(
TYPE, CONJUG, K, M,
TYPE->one, X, IX, JX, DESCX, XROC,
545 PB_Cpaxpby(
TYPE, CONJUG, M, K,
TYPE->one, X, IX, JX, DESCX, XROC,