* Bug #14648 fixed - isinf(%inf+%i*%inf)) and isinf(%nan+%i%inf) returned %F 40/18340/5
Samuel GOUGEON [Fri, 1 Jul 2016 23:58:23 +0000 (01:58 +0200)]
  http://bugzilla.scilab.org/14648
  help isinf overhauled

Change-Id: I008e0935e03a3abe4f7c2f9f738d7e006ba7f476

scilab/CHANGES.md
scilab/modules/elementary_functions/help/en_US/floating_point/isinf.xml
scilab/modules/elementary_functions/help/fr_FR/floating_point/isinf.xml
scilab/modules/elementary_functions/help/ja_JP/floating_point/isinf.xml [deleted file]
scilab/modules/elementary_functions/help/pt_BR/floating_point/isinf.xml [deleted file]
scilab/modules/elementary_functions/help/ru_RU/floating_point/isinf.xml
scilab/modules/elementary_functions/macros/isinf.sci
scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.dia.ref [new file with mode: 0644]
scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.tst [new file with mode: 0644]

index 044c989..fc8d746 100644 (file)
@@ -148,13 +148,13 @@ Help pages:
 
 * fixed / improved:  `members`, `part`, `ode`, `ode_optional_output`, `ode_roots`, `roots`,
   `printf`, `sprintf`, `iconvert`, `stdev`, `xlabel`
-* rewritten: `consolebox`, `double`, `isoview`, `householder`, `or`, `and`, `format`, `typeof`, `brackets`
+* rewritten: `consolebox`, `double`, `isoview`, `householder`, `or`, `and`, `format`, `typeof`, `brackets`, `setlanguage`, `sleep`, `isinf`
 * reorganized:
   - `else`, `elseif`, `end`, `try`, `sciargs`, `global`, `halt`, `empty`, `power`
   - CACSD and Signal Processing help pages have been sorted up.
   - Colormaps and GUI/Menus subsections created
 * translations added:
-  - (fr): `format`, `typeof`, `isoview`, `ndgrid`, `bench_run`, `consolebox`, `harmean`
+  - (fr): `format`, `typeof`, `isoview`, `ndgrid`, `bench_run`, `consolebox`, `harmean`, `sleep`
   - (ru): homepage
 
 
