- (ru): `weekday`
-User Interface improvements:
-----------------------------
+User Interface improvements
+---------------------------
* The `ans` variable is editable as any other variable in Editvar.
* Commands history is saved before executing a command to have the correct history on a crash.
- The menu "Issues" allows to display bugzilla entries related to the feature of the current page
- ATOMS chapters are automatically loaded in the browser.
- The page left at exit is restored at next startup.
+* `x_matrix` can now edit matrices of booleans, integers, or text. Matrices of real or complex numbers are better displayed.
+
Xcos
----
* [#13593](https://bugzilla.scilab.org/13593): `csvRead()` did not take the `range` into account when `header` is provided. `[]` could not be used as default `range`.
* [#13762](https://bugzilla.scilab.org/13762): In the `fft` page, the formula for the inverse FFT missed the 1/n normalization factor.
* [#13985](https://bugzilla.scilab.org/13985): The display of lists was very loose and poor.
+* [#14033](https://bugzilla.scilab.org/14033): `x_matrix` could not edit matrices of booleans, encoded integers or text. Matrices of real or complex numbers were poorly displayed.
* [#14435](https://bugzilla.scilab.org/14435): Errors were not well handled in overloaded functions.
* [#14488](https://bugzilla.scilab.org/14488): The `frameflag=9` and `strf=".9."` values of these `plot2d` options were no longer accepted. Their documentation was ambiguous.
* [#14718](https://bugzilla.scilab.org/14718): `user` is removed for a while but was still documented.
<?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: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="x_matrix">
+<!--
+ * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+ * Copyright (C) 2006-2008 - INRIA
+ * Copyright (C) 2012 - 2016 - Scilab Enterprises
+ * Copyright (C) 2020 - Samuel GOUGEON
+ *
+ * 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:db="http://docbook.org/ns/docbook"
+ xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="x_matrix">
<refnamediv>
<refname>x_matrix</refname>
- <refpurpose>Xwindow editing of matrix</refpurpose>
+ <refpurpose>Edits a matrix and waits for validation (modal)</refpurpose>
</refnamediv>
<refsynopsisdiv>
<title>Syntax</title>
- <synopsis>[result]=x_matrix(label,matrix-init)</synopsis>
+ <synopsis>
+ matrixOut = x_matrix(Header, matrixIn)</synopsis>
</refsynopsisdiv>
<refsection>
<title>Arguments</title>
<variablelist>
<varlistentry>
- <term>label</term>
+ <term>Header</term>
<listitem>
- <para>character string (name of matrix)</para>
+ column vector of text: Text displayed before the matrix.
+ Extended UTF-8 characters are supported.
+ Any element starting with "<body>" can use HTML.4 tags
+ afterward.
+ <para/>
</listitem>
</varlistentry>
<varlistentry>
- <term>matrix-init</term>
+ <term>matrixIn</term>
<listitem>
- <para>real matrix</para>
+ Initial vector or matrix of booleans, encoded integers, real or complex numbers,
+ or text.
+ <para/>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>matrixOut</term>
+ <listitem>
+ Modified matrix, of the same type than <varname>matrixIn</varname>,
+ if <emphasis role="bold">"OK"</emphasis> is pressed.
+ Or <literal>[]</literal> if <emphasis role="bold">"Cancel"</emphasis>
+ is pressed.
+ <para/>
</listitem>
</varlistentry>
</variablelist>
<refsection>
<title>Description</title>
<para>
- For reading or editing a matrix .
+ Edits a matrix in a modal way: Scilab is paused while the matrix is displayed and
+ the user can modify it. One of both buttons "OK" or "Cancel" must be clicked
+ to validate or cancel modifications. Either the modified matrix or []
+ is returned accordingly. Then Scilab resumes the execution of next instructions.
+ </para>
+ <para>
+ The pop-up is sized according to the displayed matrix. It can be resized interactively.
+ If it becomes narrower than the matrix or the header,
+ long header lines are wrapped, and some scroll bars appear.
</para>
</refsection>
<refsection>
<title>Examples</title>
<programlisting role="example"><![CDATA[
-m=evstr(x_matrix('enter a 3x3 matrix ',rand(3,3)))
- ]]></programlisting>
+i = int8(grand(3,4,"uin",-150,150))
+
+// With booleans
+b = i > 0
+m = x_matrix("<html><body>Matrix of <b>booleans", b)
+
+// With encoded integers
+m = x_matrix("<html><body>Matrix of <b>int8 integers", i)
+
+// With real numbers
+c = grand(5,4,"uin",-15,15) + grand(5,4,"uin",0,9)/10;
+c([14 8 16]) = [%nan %inf -%inf]
+m = x_matrix("<html><body>Matrix of <b>decimal numbers", c)
+
+// With complex numbers
+c = grand(5,3,"uin",-15,15) + grand(5,3,"uin",-15,15)*%i;
+c(2,2) = 3-1.24e-31*%i;
+c(4,3) = complex(0,%nan)
+m = x_matrix("<body>Matrix of <b>complex numbers", c)
+
+// With texts
+t = ["ab" "I don''t" "αβδεϵζ"
+ "j" """Yes""" "àéêèïôûù"]
+m = x_matrix("<body>Matrix of <b>text", t)
+ ]]></programlisting>
+ <para/>
+ <table>
+ <tr>
+ <td valign="top">
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_booleans.png" />
+ </imageobject>
+ </inlinemediaobject>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_integers.png" />
+ </imageobject>
+ </inlinemediaobject>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_text.png" />
+ </imageobject>
+ </inlinemediaobject>
+ </td>
+ </tr>
+ <tr>
+ <td valign="top">
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_reals.png" />
+ </imageobject>
+ </inlinemediaobject>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_complex.png" />
+ </imageobject>
+ </inlinemediaobject>
+ </td>
+ </tr>
+ </table>
+ <para/>
+ <para>
+ With a multiple-line and styled header:
+ </para>
+ <programlisting role="example"><![CDATA[
+//
+online = "https://help.scilab.org/docs/current/en_US/x_matrix.html";
+header = ["<body><h3>Head line"
+ "<body><b>Presentation:</b>"
+ "The pop-up can be resized. Some scroll bars may appear."
+ "<body>This <font color=''red''><b>word</b></font> is bold and red. " + ..
+ "<body>x_matrix <a href=''" + online + "''>online page</a>."
+ ]
+b = grand(4,14,"uin",-2,1) < 0
+m = x_matrix(header, b)
+ ]]></programlisting>
+ <para>
+ <inlinemediaobject>
+ <imageobject>
+ <imagedata fileref="../images/x_matrix_header_scrollbars.png" />
+ </imageobject>
+ </inlinemediaobject>
+ </para>
</refsection>
<refsection role="see also">
<title>See also</title>
<member>
<link linkend="x_dialog">x_dialog</link>
</member>
+ <member>
+ <link linkend="editvar">editvar</link>
+ </member>
+ <member>
+ <link linkend="uicontrol">uicontrol table</link>
+ </member>
+ <member>
+ <link linkend="messagebox">messagebox</link>
+ </member>
+ <member>
+ <link linkend="prettyprint">prettyprint</link>
+ </member>
</simplelist>
</refsection>
+ <refsection role="history">
+ <title>History</title>
+ <revhistory>
+ <revision>
+ <revnumber>6.1.1</revnumber>
+ <revdescription>
+ Booleans, encoded integers, and text are supported.
+ The display of real and complex matrices is improved.
+ </revdescription>
+ </revision>
+ </revhistory>
+ </refsection>
</refentry>
+++ /dev/null
-<?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: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="x_matrix">
- <refnamediv>
- <refname>x_matrix</refname>
- <refpurpose>行列を編集する Xwindow </refpurpose>
- </refnamediv>
- <refsynopsisdiv>
- <title>呼び出し手順</title>
- <synopsis>[result]=x_matrix(label,matrix-init)</synopsis>
- </refsynopsisdiv>
- <refsection>
- <title>引数</title>
- <variablelist>
- <varlistentry>
- <term>label</term>
- <listitem>
- <para>文字列 (行列の名前)</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>matrix-init</term>
- <listitem>
- <para>実数の行列</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refsection>
- <refsection>
- <title>説明</title>
- <para>
- 行列を読込または編集します.
- </para>
- </refsection>
- <refsection>
- <title>例</title>
- <programlisting role="example"><![CDATA[
-m=evstr(x_matrix('enter a 3x3 matrix ',rand(3,3)))
- ]]></programlisting>
- </refsection>
- <refsection role="see also">
- <title>参照</title>
- <simplelist type="inline">
- <member>
- <link linkend="x_mdialog">x_mdialog</link>
- </member>
- <member>
- <link linkend="x_dialog">x_dialog</link>
- </member>
- </simplelist>
- </refsection>
-</refentry>
// Copyright (C) INRIA
-//
// Copyright (C) 2012 - 2016 - Scilab Enterprises
+// Copyright (C) 2020 - Samuel GOUGEON
//
// 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.
// and continues to be available under such terms.
// For more information, see the COPYING file which you should have received
// along with this program.
-function [y] = x_matrix(mes, x)
+
+function y = x_matrix(mes, x)
[lhs, rhs] = argn(0);
if rhs < 2 then
error(sprintf(_("%s: Wrong number of input argument(s): %d expected.\n"), "x_matrix", 2));
end
- if type(x)<>1 then
- error(msprintf(gettext("%s: Wrong type for input argument #%d: A real expected.\n"), "x_matrix", 2));
+ if and(type(x) <> [1 4 8 10]) then
+ error(msprintf(_("%s: Argument #%d: Booleans, numbers, or text expected.\n"), "x_matrix", 2));
end
- [n1,n2] = size(x);
- z = string(x);
- y = [];
- for i=1:n1,
- y = [y; strcat(z(i,:), ", ")];
+
+ // Encoding
+ // --------
+ select type(x)
+ case 1
+ isReal = %T
+ rx = real(x)
+ sr = string(rx)
+ sr(rx>=0) = ascii(160) + sr(rx>=0)
+ sr = strsubst(justify(sr,"l"), ascii(160), " ")
+ if ~isreal(x,0) then
+ isReal = %f
+ im = imag(x)
+ si = string(abs(im)) + "i"
+ im = im >= 0
+ si(im) = "+ " + si(im)
+ si(~im) = "- " + si(~im)
+ y = sr + " " + justify(si,"l")
+ y = strcat(y, ", ", "c")
+ else
+ y = strcat(sr, ", ", "c")
+ end
+ case 4 // booleans
+ y = strcat(string(x), " ","c")
+ case 8 // integer
+ y = string(x)
+ y = strcat(justify(y, "r"), ", ", "c")
+ case 10 // strings
+ y = strsubst(x, """", """""")
+ y = strsubst(y, "''", "''''")
+ y = """" + y + """"
+ y = strcat(justify(y, "l"),", ","c")
+ if mes <> [] & stripblanks(mes) <> ""
+ mes = [mes ; ""]
+ end
+ mes = [mes ; _("<html>(quotes <b>"" ''</b> inside texts must be doubled)")]
end
- y(1) = "["+y(1);
- for i=2:n1,
- y(i) = " "+y(i);
+
+ // Modal prompt
+ // ------------
+ y = x_dialog(mes, y);
+
+ // Decoding
+ // --------
+ if y <> [] then
+ select type(x)
+ case 1
+ if ~isReal then
+ y = strsubst(y, " ", "")
+ fn = tempname()
+ csvWrite(y, fn, ",");
+ y = csvRead(fn, ",")
+ else
+ y = evstr(y)
+ end
+ case 4
+ y = strsubst(stripblanks(y), "T", "%T")
+ y = strsubst(y, "F", "%F")
+ y = "[" + strcat(y, ";") + "]"
+ y = evstr(y)
+ case 8
+ y = iconvert(evstr(y), inttype(x))
+ case 10
+ y = "[" + strcat(y, "; ") + "]"
+ y = evstr(y)
+ end
end
- y(n1) = y(n1)+"]";
- y = evstr(x_dialog(mes,y));
endfunction
--- /dev/null
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2020 - Samuel GOUGEON
+//
+// This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// unit tests for x_matrix() function
+// =============================================================================
+
+// <-- INTERACTIVE TEST -->
+// <-- TEST WITH GRAPHIC -->
+
+i = int8(grand(3,4,"uin",-150,150))
+
+// With booleans
+// -------------
+b = i > 0
+m = x_matrix("<html><body>Matrix of <b>booleans", b)
+assert_checkequal(type(m), 4);
+assert_checkequal(size(m), size(b));
+
+// With encoded integers
+// ---------------------
+m = x_matrix("<html><body>Matrix of <b>int8 integers", i)
+assert_checkequal(inttype(m), inttype(i));
+assert_checkequal(size(m), size(i));
+
+// With real numbers
+// -----------------
+c = grand(5,4,"uin",-15,15) + grand(5,4,"uin",0,9)/10;
+c([14 8 16]) = [%nan %inf -%inf]
+m = x_matrix("<html><body>Matrix of <b>decimal numbers", c)
+
+// With complex numbers
+// --------------------
+c = grand(5,3,"uin",-15,15) + grand(5,3,"uin",-15,15)*%i;
+c(2,2) = 3-1.24e-31*%i;
+c(4,3) = complex(0,%nan)
+m = x_matrix("<body>Matrix of <b>complex numbers", c)
+
+// With text
+// ---------
+t = ["ab" "I don''t" "αβδεϵζ"
+ "j" """Yes""" "àéêèïôûù"]
+m = x_matrix("<body>Matrix of <b>text", t)
+assert_checkequal(type(m), 10);
+