[scilab-Users] min/max with NaN values
Michaël Baudin
michael.baudin at scilab.org
Wed Nov 24 11:49:48 CET 2010
See also my message at :
http://bugzilla.scilab.org/show_bug.cgi?id=7608#c6
on the more specific topic of Scilab/nanmin.
Best regards,
Michaël
Le 24/11/2010 11:40, Michaël Baudin a écrit :
> Hi,
>
> The expected result is actually the matrix of Nans. If you had found
> another result, that would have been a bug. Even more, we have similar
> automatic checks that this is so - see the following unit test :
>
> http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/elementary_functions/tests/unit_tests/IEEEcompatibility.tst;h=778fc00d4833f54fce6324ac917bac725d6f9e19;hb=HEAD
>
>
> Notice that this test is mainly for +,-,*,/,sqrt, the operations which
> are specified by the IEEE754 standard. With respect to Nan, these
> tests says that "Nan on input, then Nan on output". In the IEEE754
> standard, the authors use the term "Nan propagation". More
> informations on this topic are given by "Handbook of Floating Point
> Arithmetic", by Muller et al.. See the sections "2.3 - Exceptions" and
> "3.1.5 Exceptions specified by IEEE754-1985".
>
> If you want to perform the computation without the nans, you may
> combine the "find" and "isnan" functions. For example, the statement:
>
> k = find(isnan(a))
>
> you get the indices where a is a nan. Now, the statement:
>
> a(isnan(a))=0
>
> sets to zero the entries where Nan is present.
>
> But be warned: Nans are *designed* to be propagated. That is, if your
> input data contains Nans, that means that some previous computations
> has already failed. The Nans should not be, in general, just ignored
> and thrown away.
>
> Best regards,
>
> Michaël Baudin
>
> Le 24/11/2010 10:11, Frederic Jourdin a écrit :
>> Hi all !
>> if I run this:
>>
>> a= [ 1, %nan; 4, 4];
>> b= [ %nan, 3; 3, 6];
>> c= [ 2, 2; %nan, %nan];
>> min( a, b, c)
>>
>> Scilab returns the following matrix:
>> NaN NaN
>> NaN NaN
>>
>> while the expected matrix should be:
>> 1 2
>> 3 4
>>
>> Why?
>>
>> thanks
>> Fred
>>
>> Scilab 5.3.0.beta3 on Linux
>>
>
>
--
Michaël Baudin
Ingénieur de développement
michael.baudin at scilab.org
-------------------------
Consortium Scilab - Digiteo
Domaine de Voluceau - Rocquencourt
B.P. 105 - 78153 Le Chesnay Cedex
Tel. : 01 39 63 56 87 - Fax : 01 39 63 55 94
More information about the users
mailing list