14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 char * UPLO,
int N,
int K,
char * ALPHA,
char * A,
22 int IA,
int JA,
int * DESCA,
char * XC,
int LDXC,
23 char * XR,
int LDXR,
char * YC,
int LDYC,
char * YR,
26 void PB_Cpsym(
TYPE, UTYP, SIDE, UPLO, N, K, ALPHA, A, IA, JA, DESCA,
27 XC, LDXC, XR, LDXR, YC, LDYC, YR, LDYR, SYM )
32 int IA, JA, K, LDXC, LDXR, LDYC, LDYR, N;
40 char * A, * XC, * XR, * YC, * YR;
237 int Acol, Arow, Aii, Aimb1, Ainb1, Ajj, Ald, Amp, Amb, Anb, Anq,
238 Aoffi, Aoffj, Arcol, Arrow, GoEast, GoSouth, IsColRepl,
239 IsRowRepl, XCinc, XRinc, Xii=0, Xjj=0, Xoffi=-1, Xoffj=-1,
240 YCinc, YRinc, iimax, ilow, imbloc, inbloc, ioffd, ioffx, iupp,
241 jjmax, joffd, joffx, lcmt, lcmt00, lmbloc, lnbloc, low, lower,
242 m1, mbloc, mblkd, mblks, mycol, myrow, n1, nbloc, nblkd,
243 nblks, npcol, nprow, pmb, qnb, size, tmp1, upp, upper;
259 PB_Cainfog2l( N, N, IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aimb1,
260 &Ainb1, &Amp, &Anq, &Aii, &Ajj, &Arow, &Acol, &Arrow, &Arcol );
265 if( ( Amp <= 0 ) || ( Anq <= 0 ) )
return;
267 IsRowRepl = ( ( Arow < 0 ) || ( nprow == 1 ) );
268 IsColRepl = ( ( Acol < 0 ) || ( npcol == 1 ) );
269 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ]; Ald = DESCA[
LLD_ ];
272 if( IsRowRepl && IsColRepl )
274 SYM(
TYPE, SIDE, UPLO, Amp, Anq, K, 0, ALPHA,
Mptr( A, Aii, Ajj, Ald,
275 size ), Ald, XC, LDXC, XR, LDXR, YC, LDYC, YR, LDYR );
279 XCinc = size; XRinc = LDXR * size;
280 YCinc = UTYP->
size; YRinc = LDYR * UTYP->
size;
287 PB_Cbinfo( 0, Amp, Anq, Aimb1, Ainb1, Amb, Anb, Arrow, Arcol, &lcmt00,
288 &mblks, &nblks, &imbloc, &inbloc, &lmbloc, &lnbloc, &ilow, &low,
291 iimax = ( Aoffi = Aii - 1 ) + ( m1 = Amp );
292 jjmax = ( Aoffj = Ajj - 1 ) + ( n1 = Anq );
293 pmb = ( IsRowRepl ? Amb : nprow * Amb );
294 qnb = ( IsColRepl ? Anb : npcol * Anb );
300 GoSouth = ( lcmt00 > iupp );
301 GoEast = ( lcmt00 < ilow );
305 if( ( !( GoSouth ) ) && ( !( GoEast ) ) )
310 SYM(
TYPE, SIDE, UPLO, imbloc, inbloc, K, lcmt00, ALPHA,
Mptr( A, Aii,
311 Ajj, Ald, size ), Ald, XC+Xii*XCinc, LDXC, XR+Xjj*XRinc, LDXR,
312 YC+Xii*YCinc, LDYC, YR+Xjj*YRinc, LDYR );
318 GoSouth = !( GoEast = ( ( lcmt00 - ( iupp - upp + pmb ) ) < ilow ) );
327 if( upper && ( Anq > inbloc ) )
330 SYM(
TYPE, SIDE,
ALL, imbloc, tmp1, K, 0,
331 ALPHA,
Mptr( A, Aii, Ajj+inbloc, Ald, size ), Ald,
332 XC+Xii*XCinc, LDXC, XR+(Xjj+inbloc)*XRinc, LDXR,
333 YC+Xii*YCinc, LDYC, YR+(Xjj+inbloc)*YRinc, LDYR );
335 Aii += imbloc; Xii += imbloc; m1 -= imbloc;
344 if( lower && ( Amp > imbloc ) )
347 SYM(
TYPE, SIDE,
ALL, tmp1, inbloc, K, 0,
348 ALPHA,
Mptr( A, Aii+imbloc, Ajj, Ald, size ), Ald,
349 XC+(Xii+imbloc)*XCinc, LDXC, XR+Xjj*XRinc, LDXR,
350 YC+(Xii+imbloc)*YCinc, LDYC, YR+Xjj*YRinc, LDYR );
352 Ajj += inbloc; Xjj += inbloc; n1 -= inbloc;
362 lcmt00 -= ( iupp - upp + pmb ); mblks--;
363 Aoffi += imbloc; Xoffi += imbloc;
368 while( ( mblks > 0 ) && ( lcmt00 > upp ) )
369 { lcmt00 -= pmb; mblks--; Aoffi += Amb; Xoffi += Amb; }
374 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
375 if( upper && ( tmp1 > 0 ) )
377 SYM(
TYPE, SIDE,
ALL, tmp1, n1, K, 0,
378 ALPHA,
Mptr( A, Aii, Aoffj+1, Ald, size ), Ald,
379 XC+Xii*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
380 YC+Xii*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
381 Aii += tmp1; Xii += tmp1; m1 -= tmp1;
386 if( mblks <= 0 )
return;
393 lcmt = lcmt00; mblkd = mblks; ioffd = Aoffi; ioffx = Xoffi;
396 while( ( mblkd > 0 ) && ( lcmt >= ilow ) )
401 if( mblkd == 1 ) mbloc = lmbloc;
402 SYM(
TYPE, SIDE, UPLO, mbloc, inbloc, K, lcmt,
403 ALPHA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), Ald,
404 XC+(ioffx+1)*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
405 YC+(ioffx+1)*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
406 lcmt00 = lcmt; lcmt -= pmb;
407 mblks = mblkd; mblkd--;
408 Aoffi = ioffd; ioffd += mbloc;
409 Xoffi = ioffx; ioffx += mbloc;
414 tmp1 = m1 - ioffd + Aii - 1;
415 if( lower && ( tmp1 > 0 ) )
416 SYM(
TYPE, SIDE,
ALL, tmp1, inbloc, K, 0,
417 ALPHA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), Ald,
418 XC+(ioffx+1)*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
419 YC+(ioffx+1)*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
421 tmp1 = Aoffi - Aii + 1;
424 lcmt00 += low - ilow + qnb;
431 if( upper && ( tmp1 > 0 ) && ( n1 > 0 ) )
432 SYM(
TYPE, SIDE,
ALL, tmp1, n1, K, 0,
433 ALPHA,
Mptr( A, Aii, Aoffj+1, Ald, size ), Ald,
434 XC+Xii*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
435 YC+Xii*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
436 Aii = Aoffi + 1; Ajj = Aoffj + 1;
437 Xii = Xoffi + 1; Xjj = Xoffj + 1;
445 lcmt00 += low - ilow + qnb; nblks--;
446 Aoffj += inbloc; Xoffj += inbloc;
451 while( ( nblks > 0 ) && ( lcmt00 < low ) )
452 { lcmt00 += qnb; nblks--; Aoffj += Anb; Xoffj += Anb; }
456 tmp1 =
MIN( Aoffj, jjmax ) - Ajj + 1;
457 if( lower && ( tmp1 > 0 ) )
459 SYM(
TYPE, SIDE,
ALL, m1, tmp1, K, 0,
460 ALPHA,
Mptr( A, Aii, Ajj, Ald, size ), Ald,
461 XC+Xii*XCinc, LDXC, XR+Xjj*XRinc, LDXR,
462 YC+Xii*YCinc, LDYC, YR+Xjj*YRinc, LDYR );
463 Ajj += tmp1; Xjj += tmp1; n1 -= tmp1;
468 if( nblks <= 0 )
return;
475 lcmt = lcmt00; nblkd = nblks; joffd = Aoffj; joffx = Xoffj;
478 while( ( nblkd > 0 ) && ( lcmt <= iupp ) )
483 if( nblkd == 1 ) nbloc = lnbloc;
484 SYM(
TYPE, SIDE, UPLO, imbloc, nbloc, K, lcmt,
485 ALPHA,
Mptr( A, Aii, joffd+1, Ald, size ), Ald,
486 XC+Xii*XCinc, LDXC, XR+(joffx+1)*XRinc, LDXR,
487 YC+Xii*YCinc, LDYC, YR+(joffx+1)*YRinc, LDYR );
488 lcmt00 = lcmt; lcmt += qnb;
489 nblks = nblkd; nblkd--;
490 Aoffj = joffd; joffd += nbloc;
491 Xoffj = joffx; joffx += nbloc;
496 tmp1 = n1 - joffd + Ajj - 1;
497 if( upper && ( tmp1 > 0 ) )
498 SYM(
TYPE, SIDE,
ALL, imbloc, tmp1, K, 0,
499 ALPHA,
Mptr( A, Aii, joffd+1, Ald, size ), Ald,
500 XC+Xii*XCinc, LDXC, XR+(joffx+1)*XRinc, LDXR,
501 YC+Xii*YCinc, LDYC, YR+(joffx+1)*YRinc, LDYR );
503 tmp1 = Aoffj - Ajj + 1;
506 lcmt00 -= ( iupp - upp + pmb );
513 if( lower && ( m1 > 0 ) && ( tmp1 > 0 ) )
514 SYM(
TYPE, SIDE,
ALL, m1, tmp1, K, 0,
515 ALPHA,
Mptr( A, Aoffi+1, Ajj, Ald, size ), Ald,
516 XC+(Xoffi+1)*XCinc, LDXC, XR+Xjj*XRinc, LDXR,
517 YC+(Xoffi+1)*YCinc, LDYC, YR+Xjj*YRinc, LDYR );
518 Aii = Aoffi + 1; Ajj = Aoffj + 1;
519 Xii = Xoffi + 1; Xjj = Xoffj + 1;
527 if( nblks == 1 ) nbloc = lnbloc;
532 while( ( mblks > 0 ) && ( lcmt00 > upp ) )
533 { lcmt00 -= pmb; mblks--; Aoffi += Amb; Xoffi += Amb; }
537 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
538 if( upper && ( tmp1 > 0 ) )
540 SYM(
TYPE, SIDE,
ALL, tmp1, n1, K, 0,
541 ALPHA,
Mptr( A, Aii, Aoffj+1, Ald, size ), Ald,
542 XC+Xii*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
543 YC+Xii*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
551 if( mblks <= 0 )
return;
558 lcmt = lcmt00; mblkd = mblks; ioffd = Aoffi; ioffx = Xoffi;
561 while( ( mblkd > 0 ) && ( lcmt >= low ) )
566 if( mblkd == 1 ) mbloc = lmbloc;
567 SYM(
TYPE, SIDE, UPLO, mbloc, nbloc, K, lcmt,
568 ALPHA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), Ald,
569 XC+(ioffx+1)*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
570 YC+(ioffx+1)*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
571 lcmt00 = lcmt; lcmt -= pmb;
572 mblks = mblkd; mblkd--;
573 Aoffi = ioffd; Xoffi = ioffx;
574 ioffd += mbloc; ioffx += mbloc;
579 tmp1 = m1 - ioffd + Aii - 1;
580 if( lower && ( tmp1 > 0 ) )
581 SYM(
TYPE, SIDE,
ALL, tmp1, nbloc, K, 0,
582 ALPHA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), Ald,
583 XC+(ioffx+1)*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
584 YC+(ioffx+1)*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
586 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
596 if( upper && ( tmp1 > 0 ) && ( n1 > 0 ) )
597 SYM(
TYPE, SIDE,
ALL, tmp1, n1, K, 0,
598 ALPHA,
Mptr( A, Aii, Aoffj+1, Ald, size ), Ald,
599 XC+Xii*XCinc, LDXC, XR+(Xoffj+1)*XRinc, LDXR,
600 YC+Xii*YCinc, LDYC, YR+(Xoffj+1)*YRinc, LDYR );
601 Aii = Aoffi + 1; Ajj = Aoffj + 1;
602 Xii = Xoffi + 1; Xjj = Xoffj + 1;