[Scilab-users] Fix of bug #4953 (behavior of clean() with %inf)

Samuel Gougeon sgougeon at free.fr
Fri Jul 20 19:35:06 CEST 2018


Hello,

Le 28/06/2018 à 17:41, Stéphane Mottelet a écrit :
> Hello all,
>
> A fix proposal is under review @ 
> https://codereview.scilab.org/#/c/20204/2, in order to consider the 
> actual behavior of clean() when the argument has some infinite values:
>
> In Scilab 6.0.1:
>
>
> --> clean([%inf 1])
>  ans  =
>
>    0.   0.
>
> By a argument of continuity, since
>
> --> clean([1.79e308 1])
>  ans  =
>
>    1.79D+308   0.
>
> the fixed behavior would be
>
> --> clean([%inf 1])
>  ans  =
>
>    Inf   0.
>
> Please give your opinion if you feel concerned.


IMO, setting to  zero all finite values of an array as soon as one of 
them is %inf is abusive and counter-productive.
Let
--> A = 10.^grand(4,4,"unf",-10,5); A(2,2) = %inf;
  A  =
    4.3699094   0.0000014   0.67061     6.095D-09
    6503.1214   Inf         4.5767598   0.0006926
    20.907407   1.5687011   2.749D-08   0.0029886
    129.70759   1.102D-10   0.4564722   40.621591

The proposed implementation would lead to

--> clean(A)    //  A(abs(A)~=%inf & A==A)=0
  ans  =
    0.   0.    0.   0.
    0.   Inf   0.   0.
    0.   0.    0.   0.
    0.   0.    0.   0.

With that, no more processing or linear algebra can be done, just 
getting exclusively some zeros, %inf, and Nan.
The same can be done with A(abs(A)~=%inf) = 0. This is a poor and 
stopping result.

Instead, cleaning values *with respect to the max |finite| one* will yield

--> clean(A)     // B = A; A(abs(A)<max(A(abs(A)<%inf))*1e-10)=0
  A  =
    4.3699094   0.0000014   0.67061     0.
    6503.1214   Inf         4.5767598   0.0006926
    20.907407   1.5687011   0.          0.0029886
    129.70759   0.          0.4564722   40.621591

This result is a way richer. It still allows to work with it.

By the way, there is no /continuity/ from 1.79D+308 to %inf
An array may have all its |values| around and below the max 1.79D+308 by 
some small factors, then arithmetic can still be possible with them, and 
%inf will still be a special value with a special processing.

This is why i do not agree with the proposed clean() update.

Best regards
Samuel


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20180720/22b12bea/attachment.htm>


More information about the users mailing list