* Bug #13481 fixed - varn did not work on rational fractions 20/14720/6
Samuel Gougeon [Mon, 23 Jun 2014 08:50:50 +0000 (10:50 +0200)]
Change-Id: I12711c8b98aba8fab4098d7ff2e818e56aaceafd

scilab/CHANGES_5.5.X
scilab/modules/overloading/macros/%r_varn.sci [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref [new file with mode: 0644]
scilab/modules/overloading/tests/nonreg_tests/bug_13481.tst [new file with mode: 0644]
scilab/modules/polynomials/help/en_US/varn.xml
scilab/modules/polynomials/help/fr_FR/varn.xml
scilab/modules/polynomials/help/ja_JP/varn.xml
scilab/modules/polynomials/help/pt_BR/varn.xml
scilab/modules/polynomials/help/ru_RU/varn.xml

index 831e70d..2acc454 100644 (file)
@@ -138,6 +138,8 @@ Scilab Bug Fixes
 
 * Bug #13438 fixed - drawaxis did not return the handle of the created axis.
 
+* Bug #13481 fixed - varn did not work on rational fractions
+
 * Bug #13491 fixed - intg now properly returns when the user function produces an error.
 
 * Bug #13501 fixed - Typos fixed in English help pages.
@@ -147,6 +149,7 @@ Scilab Bug Fixes
 * Bug #13509 fixed - It was not possible to have an empty prefix with xmlNs.
 
 
+
 Xcos Bug Fixes
 ==============
 
diff --git a/scilab/modules/overloading/macros/%r_varn.sci b/scilab/modules/overloading/macros/%r_varn.sci
new file mode 100644 (file)
index 0000000..b1523fb
--- /dev/null
@@ -0,0 +1,16 @@
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) Samuel GOUGEON <sgougeon@free.fr>
+//
+// This file must be used under the terms of the CeCILL.
+// This source file is licensed as described in the file COPYING, which
+// you should have received as part of this distribution.  The terms
+// are also available at
+// http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
+
+function  rep = %r_varn(p, varname)
+    if argn(2)==1 then
+        rep = varn(p("num"))
+    else
+        rep = rlist(varn(p.num, varname), varn(p.den, varname), [])
+    end
+endfunction
diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref b/scilab/modules/overloading/tests/nonreg_tests/bug_13481.dia.ref
new file mode 100644 (file)
index 0000000..0635d42
--- /dev/null
@@ -0,0 +1,29 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13481 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13481
+//
+// <-- Short Description -->
+// varn did not work on rational fractions
+//
+// <-- CLI SHELL MODE -->
+// Test on a rational fractions
+x = poly(0, "x");
+num = 3 + x + x^2;
+den = 1 - x + 2*x^2;
+R = num / den;
+assert_checkequal("x", varn(R));
+num = varn(num, "z");
+den = varn(den, "z");
+assert_checkequal(num / den, varn(R, "z"));
+// Test on matrix of rationals
+matrix_R = [R, 2*R + x, R.den/R.num];
+assert_checkequal(varn(matrix_R), "x");
+assert_checkequal(varn(varn(matrix_R, "z")), "z");
diff --git a/scilab/modules/overloading/tests/nonreg_tests/bug_13481.tst b/scilab/modules/overloading/tests/nonreg_tests/bug_13481.tst
new file mode 100644 (file)
index 0000000..ee6b920
--- /dev/null
@@ -0,0 +1,35 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2014 - Scilab Enterprises - Pierre-Aime Agnel
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- Non-regression test for bug 13481 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/13481
+//
+// <-- Short Description -->
+// varn did not work on rational fractions
+//
+// <-- CLI SHELL MODE -->
+
+// Test on a rational fractions
+
+x = poly(0, "x");
+num = 3 + x + x^2;
+den = 1 - x + 2*x^2;
+
+R = num / den;
+assert_checkequal("x", varn(R));
+
+num = varn(num, "z");
+den = varn(den, "z");
+
+assert_checkequal(num / den, varn(R, "z"));
+
+// Test on matrix of rationals
+matrix_R = [R, 2*R + x, R.den/R.num];
+assert_checkequal(varn(matrix_R), "x");
+assert_checkequal(varn(varn(matrix_R, "z")), "z");
index d38b731..d1423ff 100644 (file)
@@ -2,12 +2,12 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="varn">
     <refnamediv>
         <refname>varn</refname>
-        <refpurpose>symbolic variable of a polynomial</refpurpose>
+        <refpurpose>symbolic variable of a polynomial or a rational</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Calling Sequence</title>
         <synopsis>[symb]=varn(p)