@@ -256,9 +256,9 @@ Bug Fixes
 * [Bug #14590](http://bugzilla.scilab.org/show_bug.cgi?id=14590) fixed - Help pages in pt_BR directories had a wrong xml:lang="en" tag.
 * [Bug #14593](http://bugzilla.scilab.org/show_bug.cgi?id=14593) fixed - Signs are no more drawn in BIGSOM and PRODUCT components.
 * [Bug #14602](http://bugzilla.scilab.org/show_bug.cgi?id=14662) fixed - WRITEC_f block didn't work for x86 machines.
+* [Bug #14648](http://bugzilla.scilab.org/show_bug.cgi?id=14648) fixed - `isinf` returned `%F` for complex numbers with both real and imag infinite parts.
 * [Bug #14662](http://bugzilla.scilab.org/show_bug.cgi?id=14662) fixed - Matrix of strings concatenation with single quote led to a parser error.
 
-
 ### In 6.0.0 beta-2 and earlier:
 
 * [Bug #2104](http://bugzilla.scilab.org/show_bug.cgi?id=2104) fixed   - `iw(1:9)` and `w(1:10)` `ode` output parameters were not documented
index e877152..5cc909d 100644 (file)
@@ -2,7 +2,8 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) 2008 - INRIA
- * 
+ * Copyright (C) 2016 - Samuel GOUGEON
+ *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
  * This file is hereby licensed under the terms of the GNU GPL v2.0,
  * along with this program.
  *
  -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="en">
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
+          xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="en">
     <refnamediv>
         <refname>isinf</refname>
-        <refpurpose>check for infinite entries</refpurpose>
+        <refpurpose>tests for infinite elements</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Syntax</title>
-        <synopsis>r=isinf(x)</synopsis>
+        <synopsis>
+            r = isinf(x)
+        </synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Arguments</title>
             <varlistentry>
                 <term>x</term>
                 <listitem>
-                    <para>real or complex vector or matrix r : boolean vector or
-                        matrix
+                    <para>matrix of real or complex numbers
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>r</term>
+                <listitem>
+                    <para>
+                        matrix of booleans of the same size as <varname>x</varname>
                     </para>
                 </listitem>
             </varlistentry>
     <refsection>
         <title>Description</title>
         <para>
-            <literal>isinf(x)</literal> returns a boolean vector or matrix which
-            contains true entries corresponding with infinite <literal>x</literal>
-            entries and false entries corresponding with finite <literal>x</literal>
-            entries.
+            <literal>isinf(x)</literal> returns the matrix <varname>r</varname>
+            of booleans such that, for each element <varname>x(i)</varname>,
+            <varname>r(i)</varname> is set to <literal>%T</literal> if and only if
+            <varname>x(i)</varname> is infinite.
+        </para>
+        <para>
+            When <literal>x</literal> is complex-encoded, <literal>x(i)</literal>
+            is considered infinite if its real part or its imaginary part (or both)
+            are infinite.
         </para>
     </refsection>
     <refsection>
         <title>Examples</title>
-        <programlisting role="example"><![CDATA[ 
-isinf([1 0.01 -%inf %inf])
+        <programlisting role="example"><![CDATA[
+[i, inf, nan] = (%i, %inf, %nan);
+isinf([-1  0.01 -inf  inf  nan])
+isinf([2+i, -10-inf, inf+i])
+isinf([nan-i, inf-nan*i, nan+i*inf])
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -56,6 +77,15 @@ isinf([1 0.01 -%inf %inf])
             <member>
                 <link linkend="isnan">isnan</link>
             </member>
+            <member>
+                <link linkend="isreal">isreal</link>
+            </member>
+            <member>
+                <link linkend="isnum">isnum</link>
+            </member>
+            <member>
+                <link linkend="type">type</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
index b634aa7..f626062 100644 (file)
@@ -1,14 +1,30 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="fr">
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2008 - INRIA
+ * Copyright (C) 2016 - Samuel GOUGEON
+ *
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ *
+ * This file is hereby licensed under the terms of the GNU GPL v2.0,
+ * pursuant to article 5.3.4 of the CeCILL v.2.1.
+ * This file was originally licensed under the terms of the CeCILL v2.1,
+ * and continues to be available under such terms.
+ * For more information, see the COPYING file which you should have received
+ * along with this program.
+ *
+ -->
+<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
+          xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml"
+          xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook"
+          xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="fr">
     <refnamediv>
         <refname>isinf</refname>
-        <refpurpose>vérifie si des composantes "Inf" (infinies) sont
-            présentes.
-        </refpurpose>
+        <refpurpose>teste la présence de valeurs infinies</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
-        <title>Séquence d'appel</title>
-        <synopsis>r=isinf(x)</synopsis>
+        <title>Syntaxe</title>
+        <synopsis>r = isinf(x)</synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Paramètres</title>
             <varlistentry>
                 <term>x</term>
                 <listitem>
-                    <para>vecteur ou matrice complexe ou réelle. r : vecteur ou matrice
-                        de booléens.
+                    <para>matrice de nombres décimaux ou complexes.
+                    </para>
+                </listitem>
+            </varlistentry>
+            <varlistentry>
+                <term>r</term>
+                <listitem>
+                  <para>matrice de booléens, de même taille que <varname>x</varname>
                     </para>
                 </listitem>
             </varlistentry>
     <refsection>
         <title>Description</title>
         <para>
-            <literal>isinf(x)</literal> renvoie un vecteur ou une matrice de
-            booléens contenant des composantes égales à %T (vrai) correspondant aux
-            composantes "Inf" (infinies) de <literal>x</literal> et %F (faux) pour les
-            autres.
+            <literal>isinf(x)</literal> renvoie une matrice <literal>r</literal> dont chaque
+            élément <literal>r(i)</literal> vaut <literal>%T</literal> (vrai) si et seulement si
+            <literal>x(i)</literal> est infini.
+       </para>
+       <para>Pour <literal>x</literal> complexe, <literal>x(i)</literal> est considéré infini
+         dés que sa partie réelle ou complexe ou les deux sont infinies.
         </para>
     </refsection>
     <refsection>
         <title>Exemples</title>
-        <programlisting role="example"><![CDATA[ 
-isinf([1 0.01 -%inf %inf])
+        <programlisting role="example"><![CDATA[
+[i, inf, nan] = (%i, %inf, %nan);
+isinf([-1  0.01 -inf  inf  nan])
+isinf([2+i, -10-inf, inf+i])
+isinf([nan-i, inf-nan*i, nan+i*inf])
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -44,6 +71,15 @@ isinf([1 0.01 -%inf %inf])
             <member>
                 <link linkend="isnan">isnan</link>
             </member>
+            <member>
+                <link linkend="isreal">isreal</link>
+            </member>
+            <member>
+                <link linkend="isnum">isnum</link>
+            </member>
+            <member>
+                <link linkend="type">type</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
diff --git a/scilab/modules/elementary_functions/help/ja_JP/floating_point/isinf.xml b/scilab/modules/elementary_functions/help/ja_JP/floating_point/isinf.xml
deleted file mode 100644 (file)
index ee1227e..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA
- * 
- * Copyright (C) 2012 - 2016 - Scilab Enterprises
- *
- * This file is hereby licensed under the terms of the GNU GPL v2.0,
- * pursuant to article 5.3.4 of the CeCILL v.2.1.
- * This file was originally licensed under the terms of the CeCILL v2.1,
- * and continues to be available under such terms.
- * For more information, see the COPYING file which you should have received
- * along with this program.
- *
- -->
-
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="ja">
-    
-    <refnamediv>
-        
-        <refname>isinf</refname>
-        
-        <refpurpose>無限大のエントリかどうかを調べる</refpurpose>
-        
-    </refnamediv>
-    
-    <refsynopsisdiv>
-        
-        <title>呼び出し手順</title>
-        
-        <synopsis>r=isinf(x)</synopsis>
-        
-    </refsynopsisdiv>
-    
-    <refsection>
-        
-        <title>引数</title>
-        
-        <variablelist>
-            
-            <varlistentry>
-                
-                <term>x</term>
-                
-                <listitem>
-                    
-                    <para>
-                        
-                        実数または複素数のベクトルまたは行列r: 論理値のベクトルまたは行列
-                        
-                    </para>
-                    
-                </listitem>
-                
-            </varlistentry>
-            
-        </variablelist>
-        
-    </refsection>
-    
-    <refsection>
-        
-        <title>説明</title>
-        
-        <para>
-            
-            <literal>isinf(x)</literal> は,
-            
-            <literal>x</literal>の無限大のエントリに対応するエントリに真,
-            
-            <literal>x</literal>の有限のエントリに対応するエントリに偽を含む
-            
-            論理値のベクトルまたは行列を返します.
-            
-        </para>
-        
-    </refsection>
-    
-    <refsection>
-        
-        <title>例</title>
-        
-        <programlisting role="example"><![CDATA[ 
-isinf([1 0.01 -%inf %inf])
- ]]></programlisting>
-        
-    </refsection>
-    
-    <refsection role="see also">
-        
-        <title>参照</title>
-        
-        <simplelist type="inline">
-            
-            <member>
-                
-                <link linkend="isnan">isnan</link>
-                
-            </member>
-            
-        </simplelist>
-        
-    </refsection>
-    
-</refentry>
-
diff --git a/scilab/modules/elementary_functions/help/pt_BR/floating_point/isinf.xml b/scilab/modules/elementary_functions/help/pt_BR/floating_point/isinf.xml
deleted file mode 100644 (file)
index b0fe1b9..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 2008 - INRIA
- * 
- * Copyright (C) 2012 - 2016 - Scilab Enterprises
- *
- * This file is hereby licensed under the terms of the GNU GPL v2.0,
- * pursuant to article 5.3.4 of the CeCILL v.2.1.
- * This file was originally licensed under the terms of the CeCILL v2.1,
- * and continues to be available under such terms.
- * For more information, see the COPYING file which you should have received
- * along with this program.
- *
- -->
-<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:ns4="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="isinf" xml:lang="pt">
-    <refnamediv>
-        <refname>isinf</refname>
-        <refpurpose>verifica se há entradas infinitas</refpurpose>
-    </refnamediv>
-    <refsynopsisdiv>
-        <title>Seqüência de Chamamento</title>
-        <synopsis>r=isinf(x)</synopsis>
-    </refsynopsisdiv>
-    <refsection>
-        <title>Parâmetros</title>
-        <variablelist>
-            <varlistentry>
-                <term>x</term>
-                <listitem>
-                    <para>um vetor ou matriz de reais ou complexos. r : um vetor ou
-                        matriz de valores booleanos 
-                    </para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-    </refsection>
-    <refsection>
-        <title>Descrição</title>
-        <para>
-            <literal>isinf(x)</literal> retorna um vetor ou matriz de valores
-            booleanos que contém entradas verdadeiras correspondentes às entradas de
-            <literal>x</literal> infinitas e entradas falsas correspondentes às
-            entradas de <literal>x</literal> finitas.
-        </para>
-    </refsection>
-    <refsection>
-        <title>Exemplos</title>
-        <programlisting role="example"><![CDATA[ 
-isinf([1 0.01 -%inf %inf])
- ]]></programlisting>
-    </refsection>
-    <refsection role="see also">
-        <title>Ver Também</title>
-        <simplelist type="inline">
-            <member>
-                <link linkend="isnan">isnan</link>
-            </member>
-        </simplelist>
-    </refsection>
-</refentry>
index 363ed4b..208a6b2 100644 (file)
@@ -20,7 +20,7 @@
     </refnamediv>
     <refsynopsisdiv>
         <title>Синтаксис</title>
-        <synopsis>r=isinf(x)</synopsis>
+        <synopsis>r = isinf(x)</synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Аргументы</title>
     <refsection>
         <title>Описание</title>
         <para>
-            <literal>isinf(x)</literal> возвращает вектор или матрицу логических значений, в которых истинные элементы соответствуют бесконечным элементам <literal>x</literal>,
-            а ложные элементы соответствуют конечным элементам <literal>x</literal>.
+            <literal>isinf(x)</literal> returns a matrix <varname>r</varname>
+            of booleans such that, for each element <varname>x(i)</varname>,
+            <varname>r(i)</varname> is set to <literal>%T</literal> as soon as
+            <varname>x(i)</varname> is infinite.
+        </para>
+        <para>When <literal>x</literal> is complex-encoded, <literal>x(i)</literal>
+         is considered infinite as soon as its real or imaginary or both parts
+         are infinite.
         </para>
     </refsection>
     <refsection>
         <title>Примеры</title>
-        <programlisting role="example"><![CDATA[ 
-isinf([1 0.01 -%inf %inf])
+        <programlisting role="example"><![CDATA[
+[i, inf, nan] = (%i, %inf, %nan);
+isinf([-1  0.01 -inf  inf  nan])
+isinf([2+i, -10-inf, inf+i])
+isinf([nan-i, inf-nan*i, nan+i*inf])
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
@@ -56,6 +65,15 @@ isinf([1 0.01 -%inf %inf])
             <member>
                 <link linkend="isnan">isnan</link>
             </member>
+            <member>
+                <link linkend="isreal">isreal</link>
+            </member>
+            <member>
+                <link linkend="isnum">isnum</link>
+            </member>
+            <member>
+                <link linkend="type">type</link>
+            </member>
         </simplelist>
     </refsection>
 </refentry>
index 8b47130..257a5f1 100644 (file)
@@ -1,5 +1,6 @@
 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
 // Copyright (C) INRIA
+// Copyright (C) 2016 - Samuel GOUGEON
 //
 // Copyright (C) 2012 - 2016 - Scilab Enterprises
 //
 // For more information, see the COPYING file which you should have received
 // along with this program.
 
-function r=isinf(x)
+function r = isinf(x)
 
     rhs = argn(2);
 
     if rhs <> 1 then
-        error(msprintf(gettext("%s: Wrong number of input argument(s): %d expected.\n"),"isinf",1));
+        msg = _("%s: Wrong number of input argument(s): %d expected.\n")
+        error(msprintf(msg, "isinf", 1))
     end
 
     if x==[] then
-        r=[];
+        r = []
     else
-        r=abs(x)==%inf;
+        if isreal(x)
+            r = abs(x)==%inf;
+        else
+            // workaround of http://bugzilla.scilab.org/14062
+            r = abs(real(x))==%inf | abs(imag(x))==%inf
+        end
     end
 
 endfunction
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.dia.ref b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.dia.ref
new file mode 100644 (file)
index 0000000..d49f2e7
--- /dev/null
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14648 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14648
+//
+// <-- Short Description -->
+//  isinf(complex(%inf,%inf)) and isinf(complex(%nan,%inf)) returned %F
+// =============================================================================
+c = complex(%inf*[1 1 -1 -1], %inf*[1 -1 1 -1]);
+assert_checktrue(and(isinf(c)));
+c = complex([%nan %nan %inf -%inf], [%inf -%inf %nan %nan]);
+assert_checktrue(and(isinf(c)));
diff --git a/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.tst b/scilab/modules/elementary_functions/tests/nonreg_tests/bug_14648.tst
new file mode 100644 (file)
index 0000000..d49f2e7
--- /dev/null
@@ -0,0 +1,21 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2016 - Samuel GOUGEON
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+//
+// <-- Non-regression test for bug 14648 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/14648
+//
+// <-- Short Description -->
+//  isinf(complex(%inf,%inf)) and isinf(complex(%nan,%inf)) returned %F
+// =============================================================================
+c = complex(%inf*[1 1 -1 -1], %inf*[1 -1 1 -1]);
+assert_checktrue(and(isinf(c)));
+c = complex([%nan %nan %inf -%inf], [%inf -%inf %nan %nan]);
+assert_checktrue(and(isinf(c)));