@@ -39,7 +39,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
39
#endif
40
40
41
41
#include "common.h"
42
-
42
+ #include <float.h>
43
43
44
44
#if defined (SKYLAKEX ) || defined (COOPERLAKE ) || defined (SAPPHIRERAPIDS )
45
45
#include "zscal_microk_skylakex-2.c"
@@ -222,12 +222,10 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,
222
222
223
223
if ( da_r == 0.0 )
224
224
{
225
-
226
225
BLASLONG n1 = n & -2 ;
227
226
228
227
if ( da_i == 0.0 )
229
228
{
230
-
231
229
while (j < n1 )
232
230
{
233
231
@@ -253,7 +251,6 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,
253
251
}
254
252
else
255
253
{
256
-
257
254
while (j < n1 )
258
255
{
259
256
@@ -356,49 +353,59 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,
356
353
357
354
alpha [0 ] = da_r ;
358
355
alpha [1 ] = da_i ;
359
-
356
+
360
357
if ( da_r == 0.0 )
361
358
if ( da_i == 0 )
362
359
zscal_kernel_8_zero (n1 , alpha , x );
363
360
else
364
- zscal_kernel_8_zero_r (n1 , alpha , x );
361
+ // zscal_kernel_8_zero_r(n1 , alpha , x);
362
+ zscal_kernel_8 (n1 , alpha , x );
365
363
else
366
- if ( da_i == 0 )
364
+ if ( da_i == 0 && da_r == da_r )
367
365
zscal_kernel_8_zero_i (n1 , alpha , x );
368
366
else
369
367
zscal_kernel_8 (n1 , alpha , x );
370
-
368
+ }
371
369
i = n1 << 1 ;
372
370
j = n1 ;
373
- }
374
-
375
-
376
- if ( da_r == 0.0 )
371
+
372
+ if ( da_r == 0.0 || da_r != da_r )
377
373
{
378
-
379
374
if ( da_i == 0.0 )
380
375
{
381
-
376
+ FLOAT res = 0.0 ;
377
+ if (da_r != da_r ) res = da_r ;
382
378
while (j < n )
383
379
{
384
-
385
- x [i ]= 0.0 ;
386
- x [i + 1 ]= 0.0 ;
380
+ x [i ]= res ;
381
+ x [i + 1 ]= res ;
387
382
i += 2 ;
388
383
j ++ ;
389
384
390
385
}
391
386
392
387
}
393
- else
388
+ else if (da_r < - FLT_MAX || da_r > FLT_MAX ) {
389
+ while (j < n )
390
+ {
391
+ x [i ]= SNAN ;
392
+ x [i + 1 ]= da_r ;
393
+ i += 2 ;
394
+ j ++ ;
395
+
396
+ }
397
+
398
+ } else
394
399
{
395
400
396
401
while (j < n )
397
402
{
398
-
399
403
temp0 = - da_i * x [i + 1 ];
404
+ if (x [i ] < - FLT_MAX || x [i ] > FLT_MAX )
405
+ temp0 = SNAN ;
400
406
x [i + 1 ] = da_i * x [i ];
401
- x [i ] = temp0 ;
407
+ if ( x [i ] == x [i ]) //preserve NaN
408
+ x [i ] = temp0 ;
402
409
i += 2 ;
403
410
j ++ ;
404
411
@@ -409,28 +416,24 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,
409
416
}
410
417
else
411
418
{
412
-
413
- if ( da_i == 0.0 )
419
+ if (da_i == 0.0 )
414
420
{
415
-
416
- while (j < n )
417
- {
421
+ while (j < n )
422
+ {
418
423
419
424
temp0 = da_r * x [i ];
420
425
x [i + 1 ] = da_r * x [i + 1 ];
421
426
x [i ] = temp0 ;
422
427
i += 2 ;
423
428
j ++ ;
424
429
425
- }
426
-
430
+ }
427
431
}
428
432
else
429
433
{
430
434
431
435
while (j < n )
432
436
{
433
-
434
437
temp0 = da_r * x [i ] - da_i * x [i + 1 ];
435
438
x [i + 1 ] = da_r * x [i + 1 ] + da_i * x [i ];
436
439
x [i ] = temp0 ;
@@ -445,5 +448,3 @@ int CNAME(BLASLONG n, BLASLONG dummy0, BLASLONG dummy1, FLOAT da_r, FLOAT da_i,
445
448
446
449
return (0 );
447
450
}
448
-
449
-
0 commit comments