-            [pm]=varn(x,var)
+            [pm]=varn(p,varname)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
             <varlistentry>
                 <term>p</term>
                 <listitem>
-                    <para>polynomial (or polynomial matrix)</para>
+                    <para>matrix of polynomials or of rationals</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>symb</term>
                 <listitem>
-                    <para>character string</para>
+                    <para>character string: name of the variable</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>x</term>
+                <term>varname</term>
                 <listitem>
-                    <para>polynomial or polynomial matrix</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>var</term>
-                <listitem>
-                    <para>symbolic variable (character string)</para>
+                    <para>
+                        character string: the new name of the variable of <literal>p</literal>, set for <literal>pm</literal>
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>pm</term>
                 <listitem>
-                    <para>polynomial (or polynomial matrix)</para>
+                    <para>matrix of polynomials or of rationals</para>
                 </listitem>
             </varlistentry>
         </variablelist>
             (i.e. <literal>varn(poly(0,'x'))</literal> is <literal>'x'</literal>).
         </para>
         <para>
-            <literal>varn(x,'s')</literal> returns a polynomial matrix with same coefficients
-            as <literal>x</literal> but with <literal>'s'</literal> as symbolic variable (change of variable name).
+            <literal>varn(p,'s')</literal> returns a polynomial matrix with same coefficients
+            as <literal>p</literal> but with <literal>'s'</literal> as symbolic variable (change of variable name).
         </para>
     </refsection>
     <refsection>
         <title>Examples</title>
         <programlisting role="example"><![CDATA[ 
-s=poly(0,'s');p=[s^2+1,s];
+s = poly(0,'s'); p = [s^2+1,s];
 varn(p)
 varn(p,'x')
+
+f = %z / (%z-1); f = [f f^2]
+varn(f)
+varn(f,"x")
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>See Also</title>
         <simplelist type="inline">
             <member>
-                <link linkend="horner">horner</link>
+                <link linkend="poly">poly</link>
             </member>
             <member>
-                <link linkend="poly">poly</link>
+                <link linkend="rlist">rlist</link>
+            </member>
+            <member>
+                <link linkend="horner">horner</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.1</revnumber>
+                <revdescription>
+                    <para>Extension to rationals</para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 8205dc0..f67068c 100644 (file)
@@ -2,12 +2,12 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="fr" xml:id="varn">
     <refnamediv>
         <refname>varn</refname>
-        <refpurpose>indéterminée d'un polynôme  </refpurpose>
+        <refpurpose>variable symbolique d'un polynôme ou d'une fraction rationnelle</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Séquence d'appel</title>
         <synopsis>[symb]=varn(p)
-            [pm]=varn(x,var)
+            [pm]=varn(p,varname)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
             <varlistentry>
                 <term>p  </term>
                 <listitem>
-                    <para>polynôme (ou matrice de polynômes)
+                    <para>matrice de polynômes ou de fractions rationelles
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>symb  </term>
                 <listitem>
-                    <para>chaîne de caractères
+                    <para>
+                        chaîne de caractères: nom de l'indéterminée des éléments de <literal>p</literal>
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>x  </term>
+                <term>varname  </term>
                 <listitem>
-                    <para>polynôme (ou matrice de polynômes)
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>var  </term>
-                <listitem>
-                    <para>indéterminée du polynôme
+                    <para>
+                        chaîne de caractères: nouveau nom à attribuer à la variable des polynômes ou fractions rationnelles de <literal>p</literal>
                     </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>pm  </term>
                 <listitem>
-                    <para>polynôme (ou matrice de polynômes)
+                    <para>
+                        matrice <literal>p</literal> actualisée avec le nouveau nom de variable <literal>varname</literal>
                     </para>
                 </listitem>
             </varlistentry>
             (par exemple <literal>varn(poly(0,'x'))</literal> est égal à <literal>'x'</literal>).
         </para>
         <para>
-            <literal>varn(x,'s')</literal> renvoie une matrice polynomiale de même taille que <literal>x</literal> mais avec <literal>'s'</literal> comme indéterminée.
+            <literal>varn(p,'s')</literal> renvoie une matrice polynomiale de même taille que <literal>p</literal> mais avec <literal>'s'</literal> comme indéterminée.
         </para>
     </refsection>
     <refsection>
         <title>Exemples</title>
         <programlisting role="example"><![CDATA[ 
-s=poly(0,'s');p=[s^2+1,s];
+s = poly(0,'s'); p = [s^2+1,s];
 varn(p)
 varn(p,'x')
+
+f = %z / (%z-1); f = [f f^2]
+varn(f)
+varn(f,"x")
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>Voir aussi</title>
         <simplelist type="inline">
             <member>
-                <link linkend="horner">horner</link>
+                <link linkend="poly">poly</link>
             </member>
             <member>
-                <link linkend="poly">poly</link>
+                <link linkend="rlist">rlist</link>
+            </member>
+            <member>
+                <link linkend="horner">horner</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>Historique</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.1</revnumber>
+                <revdescription>
+                    <para>Extension aux fractions rationnelles</para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index fb066f4..df79531 100644 (file)
@@ -2,12 +2,12 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ja" xml:id="varn">
     <refnamediv>
         <refname>varn</refname>
-        <refpurpose>多項式の記号変数</refpurpose>
+        <refpurpose>多項式または有理分数のシンボリック変数</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>呼出し手順</title>
         <synopsis>[symb]=varn(p)
-            [pm]=varn(x,var)
+            [pm]=varn(p,varname)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -16,7 +16,7 @@
             <varlistentry>
                 <term>p</term>
                 <listitem>
-                    <para>多項式 (または多項式行列)</para>
+                    <para>多項式のか合理的な画分の行列</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>x</term>
-                <listitem>
-                    <para>多項式または多項式行列</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>var</term>
+                <term>varname</term>
                 <listitem>
                     <para>記号変数 (文字列)</para>
                 </listitem>
@@ -40,7 +34,7 @@
             <varlistentry>
                 <term>pm</term>
                 <listitem>
-                    <para>多項式 (または多項式行列)</para>
+                    <para>多項式のか合理的な画分の行列</para>
                 </listitem>
             </varlistentry>
         </variablelist>
@@ -53,7 +47,7 @@
             (すなわち,<literal>varn(poly(0,'x'))</literal> は <literal>'x'</literal> です).
         </para>
         <para>
-            <literal>varn(x,'s')</literal> は,<literal>x</literal>と
+            <literal>varn(p,'s')</literal> は,<literal>p</literal>と
             同じ係数を有し,<literal>'s'</literal>を記号変数とする
             多項式行列を返します(変数名の変更).
         </para>
     <refsection>
         <title>例</title>
         <programlisting role="example"><![CDATA[ 
-s=poly(0,'s');p=[s^2+1,s];
+s = poly(0,'s'); p = [s^2+1,s];
 varn(p)
 varn(p,'x')
+
+f = %z / (%z-1); f = [f f^2]
+varn(f)
+varn(f,"x")
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>参照</title>
         <simplelist type="inline">
             <member>
-                <link linkend="horner">horner</link>
+                <link linkend="poly">poly</link>
             </member>
             <member>
-                <link linkend="poly">poly</link>
+                <link linkend="rlist">rlist</link>
+            </member>
+            <member>
+                <link linkend="horner">horner</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>履歴</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.1</revnumber>
+                <revdescription>
+                    <para>Extension to rationals</para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 6f0882e..b4c8266 100644 (file)
@@ -1,22 +1,22 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<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="varn" xml:lang="en">
+<?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: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="varn" xml:lang="pt">
     <refnamediv>
         <refname>varn</refname>
-        <refpurpose>variável simbólica de um polinômio</refpurpose>
+        <refpurpose>variável simbólica de polinômios ou de frações racionais</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
-        <title> Seqüência de Chamamento </title>
+        <title> Seqüência de Chamamento </title>
         <synopsis>[symb]=varn(p)
-            [pm]=varn(x,var)
+            [pm]=varn(p,varname)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
-        <title> Parâmetros </title>
+        <title> Parâmetros </title>
         <variablelist>
             <varlistentry>
                 <term>p</term>
                 <listitem>
-                    <para>polinômio (matriz de polinômios) </para>
+                    <para>matriz de polinômios ou de frações racionais</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>x</term>
-                <listitem>
-                    <para>polinômio ou matriz de polinômios </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
                 <term>var</term>
                 <listitem>
-                    <para>variável simbólica (string) </para>
+                    <para>variável simbólica (string) </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>pm</term>
                 <listitem>
-                    <para>polinômio (matriz de polinômios)</para>
+                    <para>matriz de polinômios ou de frações racionais</para>
                 </listitem>
             </varlistentry>
         </variablelist>
     </refsection>
     <refsection>
-        <title>Descrição</title>
+        <title>Descrição</title>
         <para>
             <literal>symb=varn(p)</literal> retorna em <literal>symb</literal> a
-            variável simbólica de <literal>p</literal> (i.e.
+            variável simbólica de <literal>p</literal> (i.e.
             <literal>varn(poly(0,'x'))</literal> is <literal>'x'</literal>).
         </para>
         <para>
-            <literal>varn(x,'s')</literal> retorna uma matriz de polinômios com
-            os mesmos coeficientes que <literal>x</literal> mas com <literal>'s'
+            <literal>varn(p,'s')</literal> retorna uma matriz de polinômios com
+            os mesmos coeficientes que <literal>p</literal> mas com <literal>'s'
             </literal>
-            como variável simbólica (mudança do nome de variável).
+            como variável simbólica (mudança do nome de variável).
         </para>
     </refsection>
     <refsection>
         <title>Exemplos</title>
         <programlisting role="example"><![CDATA[ 
-s=poly(0,'s');p=[s^2+1,s];
+s = poly(0,'s'); p = [s^2+1,s];
 varn(p)
 varn(p,'x')
+
+f = %z / (%z-1); f = [f f^2]
+varn(f)
+varn(f,"x")
  ]]></programlisting>
     </refsection>
     <refsection>
-        <title> Ver Também </title>
+        <title> Ver Também </title>
         <simplelist type="inline">
             <member>
-                <link linkend="horner">horner</link>
+                <link linkend="poly">poly</link>
             </member>
             <member>
-                <link linkend="poly">poly</link>
+                <link linkend="rlist">rlist</link>
+            </member>
+            <member>
+                <link linkend="horner">horner</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>Histórico</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.1</revnumber>
+                <revdescription>
+                    <para>Extensão de frações racionais</para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
index 93a360c..c1bc844 100644 (file)
@@ -2,13 +2,13 @@
 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="ru" xml:id="varn">
     <refnamediv>
         <refname>varn</refname>
-        <refpurpose>символическая переменная полинома</refpurpose>
+        <refpurpose>Символические переменных полиномами или рациональные дроби</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Последовательность вызова</title>
         <synopsis>
             [symb]=varn(p)
-            [pm]=varn(x,var)
+            [pm]=varn(p, varname)
         </synopsis>
     </refsynopsisdiv>
     <refsection>
@@ -17,7 +17,7 @@
             <varlistentry>
                 <term>p</term>
                 <listitem>
-                    <para>полином (или матрица полиномов)</para>
+                    <para>Матрица полиномов или рациональных дробей</para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>x</term>
-                <listitem>
-                    <para>полином или матрица полиномов</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>var</term>
+                <term>varname</term>
                 <listitem>
                     <para>символическая переменная (символьная строка)</para>
                 </listitem>
@@ -41,7 +35,7 @@
             <varlistentry>
                 <term>pm</term>
                 <listitem>
-                    <para>полином (или матрица полиномов)</para>
+                    <para>Матрица полиномов или рациональных дробей</para>
                 </listitem>
             </varlistentry>
         </variablelist>
             <literal>varn(poly(0,'x'))</literal>, то <literal>'x'</literal>).
         </para>
         <para>
-            <literal>varn(x,'s')</literal> возвращает матрицу полиномов с теми же коэффициентами, 
-            что и <literal>x</literal>, но с <literal>'s'</literal> в качестве символической 
+            <literal>varn(p,'s')</literal> возвращает матрицу полиномов с теми же коэффициентами, 
+            что и <literal>p</literal>, но с <literal>'s'</literal> в качестве символической 
             переменой (смена имени переменной).
         </para>
     </refsection>
     <refsection>
         <title>Примеры</title>
         <programlisting role="example"><![CDATA[ 
-s=poly(0,'s');p=[s^2+1,s];
+s = poly(0,'s'); p = [s^2+1,s];
 varn(p)
 varn(p,'x')
+
+f = %z / (%z-1); f = [f f^2]
+varn(f)
+varn(f,"x")
  ]]></programlisting>
     </refsection>
     <refsection role="see also">
         <title>Смотрите также</title>
         <simplelist type="inline">
             <member>
-                <link linkend="horner">horner</link>
+                <link linkend="poly">poly</link>
             </member>
             <member>
-                <link linkend="poly">poly</link>
+                <link linkend="rlist">rlist</link>
+            </member>
+            <member>
+                <link linkend="horner">horner</link>
             </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>История</title>
+        <revhistory>
+            <revision>
+                <revnumber>5.5.1</revnumber>
+                <revdescription>
+                    <para>Расширение для рациональных дробей</para>
+                </revdescription>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>