<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <span class="Apple-style-span" style="border-collapse: separate;
      color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style:
      normal; font-variant: normal; font-weight: normal; letter-spacing:
      normal; line-height: normal; orphans: 2; text-indent: 0px;
      text-transform: none; white-space: normal; widows: 2;
      word-spacing: 0px; font-size: medium;"><span
        class="Apple-style-span" style="font-family:
        Verdana,Arial,Helvetica,sans-serif; font-size: 11px;"></span></span>Noticed
    the small line at the end of the Matlab/min: "The min function
    ignores NaNs.". This is not written in the help page Scilab/min, but
    I guess that this is also true.<br>
    <br>
    Now, Matlab is more consistent :<br>
    <br>
    >> min([1 nan])<br>
    ans =<br>
         1<br>
    >> min(1,nan)<br>
    ans =<br>
         1<br>
    <br>
    while Scilab is weird :<br>
    <br>
    Scilab:<br>
    <br>
    -->min([1 %nan])<br>
     ans  =<br>
        1.  <br>
    -->min(1,%nan)<br>
     ans  =<br>
        Nan <br>
    <br>
    I think that you have found a 2 more bugs (that is, added with the
    bug #7608), i.e. :<br>
    1. nans are ignored by Scilab inside a matrix, but not across the
    input arguments,<br>
    2. this is not explicitely written in the help page. <br>
    I guess that the particular processing of Nans in the loop over the
    arguments has just been forgotten. <br>
    <br>
    Would you mind to submit these bug report please ?<br>
    <br>
    Best regards,<br>
    <br>
    Michaël Baudin<br>
    <br>
    Le 24/11/2010 11:54, Michaël Baudin a écrit :
    <blockquote cite="mid:4CECEEE1.9070503@scilab.org" type="cite">Ahah...
      <br>
      <br>
      In Scilab:
      <br>
      <br>
      -->min([1 2 3 %nan])
      <br>
       ans  =
      <br>
          1.
      <br>
      -->min(1,2,3,%nan)
      <br>
       ans  =
      <br>
          Nan
      <br>
      <br>
      This is fun...
      <br>
      <br>
      In Matlab:
      <br>
      <br>
      >> min([1 2 3 nan])
      <br>
      ans =
      <br>
           1
      <br>
      >> min(1,2,3,nan)
      <br>
      ??? Error using ==> min
      <br>
      Too many input arguments.
      <br>
      <br>
      So Matlab does not support the y=min(x1,x2,x3) calling sequence,
      but Scilab do. On the other hand, Scilab results are weird with
      nans, at least.
      <br>
      <br>
      Regards,
      <br>
      <br>
      Michaël
      <br>
      <br>
      Le 24/11/2010 11:47, Mathieu Dubois a écrit :
      <br>
      <blockquote type="cite">On 11/24/2010 11:40 AM, Michaël Baudin
        wrote:
        <br>
        <blockquote type="cite">Hi,
          <br>
          <br>
          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 :
          <br>
          <br>
          <a class="moz-txt-link-freetext" href="http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/elementary_functions/tests/unit_tests/IEEEcompatibility.tst;h=778fc00d4833f54fce6324ac917bac725d6f9e19;hb=HEAD">http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/elementary_functions/tests/unit_tests/IEEEcompatibility.tst;h=778fc00d4833f54fce6324ac917bac725d6f9e19;hb=HEAD</a>
          <br>
          <br>
          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".
          <br>
        </blockquote>
        That sounds like a sane convention but then, just out of
        curiosity, how do you explain that min([1 2 3 %nan])  returns 1?
        <br>
        <blockquote type="cite">
          <br>
          If you want to perform the computation without the nans, you
          may combine the "find" and "isnan" functions. For example, the
          statement:
          <br>
          <br>
          k = find(isnan(a))
          <br>
          <br>
          you get the indices where a is a nan. Now, the statement:
          <br>
          <br>
          a(isnan(a))=0
          <br>
          <br>
          sets to zero the entries where Nan is present.
          <br>
          <br>
          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.
          <br>
          <br>
          Best regards,
          <br>
          <br>
          Michaël Baudin
          <br>
          <br>
          Le 24/11/2010 10:11, Frederic Jourdin a écrit :
          <br>
          <blockquote type="cite">Hi all !
            <br>
            if I run this:
            <br>
            <br>
            a= [    1, %nan;    4,    4];
            <br>
            b= [ %nan,    3;    3,    6];
            <br>
            c= [    2,    2; %nan, %nan];
            <br>
            min( a, b, c)
            <br>
            <br>
            Scilab returns the following matrix:
            <br>
            NaN  NaN
            <br>
            NaN  NaN
            <br>
            <br>
            while the expected matrix should be:
            <br>
            1  2
            <br>
            3  4
            <br>
            <br>
            Why?
            <br>
            <br>
            thanks
            <br>
            Fred
            <br>
            <br>
            Scilab 5.3.0.beta3 on Linux
            <br>
            <br>
          </blockquote>
          <br>
          <br>
        </blockquote>
        <br>
      </blockquote>
      <br>
      <br>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Michaël Baudin
Ingénieur de développement
<a class="moz-txt-link-abbreviated" href="mailto:michael.baudin@scilab.org">michael.baudin@scilab.org</a>
-------------------------
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

</pre>
  </body>
</html>