* Bug 11933 fixed: sci2exp failed for polynom. in s or z. Page overhauled 07/20707/3
Samuel GOUGEON [Wed, 30 Aug 2017 20:00:28 +0000 (22:00 +0200)]
 * http://bugzilla.scilab.org/11933
 * Page overhauled
   1) to document the case of other polynomials (<=> bug 11933.b)
   2) because many important features were misleading or undocumented:
      - Obscure short description (while it's a important function)
      - The doc made thinking that only scalars are supported, while
        vectors, matrices and hypermatrices are so.
      - The support to encoded integers, sparse, structures and cells
        arrays and mlists was undocumented.
      - The support of ascii(10) in strings was undocumented.
      - For containers, the restriction to components supported by
        sci2exp() was undocumented.
      - The impact of format() was not illustrated.
      - The See also section missed string(), evstr(), execstr(),
        pol2str()..
      etc
   Due to heavy changes, the page shall be retranslated from scratch.

Change-Id: I0bb56551c7671485730e30f3d7e4a87638bb53cc

scilab/CHANGES.md
scilab/modules/string/help/en_US/sci2exp.xml
scilab/modules/string/help/ja_JP/sci2exp.xml [deleted file]
scilab/modules/string/help/pt_BR/sci2exp.xml [deleted file]
scilab/modules/string/help/ru_RU/sci2exp.xml [deleted file]
scilab/modules/string/macros/sci2exp.sci
scilab/modules/string/tests/nonreg_tests/bug_11933.tst [new file with mode: 0644]

index cd0e4f2..f609c25 100644 (file)
@@ -254,6 +254,7 @@ input and output arguments.
    - Input variables can no longer be corrupted by internal values before being saved.
    - When an error occurs, the output file is now closed and unlocked.
    - Encoded integers can now be saved in `-v4` format.
+* `sci2exp` now uses `%s` or `%z` in literal expressions of polynomials in `s` or `z`.
 
 Help pages:
 -----------
@@ -267,7 +268,7 @@ Help pages:
   `colordef`, `matrix`, `coffg`, `diag`, `speye`, `sparse`, `recursionlimit`, `for`, `fileinfo`, `end`,
   `iconvert`, `cond`, `Globalproperty`, `unique`, `intdec`, `plus`, `minus`, `varn`, `savematfile`,
   `empty`, `modulo`, `pdiv`, `unix_g`, `unix_s`, `unix_w`, `unix_x`, `dos`, `listvarinfile`, `surf`, `plot`
-* rewritten: `consolebox`, `double`, `isoview`, `pixel_drawing_mode`, `householder`, `or`, `|,||`,
+* rewritten: `consolebox`, `double`, `isoview`, `pixel_drawing_mode`, `householder`, `or`, `|,||`, `sci2exp`,
  `and`, `&,&&`, `format`, `type`, `typeof`, `brackets`, `setlanguage`, `sleep`, `isinf`, `unique`,
  `bitor`, `bitxor`, `bitand`, `macr2tree`, `geomean`, `clf`, `getPreferencesValue`, `gcd`, `lcm`, `isglobal`,
  `whereis`, `mode`, `%onprompt`, `toeplitz`, `param3d`, `param3d1`, `argn`, `powershell`, `gettext`, `poly`,
@@ -895,6 +896,7 @@ Known issues
 * [#11375](http://bugzilla.scilab.org/show_bug.cgi?id=11375): When a localized help subdirectory has only a `CHAPTER` file specifying the section title, this one was ignored.
 * [#11476](http://bugzilla.scilab.org/show_bug.cgi?id=11476): `clf("reset")` used on a docked figure resized and moved the whole docked block like the Scilab desktop.
 * [#11692](http://bugzilla.scilab.org/show_bug.cgi?id=11692): The summary of a help section built from both default `en_US` and localized files was never sorted overall.
+* [#11933](http://bugzilla.scilab.org/show_bug.cgi?id=11933): For polynomials in `s` or `z`, `sci2exp` did not use `%s` and `%z` to generate a valid expression. For other polynomials, no how-to was documented.
 * [#11959](http://bugzilla.scilab.org/show_bug.cgi?id=11959): Selecting a zoom area starting on some axes borders was hard and tricky.
 * [#12017](http://bugzilla.scilab.org/show_bug.cgi?id=12017): The on-screen rendering according to `figure.pixel_drawing_mode` was out of work since Scilab 5.4
 * [#12110](http://bugzilla.scilab.org/show_bug.cgi?id=12110): Zooming multiple side-by-side or overlaying axes at once was out of work since Scilab 5.4
index f16db9c..3d0f403 100644 (file)
@@ -2,6 +2,7 @@
 <!--
  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
  * Copyright (C) INRIA -
+ * Copyright (C) 2017 - Samuel GOUGEON
  *
  * Copyright (C) 2012 - 2016 - Scilab Enterprises
  *
  * 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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xml:lang="en" xml:id="sci2exp">
+<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" xml:lang="en" xml:id="sci2exp">
     <refnamediv>
         <refname>sci2exp</refname>
-        <refpurpose> converts an expression to a string</refpurpose>
+        <refpurpose>returns a string able to generate a given Scilab object</refpurpose>
     </refnamediv>
     <refsynopsisdiv>
         <title>Syntax</title>
-        <synopsis>t = sci2exp(a [,nam] [,lmax])</synopsis>
+        <synopsis>
+            t = sci2exp(a)
+            t = sci2exp(a, LHSname)
+            t = sci2exp(a, LHSname, lmax)
+            t = sci2exp(a, lmax)
+        </synopsis>
     </refsynopsisdiv>
     <refsection>
         <title>Arguments</title>
             <varlistentry>
                 <term>a</term>
                 <listitem>
-                    <para>a scilab expression, may be:</para>
-                    <variablelist>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a constant;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a polynomial;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a string matrix;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a list;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a boolean matrix;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>a handle (only figure and uicontrol).</para>
-                            </listitem>
-                        </varlistentry>
-                    </variablelist>
+                    <para>a scilab object. The supported types are:
+                    </para>
+                    <itemizedlist>
+                        <listitem>booleans</listitem>
+                        <listitem>
+                            encoded integers of any <link linkend="inttype">inttype</link>
+                        </listitem>
+                        <listitem>real or complex numbers</listitem>
+                        <listitem>sparse matrices</listitem>
+                        <listitem>polynomials</listitem>
+                        <listitem>strings, that may include some NewLine (ascii(10)) sequences</listitem>
+                        <listitem>a structures array or cells array with any number of dimensions</listitem>
+                        <listitem>a simple list whose components types are supported by
+                            <literal>sci2exp</literal>
+                        </listitem>
+                        <listitem>a typed list tlist() and mlist()</listitem>
+                        <listitem>a single graphic handle (only of figure or uicontrol).</listitem>
+                    </itemizedlist>
+                    <para>
+                        For booleans, encoded integers, real or complex numbers, polynomials and
+                        strings, any of a single element or a vector or a matrix or an hypermatrix
+                        is accepted.
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
-                <term>nam</term>
+                <term>LHSname</term>
                 <listitem>
-                    <para>a character string.</para>
+                    <para>
+                    Optional string: The name of the variable building the assignment prefix
+                    <literal>LHSname+" = "</literal>. When it is provided, <literal>LHSname+" = "</literal>
+                    is prepended to the raw expression yielded from the <varname>a</varname> object.
+                    Then, the result string <literal>t</literal> can no longer be evaluated with
+                    <literal>evstr()</literal> but with <literal>execstr()</literal>.
+                    </para>
                 </listitem>
             </varlistentry>
             <varlistentry>
                 <term>t</term>
                 <listitem>
                     <para>
-                        a vector of strings, contains the expression or the affectation instruction.
+                        Column of strings. A single whole string is returned when <varname>lmax</varname>
+                        is not used or is set to 0: The Scilab literal expression, with possibly
+                        the left-hand affectation part on the first line when <varname>LHSname</varname>
+                        is provided.
                     </para>
                 </listitem>
             </varlistentry>
                 <term>lmax</term>
                 <listitem>
                     <para>
-                        an integer, contains the maximum line length. Default
-                        value is <literal>0</literal>,
-                        which indicates no line length
-                        control; a single string is returned.
+                        Positive integer setting the maximal length of the <varname>t</varname>
+                        components. The default value <literal>0</literal> ignores such a constrain
+                        and returns <varname>t</varname> as a single (long) string. Otherwise,
+                        some continuation marks <literal>..</literal> are used to break too long
+                        rows.
                     </para>
+                    <warning>
+                       Since continuation marks <literal>..</literal> prevent using
+                       <literal>evstr()</literal> and <literal>execstr()</literal>, using this
+                       <varname>lmax</varname> option mostly cancels the main <literal>sci2exp()</literal>
+                       purpose.
+                    </warning>
                 </listitem>
             </varlistentry>
         </variablelist>
     <refsection>
         <title>Description</title>
         <para>
-            <function>sci2exp</function> converts expression to an instruction string if <varname>nam</varname> is
-            given or to an expression string.
+            "sci2exp" stands for the conversion of a <emphasis role="bold">sci</emphasis>lab
+            object into a literal executable <emphasis role="bold">exp</emphasis>ression.
         </para>
-    </refsection>
-    <refsection>
-        <title>Remarks</title>
-        <itemizedlist>
-            <listitem>
-                <para>
-                    If <varname>a</varname> is a handle, <function>sci2exp</function> gives a result which has no hierarchical links,
-                    that is, with empty fields for parent and children.
-                </para>
-            </listitem>
-            <listitem>
-                <para>
-                    <varname>t</varname> can be impacted by <link linkend="format">format</link>.
-                </para>
-            </listitem>
-        </itemizedlist>
-    </refsection>
+        <important>
+            <itemizedlist>
+                <listitem>
+                    <para>
+                        Literal values of decimal real or complex numbers or coefficients are output
+                        in <varname>t</varname> according to the current
+                        <link linkend="format">format</link> setting. So, they may be truncated
+                        with respect to the full numerical accuracy.
+                    </para>
+                </listitem>
+                <listitem>
+                    <para>
+                    When <varname>a</varname> are polynomials, the resulting expression
+                    <varname>t</varname> can be executed to regenerate <varname>a</varname> ONLY if
+                    the formal variable of the polynomials is defined in the current scope:
+                    <itemizedlist>
+                        <listitem>
+                            <para>
+                            For polynomials in <literal>s</literal> or <literal>z</literal>, the
+                            predefined Scilab variables <literal>%s</literal> or <literal>%z</literal>
+                            are used, and the regeneration can be straightforward:
+                            </para>
+                            <screen><![CDATA[
+--> p = [1+%z 1-%z^2];
+
+--> tp = pol2str(p)
+ tp  =
+!1+z  1-z^2  !
+
+--> evstr(tp)
+at line     1 of executed string
+at line    38 of function        evstr ( SCI\modules\string\macros\evstr.sci line 52 )
+Undefined variable: z
 
+--> tp = sci2exp(p)
+ tp  =
+ [1+%z,1-%z^2]        <<< sci2exp() uses the variable %z as predefined "z" generator
+
+--> t = evstr(tp)     // .. straigntforward regeneration
+ t  =
+              2
+   1 +z   1 -z
+
+--> typeof(t)
+ ans  =
+ polynomial
+]]></screen>
+                        </listitem>
+                        <listitem>
+                            <para>
+                            Otherwise: The formal variable of <varname>a</varname> -- say
+                            <literal>"x"</literal> -- must be explicitly defined with (say)
+                            <literal>x = poly(0,"x")</literal>:
+                            </para>
+                            <screen><![CDATA[
+--> p = poly([1 2 3], "x")
+ p  =
+             2   3
+  -6 +11x -6x  +x
+
+--> tp = sci2exp(p)
+ tp  =
+ -6+11*x-6*x^2+x^3
+
+--> // Evaluating tp now would yield an error: x is not yet defined. We must prioly do:
+
+--> x = poly(0,"x")  // Defines the symbolic variable "x" in the actual variable with the SAME name
+ x  =
+   x
+
+--> // Then evaluating tp to regenerate p is OK:
+--> rp = evstr(tp)
+ rp  =
+             2   3
+  -6 +11x -6x  +x
+
+--> rp==p
+ ans  =
+  T
+]]></screen>
+                        </listitem>
+                    </itemizedlist>
+                    </para>
+                </listitem>
+                <listitem>
+                    <para>
+                    When <varname>a</varname> is a graphic handle, <function>sci2exp</function>
+                    ignores its parent (empty) and its children.
+                    </para>
+                </listitem>
+            </itemizedlist>
+        </important>
+    </refsection>
     <refsection>
         <title>Examples</title>
+        <para>
+            <emphasis role="bold">With a numerical matrix:</emphasis>
+        </para>
         <programlisting role="example"><![CDATA[
-a=[1 2;3 4]
-sci2exp(a,'aa')
-sci2exp(a,'aa',10)
-sci2exp(ssrand(2,2,2))
-sci2exp(poly([1 0 3 4],'s'),'fi')
-sci2exp(figure("figure_name","figure1"))
-b=0.123456789;
-format(5);
-c=sci2exp(b)
-format(10);
-d=sci2exp(b)
+a = [%i 2 ; 3 4-2*%i]
+sci2exp(a)
+sci2exp(a, 'aa')
+sci2exp(a, 'aa', 10)
     ]]></programlisting>
+        <screen><![CDATA[
+--> a = [%i 2 ; 3 4-2*%i]
+ a  =
+   i      2.
+   3.     4. - 2.i
+
+--> sci2exp(a)
+ ans  =
+ [%i,2;3,4-%i*2]
+
+--> sci2exp(a, 'aa')
+ ans  =
+ aa = [%i,2;3,4-%i*2]
+
+--> sci2exp(a, 'aa', 10)
+ ans  =
+!aa = [     !
+!%i,2;      !
+!3,4-%i*2]  !
+]]></screen>
+        <para>
+            <emphasis role="bold">With some other types of objects:</emphasis>
+        </para>
+        <programlisting role="example"><![CDATA[
+sci2exp(ssrand(2,2,2))                      // a typed list created with tlist()
+
+sci2exp(figure("figure_name","figure1"))    // a graphic handle
+    ]]></programlisting>
+        <para>
+        <emphasis role="bold">Impact of format()</emphasis> on literal output numbers:
+        </para>
+        <programlisting role="example"><![CDATA[
+p = [0.123456789, %z-%pi*%i];
+pol2str(p)                      // also impacted by format()
+format(20);
+Lp = sci2exp(p)                 // Literal encoding
+Rp = evstr(Lp); pol2str(Rp)     // Regenerated from literal
+Rp == p
+format(10);                     // Let's truncate the literal output before calling sci2exp()
+Lp = sci2exp(p)
+Rp = evstr(Lp); format(20); pol2str(Rp)
+Rp == p
+    ]]></programlisting>
+    <screen><![CDATA[
+--> p = [0.123456789, %z-%pi*%i];
+
+--> pol2str(p)
+ ans  =
+!0.1234568  -%i*3.1415927+z  !
+
+--> format(20)
+
+--> Lp = sci2exp(p)
+ Lp  =
+ [0.12345678900000000,-%i*3.14159265358979310+%z]
+
+--> Rp = evstr(Lp); pol2str(Rp)
+ ans  =
+!0.12345678900000000  -%i*3.14159265358979310+z  !
+
+--> Rp == p
+ ans  =
+  T T
+
+
+--> format(10)          // Let's truncate the literal output before calling sci2exp()
+
+--> Lp = sci2exp(p)
+ Lp  =
+ [0.1234568,-%i*3.1415927+%z]
+
+--> Rp = evstr(Lp); format(20); pol2str(Rp)
+ ans  =
+!0.12345680000000001  -%i*3.14159269999999990+z  !
+
+--> Rp == p
+ ans  =
+  F F
+]]></screen>
     </refsection>
     <refsection role="see also">
         <title>See also</title>
         <simplelist type="inline">
             <member>
+                <link linkend="string">string</link>
+            </member>
+            <member>
                 <link linkend="prettyprint">prettyprint</link>
             </member>
             <member>
                 <link linkend="format">format</link>
             </member>
+            <member>
+                <link linkend="pol2str">pol2str</link>
+            </member>
+            <member>
+                <link linkend="evstr">evstr</link>
+            </member>
+            <member>
+                <link linkend="execstr">execstr</link>
+            </member>
         </simplelist>
     </refsection>
+    <refsection>
+        <title>History</title>
+        <revhistory>
+            <revision>
+                <revnumber>6.1</revnumber>
+                <revremark>
+                    The name of the predefined variables <literal>%s</literal> and
+                    <literal>%z</literal> is now used as literal generator for input polynomials in
+                    <literal>s</literal> or <literal>z</literal>.
+                </revremark>
+            </revision>
+        </revhistory>
+    </refsection>
 </refentry>
diff --git a/scilab/modules/string/help/ja_JP/sci2exp.xml b/scilab/modules/string/help/ja_JP/sci2exp.xml
deleted file mode 100644 (file)
index bdbc06a..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 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: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="sci2exp">
-
-    <refnamediv>
-
-        <refname>sci2exp</refname>
-
-        <refpurpose>式を文字列に変換</refpurpose>
-
-    </refnamediv>
-
-    <refsynopsisdiv>
-
-        <title>呼び出し手順</title>
-
-        <synopsis>t = sci2exp(a [,nam] [,lmax])</synopsis>
-
-    </refsynopsisdiv>
-
-    <refsection>
-
-        <title>引数</title>
-
-        <variablelist>
-
-            <varlistentry>
-
-                <term>a</term>
-
-                <listitem>
-
-                    <para>以下に示すscilab式</para>
-
-                    <variablelist>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>定数,</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>多項式</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>文字列行列</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>リスト</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>論理値行列</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                        <varlistentry>
-
-                            <term>-    </term>
-
-                            <listitem>
-
-                                <para>ハンドル(図およびuicontrolのみ).</para>
-
-                            </listitem>
-
-                        </varlistentry>
-
-                    </variablelist>
-
-                </listitem>
-
-            </varlistentry>
-
-            <varlistentry>
-
-                <term>nam</term>
-
-                <listitem>
-
-                    <para>文字列</para>
-
-                </listitem>
-
-            </varlistentry>
-
-            <varlistentry>
-
-                <term>t</term>
-
-                <listitem>
-
-                    <para>文字列ベクトルで, 式またはダミー命令を含みます</para>
-
-                </listitem>
-
-            </varlistentry>
-
-            <varlistentry>
-
-                <term>lmax</term>
-
-                <listitem>
-
-                    <para>
-
-                        整数で, 行の最大長を有します.
-
-                        デフォルト値は<literal>0</literal>で,
-
-                        行の長さを制御を行わず,
-
-                        単一の文字列が返されることを示します.
-
-                    </para>
-
-                </listitem>
-
-            </varlistentry>
-
-        </variablelist>
-
-    </refsection>
-
-    <refsection>
-
-        <title>説明</title>
-
-        <para>
-
-            <function>sci2exp</function>は,
-
-            <varname>nam</varname>が指定されるた場合には
-
-            式を命令文字列に,さもなくば式文字列に変換します.
-
-        </para>
-
-    </refsection>
-
-    <refsection>
-
-        <title>注意</title>
-
-        <itemizedlist>
-
-            <listitem>
-
-                <para>
-
-                    <varname>a</varname> がハンドルの場合,
-
-                    <function>sci2exp</function> は階層的リンクがない結果
-
-                    つまり,親および子の空のフィールドの結果を出力します.
-
-                </para>
-
-            </listitem>
-
-            <listitem>
-
-                <para>
-
-                    <varname>t</varname> は,<link linkend="format">format</link>の
-
-                    影響を受けます.
-
-                </para>
-
-            </listitem>
-
-        </itemizedlist>
-
-    </refsection>
-
-    <refsection>
-
-        <title>例</title>
-
-        <programlisting role="example"><![CDATA[
-a=[1 2;3 4]
-sci2exp(a,'aa')
-sci2exp(a,'aa',10)
-sci2exp(ssrand(2,2,2))
-sci2exp(poly([1 0 3 4],'s'),'fi')
-sci2exp(figure("figure_name","figure1"))
-b=0.123456789;
-format(5);
-c=sci2exp(b)
-format(10);
-d=sci2exp(b)
-    ]]></programlisting>
-
-    </refsection>
-
-    <refsection role="see also">
-
-        <title>参照</title>
-
-        <simplelist type="inline">
-
-            <member>
-
-                <link linkend="prettyprint">prettyprint</link>
-
-            </member>
-
-            <member>
-
-                <link linkend="format">format</link>
-
-            </member>
-
-        </simplelist>
-
-    </refsection>
-
-</refentry>
-
diff --git a/scilab/modules/string/help/pt_BR/sci2exp.xml b/scilab/modules/string/help/pt_BR/sci2exp.xml
deleted file mode 100644 (file)
index ab3bb60..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 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="sci2exp" xml:lang="pt">
-    <refnamediv>
-        <refname>sci2exp</refname>
-        <refpurpose>converte uma expressão para um string</refpurpose>
-    </refnamediv>
-    <refsynopsisdiv>
-        <title>Seqüência de Chamamento</title>
-        <synopsis>t=sci2exp(a [,nam] [,lmax])</synopsis>
-    </refsynopsisdiv>
-    <refsection>
-        <title>Parâmetros</title>
-        <variablelist>
-            <varlistentry>
-                <term>a</term>
-                <listitem>
-                    <para>expressão Scilab. Pode ser:</para>
-                    <variablelist>
-                        <varlistentry>
-                            <term>-</term>
-                            <listitem>
-                                <para>constante,</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-</term>
-                            <listitem>
-                                <para>polinomial</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-</term>
-                            <listitem>
-                                <para>matriz de strings</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-</term>
-                            <listitem>
-                                <para>lista</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-</term>
-                            <listitem>
-                                <para>matriz de booleanos</para>
-                            </listitem>
-                        </varlistentry>
-                    </variablelist>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>nam</term>
-                <listitem>
-                    <para>string</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>t</term>
-                <listitem>
-                    <para>vetor de strings, contém a expressão ou a instrução de
-                        simulação.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>lmax</term>
-                <listitem>
-                    <para>inteiro, contém o comprimento de linha máximo. O valor padrão
-                        é 90, <literal>lmax=0</literal> indica ausência de controle de
-                        comprimento de linha, um único string é retornado
-                    </para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-    </refsection>
-    <refsection>
-        <title>Descrição</title>
-        <para>
-            <literal>sci2exp</literal> converte expressão para um string de
-            instrução se <literal>nam</literal> for fornecido, ou para um string de
-            expressão.
-        </para>
-    </refsection>
-    <refsection>
-        <title>Exemplos</title>
-        <programlisting role="example"><![CDATA[
-a=[1 2;3 4]
-sci2exp(a,'aa')
-sci2exp(a,'aa',0)
-sci2exp(ssrand(2,2,2))
-sci2exp(poly([1 0 3 4],'s'),'fi')
- ]]></programlisting>
-    </refsection>
-    <refsection role="see also">
-        <title>Ver Também</title>
-        <simplelist type="inline">
-            <member>
-                <link linkend="prettyprint">prettyprint</link>
-            </member>
-        </simplelist>
-    </refsection>
-</refentry>
diff --git a/scilab/modules/string/help/ru_RU/sci2exp.xml b/scilab/modules/string/help/ru_RU/sci2exp.xml
deleted file mode 100644 (file)
index 8388641..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
- * Copyright (C) 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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xml:lang="ru" xml:id="sci2exp">
-    <refnamediv>
-        <refname>sci2exp</refname>
-        <refpurpose>преобразует выражение в строку</refpurpose>
-    </refnamediv>
-    <refsynopsisdiv>
-        <title>Синтаксис</title>
-        <synopsis>t = sci2exp(a [,nam] [,lmax])</synopsis>
-    </refsynopsisdiv>
-    <refsection>
-        <title>Аргументы</title>
-        <variablelist>
-            <varlistentry>
-                <term>a</term>
-                <listitem>
-                    <para>Scilab-выражение, может быть:</para>
-                    <variablelist>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>константа;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>полином;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>матрица строк;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>список;</para>
-                            </listitem>
-                        </varlistentry>
-                        <varlistentry>
-                            <term>-    </term>
-                            <listitem>
-                                <para>матрица логических значений.</para>
-                            </listitem>
-                        </varlistentry>
-                    </variablelist>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>nam</term>
-                <listitem>
-                    <para>символьная строка.</para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>t</term>
-                <listitem>
-                    <para>
-                        вектор строк, содержащих выражение или инструкцию.
-                    </para>
-                </listitem>
-            </varlistentry>
-            <varlistentry>
-                <term>lmax</term>
-                <listitem>
-                    <para>
-                        целое число, содержащее максимальную длину строки. По
-                        умолчанию оно равно <literal>90</literal>,
-                        <literal>lmax=0</literal> указывает, что нет управления
-                        длиной отдельной строки; возвращается одиночная строка.
-                    </para>
-                </listitem>
-            </varlistentry>
-        </variablelist>
-    </refsection>
-    <refsection>
-        <title>Описание</title>
-        <para>
-            Функция <function>sci2exp</function> преобразует выражение в строку
-            инструкции, если указано <varname>nam</varname> или в строку
-            выражения.
-        </para>
-    </refsection>
-    <refsection>
-        <title>Примеры</title>
-        <programlisting role="example"><![CDATA[
-a=[1 2;3 4]
-sci2exp(a,'aa')
-sci2exp(a,'aa',0)
-sci2exp(ssrand(2,2,2))
-sci2exp(poly([1 0 3 4],'s'),'fi')
-    ]]></programlisting>
-    </refsection>
-    <refsection role="see also">
-        <title>Смотрите также</title>
-        <simplelist type="inline">
-            <member>
-                <link linkend="prettyprint">prettyprint</link>
-            </member>
-        </simplelist>
-    </refsection>
-</refentry>
index 6ca61e7..d40753e 100644 (file)
@@ -283,8 +283,14 @@ function t=pol2exp(a,lmax)
     if rhs<2 then lmax = 0, end
     [lhs,rhs] = argn(0)
 
-    [m,n]=size(a),var=" ";lvar=1
-    var=varn(a),lvar=length(var);
+    [m,n] = size(a)
+    var = " ";
+    lvar = 1;
+    var = varn(a);
+    if or(var==["s" "z"]) then
+        var = "%"+var;
+    end
+    lvar=length(var);
     while part(var,lvar)==" " then lvar=lvar-1,end
     var=part(var,1:lvar);
     if m<0 then
diff --git a/scilab/modules/string/tests/nonreg_tests/bug_11933.tst b/scilab/modules/string/tests/nonreg_tests/bug_11933.tst
new file mode 100644 (file)
index 0000000..427cbe6
--- /dev/null
@@ -0,0 +1,35 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2017 - Samuel GOUGEON
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+//
+// <-- CLI SHELL MODE -->
+// <-- NO CHECK REF -->
+//
+// <-- Non-regression test for bug 11933 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/11933
+//
+// <-- Short Description -->
+// For any polynomial p -- noticeably in s or z --, evaluating sci2exp(p)
+// failed generating p.
+
+
+p = (2*%i-%z)^4;
+p = [p p p ; p p p];
+s = sci2exp(p);
+assert_checkequal(evstr(s), p);
+
+p = (3-%s*%i)^11;
+p = [p p p ; p p p];
+s = sci2exp(p);
+assert_checkequal(evstr(s), p);
+
+abc = poly(0,"abc");
+p = (4*%i-3*abc)^4;
+p = [p p p ; p p p];
+s = sci2exp(p);
+assert_checkequal(evstr(s), p);