14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 int N,
char * ALPHA,
char * A,
int IA,
int JA,
28 char * CONJUG, * UPLO;
43 int Acol, Arow, Aii, iimax, ilow, imbloc, Aimb1, inbloc, Ainb1,
44 Aoffi, GoEast, GoSouth, ioffd, iupp, izero=0, Ajj, jjmax,
45 Aoffj, joffd, lcmt, lcmt00, Ald, lmbloc, lnbloc, low, lower,
46 m1, Amb, mbloc, mblkd, mblks, Amp, Arcol, Arrow, mycol, myrow,
47 n1, Anb, nbloc, nblkd, nblks, npcol, nprow, Anq, pmb, qnb,
48 size, tmp1, upp, upper;
57 if( ( M <= 0 ) || ( N <= 0 ) )
return;
65 PB_Cainfog2l( M, N, IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aimb1,
66 &Ainb1, &Amp, &Anq, &Aii, &Ajj, &Arow, &Acol, &Arrow, &Arcol );
70 if( ( Amp <= 0 ) || ( Anq <= 0 ) )
return;
75 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ]; Ald = DESCA[
LLD_];
76 PB_Cbinfo( 0, Amp, Anq, Aimb1, Ainb1, Amb, Anb, Arrow, Arcol, &lcmt00,
77 &mblks, &nblks, &imbloc, &inbloc, &lmbloc, &lnbloc, &ilow, &low,
79 iimax = ( Aoffi = Aii - 1 ) + ( m1 = Amp );
80 jjmax = ( Aoffj = Ajj - 1 ) + ( n1 = Anq );
81 pmb = ( ( ( Arow < 0 ) || ( nprow == 1 ) ) ? Amb : nprow * Amb );
82 qnb = ( ( ( Acol < 0 ) || ( npcol == 1 ) ) ? Anb : npcol * Anb );
85 upper = ( UploA !=
CLOWER );
86 lower = ( UploA !=
CUPPER );
96 GoSouth = ( lcmt00 > iupp );
97 GoEast = ( lcmt00 < ilow );
101 if( ( !( GoSouth ) ) && ( !( GoEast ) ) )
106 scal(
C2F_CHAR( UPLO ), &imbloc, &inbloc, &lcmt00, ALPHA,
107 Mptr( A, Aii, Ajj, Ald, size ), &Ald );
113 GoSouth = !( GoEast = ( ( lcmt00 - ( iupp - upp + pmb ) ) < ilow ) );
122 if( upper && ( Anq > inbloc ) )
125 scal(
C2F_CHAR(
ALL ), &imbloc, &tmp1, &izero, ALPHA,
126 Mptr( A, Aii, Ajj+inbloc, Ald, size ), &Ald );
138 if( lower && ( Amp > imbloc ) )
141 scal(
C2F_CHAR(
ALL ), &tmp1, &inbloc, &izero, ALPHA,
142 Mptr( A, Aii+imbloc, Ajj, Ald, size ), &Ald );
155 lcmt00 -= ( iupp - upp + pmb ); mblks--; Aoffi += imbloc;
160 while( ( mblks > 0 ) && ( lcmt00 > upp ) )
161 { lcmt00 -= pmb; mblks--; Aoffi += Amb; }
165 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
166 if( upper && ( tmp1 > 0 ) )
169 Mptr( A, Aii, Aoffj+1, Ald, size ), &Ald );
176 if( mblks <= 0 )
return;
183 lcmt = lcmt00; mblkd = mblks; ioffd = Aoffi;
186 while( ( mblkd > 0 ) && ( lcmt >= ilow ) )
191 if( mblkd == 1 ) mbloc = lmbloc;
192 scal(
C2F_CHAR( UPLO ), &mbloc, &inbloc, &lcmt, ALPHA,
193 Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
204 tmp1 = m1 - ioffd + Aii - 1;
205 if( lower && ( tmp1 > 0 ) )
206 scal(
C2F_CHAR(
ALL ), &tmp1, &inbloc, &izero, ALPHA,
207 Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
209 tmp1 = Aoffi - Aii + 1;
212 lcmt00 += low - ilow + qnb;
219 if( upper && ( tmp1 > 0 ) && ( n1 > 0 ) )
221 Mptr( A, Aii, Aoffj+1, Ald, size ), &Ald );
231 lcmt00 += low - ilow + qnb; nblks--; Aoffj += inbloc;
236 while( ( nblks > 0 ) && ( lcmt00 < low ) )
237 { lcmt00 += qnb; nblks--; Aoffj += Anb; }
241 tmp1 =
MIN( Aoffj, jjmax ) - Ajj + 1;
242 if( lower && ( tmp1 > 0 ) )
245 Mptr( A, Aii, Ajj, Ald, size ), &Ald );
252 if( nblks <= 0 )
return;
259 lcmt = lcmt00; nblkd = nblks; joffd = Aoffj;
262 while( ( nblkd > 0 ) && ( lcmt <= iupp ) )
267 if( nblkd == 1 ) nbloc = lnbloc;
268 scal(
C2F_CHAR( UPLO ), &imbloc, &nbloc, &lcmt, ALPHA,
269 Mptr( A, Aii, joffd+1, Ald, size ), &Ald );
280 tmp1 = n1 - joffd + Ajj - 1;
281 if( upper && ( tmp1 > 0 ) )
282 scal(
C2F_CHAR(
ALL ), &imbloc, &tmp1, &izero, ALPHA,
283 Mptr( A, Aii, joffd+1, Ald, size ), &Ald );
285 tmp1 = Aoffj - Ajj + 1;
288 lcmt00 -= ( iupp - upp + pmb );
295 if( lower && ( m1 > 0 ) && ( tmp1 > 0 ) )
297 Mptr( A, Aoffi+1, Ajj, Ald, size ), &Ald );
307 if( nblks == 1 ) nbloc = lnbloc;
312 while( ( mblks > 0 ) && ( lcmt00 > upp ) )
313 { lcmt00 -= pmb; mblks--; Aoffi += Amb; }
317 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
318 if( upper && ( tmp1 > 0 ) )
321 Mptr( A, Aii, Aoffj+1, Ald, size ), &Ald );
328 if( mblks <= 0 )
return;
335 lcmt = lcmt00; mblkd = mblks; ioffd = Aoffi;
338 while( ( mblkd > 0 ) && ( lcmt >= low ) )
343 if( mblkd == 1 ) mbloc = lmbloc;
344 scal(
C2F_CHAR( UPLO ), &mbloc, &nbloc, &lcmt, ALPHA,
345 Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
356 tmp1 = m1 - ioffd + Aii - 1;
357 if( lower && ( tmp1 > 0 ) )
358 scal(
C2F_CHAR(
ALL ), &tmp1, &nbloc, &izero, ALPHA,
359 Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
361 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
371 if( upper && ( tmp1 > 0 ) && ( n1 > 0 ) )
373 Mptr( A, Aii, Aoffj+1, Ald, size ), &Ald );