14 #include "../PBpblas.h"
15 #include "../PBtools.h"
16 #include "../PBblacs.h"
17 #include "../PBblas.h"
21 int N,
char * ALPHA,
char * BETA,
char * A,
int IA,
24 void PB_Cplapd2(
TYPE, UPLO, CONJUG, M, N, ALPHA, BETA, A, IA, JA,
29 char * CONJUG, * UPLO;
44 int Acol, Aii, Aimb1, Ainb1, Aoffi, Ajj, Ald, Amb, Amp, Anb, Anq,
45 Aoffj, Arcol, Arow, Arrow, GoEast, GoSouth, iimax, ilow,
46 imbloc, inbloc, ioffd, iupp, izero=0, jjmax, joffd, lcmt,
47 lcmt00, lmbloc, lnbloc, low, lower, m1, mbloc, mblkd, mblks,
48 mycol, myrow, n1, nbloc, nblkd, nblks, npcol, nprow, pmb, qnb,
49 size, tmp1, upp, upper;
58 if( ( M <= 0 ) || ( N <= 0 ) )
return;
66 PB_Cainfog2l( M, N, IA, JA, DESCA, nprow, npcol, myrow, mycol, &Aimb1,
67 &Ainb1, &Amp, &Anq, &Aii, &Ajj, &Arow, &Acol, &Arrow, &Arcol );
71 if( ( Amp <= 0 ) || ( Anq <= 0 ) )
return;
76 Amb = DESCA[
MB_ ]; Anb = DESCA[
NB_ ]; Ald = DESCA[
LLD_];
77 PB_Cbinfo( 0, Amp, Anq, Aimb1, Ainb1, Amb, Anb, Arrow, Arcol, &lcmt00,
78 &mblks, &nblks, &imbloc, &inbloc, &lmbloc, &lnbloc, &ilow, &low,
81 iimax = ( Aoffi = Aii - 1 ) + ( m1 = Amp );
82 jjmax = ( Aoffj = Ajj - 1 ) + ( n1 = Anq );
83 pmb = ( ( ( Arow < 0 ) || ( nprow == 1 ) ) ? Amb : nprow * Amb );
84 qnb = ( ( ( Acol < 0 ) || ( npcol == 1 ) ) ? Anb : npcol * Anb );
86 size =
TYPE->size; pad =
TYPE->Ftzpad;
89 upper = ( UploA !=
CLOWER );
90 lower = ( UploA !=
CUPPER );
96 GoSouth = ( lcmt00 > iupp );
97 GoEast = ( lcmt00 < ilow );
101 if( ( !( GoSouth ) ) && ( !( GoEast ) ) )
107 ALPHA, BETA,
Mptr( A, Aii, Ajj, Ald, size ), &Ald );
113 GoSouth = !( GoEast = ( ( lcmt00 - ( iupp - upp + pmb ) ) < ilow ) );
122 if( upper && ( Anq > inbloc ) )
126 ALPHA, ALPHA,
Mptr( A, Aii, Ajj+inbloc, Ald, size ), &Ald );
138 if( lower && ( Amp > imbloc ) )
142 ALPHA, ALPHA,
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 ALPHA,
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;
193 ALPHA, BETA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
204 tmp1 = m1 - ioffd + Aii - 1;
205 if( lower && ( tmp1 > 0 ) )
207 ALPHA,
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 ALPHA,
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 ALPHA,
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;
269 ALPHA, BETA,
Mptr( A, Aii, joffd+1, Ald, size ), &Ald );
280 tmp1 = n1 - joffd + Ajj - 1;
281 if( upper && ( tmp1 > 0 ) )
283 ALPHA,
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 ALPHA,
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 ALPHA,
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;
345 BETA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
356 tmp1 = m1 - ioffd + Aii - 1;
357 if( lower && ( tmp1 > 0 ) )
359 ALPHA,
Mptr( A, ioffd+1, Aoffj+1, Ald, size ), &Ald );
361 tmp1 =
MIN( Aoffi, iimax ) - Aii + 1;
371 if( upper && ( tmp1 > 0 ) && ( n1 > 0 ) )
373 ALPHA,
Mptr( A, Aii, Aoffj+1, Ald, size ), &Ald );