35{
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175 char top;
176 Int Xcol, Xi, Xii, Xj, Xjj, Xld, Xnp, Xnq, Xrow, ctxt, dst, dist,
177 info, k, mycol, mydist, myrow, npcol, nprow, src;
178 float scale, ssq, temp1, temp2;
179
180
181
183 float * Xptr = NULL, work[4];
184
185
186
187
189#ifndef NO_ARGCHK
190
191
192
194 if( !( info = ( ( nprow == -1 ) ? -( 601 +
CTXT_ ) : 0 ) ) )
195 PB_Cchkvec( ctxt,
"PSNRM2",
"X", *N, 1, Xi, Xj, Xd, *INCX, 6, &info );
196 if( info ) {
PB_Cabort( ctxt,
"PSNRM2", info );
return; }
197#endif
198
199
200
202
203
204
205 if( *N == 0 ) return;
206
207
208
209#ifdef NO_ARGCHK
211#endif
212
213
214
215 PB_Cinfog2l( Xi, Xj, Xd, nprow, npcol, myrow, mycol, &Xii, &Xjj,
216 &Xrow, &Xcol );
217
218
219
220 if( ( *N == 1 ) && ( *INCX == 1 ) && ( Xd[
M_] == 1 ) )
221 {
222
223
224
225 if( ( ( myrow == Xrow ) || ( Xrow < 0 ) ) &&
226 ( ( mycol == Xcol ) || ( Xcol < 0 ) ) )
228 return;
229 }
230 else if( *INCX == Xd[
M_] )
231 {
232
233
234
235 if( ( myrow == Xrow ) || ( Xrow < 0 ) )
236 {
237
238
239
242
243
244
246 if( Xnq > 0 )
247 {
249 Xptr =
Mptr(X,Xii,Xjj,Xld,1);
250
251 for( k = 0; k < Xnq; k++ )
252 {
254 {
255 temp1 =
ABS( *Xptr );
256 if( scale < temp1 )
257 {
258 temp2 = scale / temp1;
259 ssq =
ONE + ssq * ( temp2 * temp2 );
260 scale = temp1;
261 }
262 else
263 {
264 temp2 = temp1 / scale;
265 ssq = ssq + ( temp2 * temp2 );
266 }
267 }
268 Xptr += Xld;
269 }
270 }
271
272
273
274 if( ( npcol >= 2 ) && ( Xcol >= 0 ) )
275 {
276
277
278
279
280 work[0] = scale;
281 work[1] = ssq;
282
283 mydist = mycol;
284 k = 1;
285l_10:
286 if( mydist & 1 )
287 {
288 dist = k * ( mydist - 1 );
290 Csgesd2d( ctxt, 2, 1, ((
char*) work), 2, myrow, dst );
291 goto l_20;
292 }
293 else
294 {
295 dist = mycol + k;
297
298 if( mycol < src )
299 {
300 Csgerv2d( ctxt, 2, 1, ((
char*)&work[2]), 2, myrow, src );
301 if( work[0] >= work[2] )
302 {
303 if( work[0] !=
ZERO )
304 {
305 temp1 = work[2] / work[0];
306 work[1] = work[1] + ( temp1 * temp1 ) * work[3];
307 }
308 }
309 else
310 {
311 temp1 = work[0] / work[2];
312 work[1] = work[3] + ( temp1 * temp1 ) * work[1];
313 work[0] = work[2];
314 }
315 }
316 mydist >>= 1;
317 }
318 k <<= 1;
319
320 if( k < npcol ) goto l_10;
321l_20:
322
323
324
325
327 if( mycol == 0 )
328 {
329 Csgebs2d( ctxt,
ROW, &top, 2, 1, ((
char*)work), 2 );
330 }
331 else
332 {
334 myrow, 0 );
335 }
336
337
338
339 sasqrtb_( &work[0], &work[1], NORM2 );
340 }
341 else
342 {
343
344
345
347 }
348 }
349 return;
350 }
351 else
352 {
353
354
355
356 if( ( mycol == Xcol ) || ( Xcol < 0 ) )
357 {
358
359
360
363
364
365
367 if( Xnp > 0 )
368 {
370
371 for( k = 0; k < Xnp; k++ )
372 {
374 {
375 temp1 =
ABS( *Xptr );
376 if( scale < temp1 )
377 {
378 temp2 = scale / temp1;
379 ssq =
ONE + ssq * ( temp2 * temp2 );
380 scale = temp1;
381 }
382 else
383 {
384 temp2 = temp1 / scale;
385 ssq = ssq + ( temp2 * temp2 );
386 }
387 }
388 Xptr++;
389 }
390 }
391
392
393
394 if( ( nprow >= 2 ) && ( Xrow >= 0 ) )
395 {
396
397
398
399
400 work[0] = scale;
401 work[1] = ssq;
402
403 mydist = myrow;
404 k = 1;
405l_30:
406 if( mydist & 1 )
407 {
408 dist = k * ( mydist - 1 );
410 Csgesd2d( ctxt, 2, 1, ((
char*)work), 2, dst, mycol );
411 goto l_40;
412 }
413 else
414 {
415 dist = myrow + k;
417
418 if( myrow < src )
419 {
420 Csgerv2d( ctxt, 2, 1, ((
char*)&work[2]), 2, src, mycol );
421 if( work[0] >= work[2] )
422 {
423 if( work[0] !=
ZERO )
424 {
425 temp1 = work[2] / work[0];
426 work[1] = work[1] + ( temp1 * temp1 ) * work[3];
427 }
428 }
429 else
430 {
431 temp1 = work[0] / work[2];
432 work[1] = work[3] + ( temp1 * temp1 ) * work[1];
433 work[0] = work[2];
434 }
435 }
436 mydist >>= 1;
437 }
438 k <<= 1;
439
440 if( k < nprow ) goto l_30;
441l_40:
442
443
444
445
447 if( myrow == 0 )
448 {
450 }
451 else
452 {
454 0, mycol );
455 }
456
457
458
459 sasqrtb_( &work[0], &work[1], NORM2 );
460 }
461 else
462 {
463
464
465
467 }
468 }
469 return;
470 }
471
472
473
474}