20 void pdnrm2_(
int * N,
double * NORM2,
21 double * X,
int * IX,
int * JX,
int * DESCX,
int * INCX )
23 void pdnrm2_( N, NORM2, X, IX, JX, DESCX, INCX )
27 int * INCX, * IX, * JX, * N;
176 int Xcol, Xi, Xii, Xj, Xjj, Xld, Xnp, Xnq, Xrow, ctxt, dst, dist,
177 info, k, mycol, mydist, myrow, npcol, nprow, src;
178 double scale, ssq, temp1, temp2;
183 double * Xptr = NULL, work[4];
194 if( !( info = ( ( nprow == -1 ) ? -( 601 +
CTXT_ ) : 0 ) ) )
195 PB_Cchkvec( ctxt,
"PDNRM2",
"X", *N, 1, Xi, Xj, Xd, *INCX, 6, &info );
196 if( info ) {
PB_Cabort( ctxt,
"PDNRM2", info );
return; }
205 if( *N == 0 )
return;
215 PB_Cinfog2l( Xi, Xj, Xd, nprow, npcol, myrow, mycol, &Xii, &Xjj,
220 if( ( *N == 1 ) && ( *INCX == 1 ) && ( Xd[
M_] == 1 ) )
225 if( ( ( myrow == Xrow ) || ( Xrow < 0 ) ) &&
226 ( ( mycol == Xcol ) || ( Xcol < 0 ) ) )
227 *NORM2 =
ABS( X[Xii+Xjj*Xd[
LLD_]] );
230 else if( *INCX == Xd[
M_] )
235 if( ( myrow == Xrow ) || ( Xrow < 0 ) )
249 Xptr = X+(Xii+Xjj*Xld);
251 for( k = 0; k < Xnq; k++ )
255 temp1 =
ABS( *Xptr );
258 temp2 = scale / temp1;
259 ssq =
ONE + ssq * ( temp2 * temp2 );
264 temp2 = temp1 / scale;
265 ssq = ssq + ( temp2 * temp2 );
274 if( ( npcol >= 2 ) && ( Xcol >= 0 ) )
288 dist = k * ( mydist - 1 );
290 Cdgesd2d( ctxt, 2, 1, ((
char*) work), 2, myrow, dst );
300 Cdgerv2d( ctxt, 2, 1, ((
char*)&work[2]), 2, myrow, src );
301 if( work[0] >= work[2] )
303 if( work[0] !=
ZERO )
305 temp1 = work[2] / work[0];
306 work[1] = work[1] + ( temp1 * temp1 ) * work[3];
311 temp1 = work[0] / work[2];
312 work[1] = work[3] + ( temp1 * temp1 ) * work[1];
320 if( k < npcol )
goto l_10;
329 Cdgebs2d( ctxt,
ROW, &top, 2, 1, ((
char*)work), 2 );
339 dasqrtb_( &work[0], &work[1], NORM2 );
356 if( ( mycol == Xcol ) || ( Xcol < 0 ) )
369 Xptr = X+(Xii+Xjj*Xd[
LLD_]);
371 for( k = 0; k < Xnp; k++ )
375 temp1 =
ABS( *Xptr );
378 temp2 = scale / temp1;
379 ssq =
ONE + ssq * ( temp2 * temp2 );
384 temp2 = temp1 / scale;
385 ssq = ssq + ( temp2 * temp2 );
394 if( ( nprow >= 2 ) && ( Xrow >= 0 ) )
408 dist = k * ( mydist - 1 );
410 Cdgesd2d( ctxt, 2, 1, ((
char*)work), 2, dst, mycol );
420 Cdgerv2d( ctxt, 2, 1, ((
char*)&work[2]), 2, src, mycol );
421 if( work[0] >= work[2] )
423 if( work[0] !=
ZERO )
425 temp1 = work[2] / work[0];
426 work[1] = work[1] + ( temp1 * temp1 ) * work[3];
431 temp1 = work[0] / work[2];
432 work[1] = work[3] + ( temp1 * temp1 ) * work[1];
440 if( k < nprow )
goto l_30;
459 dasqrtb_( &work[0], &work[1], NORM2 );