summaryrefslogtreecommitdiffstats
path: root/scilab/modules/data_structures
diff options
context:
space:
mode:
authorClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
committerClément David <clement.david@esi-group.com>2021-07-15 15:50:48 +0200
commit81a9cc049332de0c712cf56da585fcd25c8e59e3 (patch)
treef365c25a05c1782a16b2985bf7481116c106952d /scilab/modules/data_structures
parentb0937f19e4b8ddf416ca9a9a433bcbbd3f4ef2c0 (diff)
parent90b4ecb9b57ac6ad4e00d4a99b0d8bd1a6424403 (diff)
downloadscilab-master.zip
scilab-master.tar.gz
Merge remote-tracking branch 'origin/6.1'HEADmaster
Change-Id: I5d26fc380a28efe0bb6d0096fe9684b274b55bfe
Diffstat (limited to 'scilab/modules/data_structures')
-rw-r--r--scilab/modules/data_structures/Makefile.in2
-rw-r--r--scilab/modules/data_structures/help/en_US/struct.xml265
-rw-r--r--scilab/modules/data_structures/help/fr_FR/struct.xml91
-rw-r--r--scilab/modules/data_structures/help/ja_JP/struct.xml73
-rw-r--r--scilab/modules/data_structures/help/pt_BR/struct.xml79
-rw-r--r--scilab/modules/data_structures/help/ru_RU/struct.xml260
6 files changed, 458 insertions, 312 deletions
diff --git a/scilab/modules/data_structures/Makefile.in b/scilab/modules/data_structures/Makefile.in
index 1b26ebb..eb065b2 100644
--- a/scilab/modules/data_structures/Makefile.in
+++ b/scilab/modules/data_structures/Makefile.in
@@ -409,9 +409,11 @@ NMEDIT = @NMEDIT@
409OBJDUMP = @OBJDUMP@ 409OBJDUMP = @OBJDUMP@
410OBJEXT = @OBJEXT@ 410OBJEXT = @OBJEXT@
411OCAMLC = @OCAMLC@ 411OCAMLC = @OCAMLC@
412OCAMLCFLAGS = @OCAMLCFLAGS@
412OCAMLDEP = @OCAMLDEP@ 413OCAMLDEP = @OCAMLDEP@
413OCAMLLEX = @OCAMLLEX@ 414OCAMLLEX = @OCAMLLEX@
414OCAMLOPT = @OCAMLOPT@ 415OCAMLOPT = @OCAMLOPT@
416OCAMLOPTFLAGS = @OCAMLOPTFLAGS@
415OCAMLYACC = @OCAMLYACC@ 417OCAMLYACC = @OCAMLYACC@
416OPENMPI_CC = @OPENMPI_CC@ 418OPENMPI_CC = @OPENMPI_CC@
417OPENMPI_CFLAGS = @OPENMPI_CFLAGS@ 419OPENMPI_CFLAGS = @OPENMPI_CFLAGS@
diff --git a/scilab/modules/data_structures/help/en_US/struct.xml b/scilab/modules/data_structures/help/en_US/struct.xml
index 1e85ca3..0394c38 100644
--- a/scilab/modules/data_structures/help/en_US/struct.xml
+++ b/scilab/modules/data_structures/help/en_US/struct.xml
@@ -1,9 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA 4 * Copyright (C) 2006 - 2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -13,14 +13,18 @@
13 * along with this program. 13 * along with this program.
14 * 14 *
15 --> 15 -->
16<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="struct"> 16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
18 xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="struct">
17 <refnamediv> 19 <refnamediv>
18 <refname>struct</refname> 20 <refname>struct</refname>
19 <refpurpose>create a struct</refpurpose> 21 <refpurpose>Builds a structure or an array of structures</refpurpose>
20 </refnamediv> 22 </refnamediv>
21 <refsynopsisdiv> 23 <refsynopsisdiv>
22 <title>Syntax</title> 24 <title>Syntax</title>
23 <synopsis>st = struct(field1, value1, field2, value2, ...)</synopsis> 25 <synopsis>
26 st = struct(field1, value1, field2, value2, ...)
27 </synopsis>
24 </refsynopsisdiv> 28 </refsynopsisdiv>
25 <refsection> 29 <refsection>
26 <title>Arguments</title> 30 <title>Arguments</title>
@@ -28,76 +32,251 @@
28 <varlistentry> 32 <varlistentry>
29 <term>field1, field2, ...</term> 33 <term>field1, field2, ...</term>
30 <listitem> 34 <listitem>
31 <para>strings representing the fields names.</para> 35 strings: Case-sensitive names of the fields of the structure.
36 <para/>
32 </listitem> 37 </listitem>
33 </varlistentry> 38 </varlistentry>
34 <varlistentry> 39 <varlistentry>
35 <term>value1, value2, ...</term> 40 <term>value1, value2, ...</term>
36 <listitem> 41 <listitem>
37 <para> 42 <para>
38 all data type (<literal>double</literal>, <literal>char</literal>, <literal>int</literal>, ...), representing the fields values. 43 Data assigned to the respective fields. All data types are supported.
44 </para>
45 <para/>
46 <para>
47 If several values are non-scalar cells arrays, then they must have the same size.
48 For any scalar cell, the cell's container is stripped off, and its content
49 is considered and assigned to the field as a whole. The processing of non-scalar
50 cells is described here-below.
39 </para> 51 </para>
52 <para/>
53 </listitem>
54 </varlistentry>
55 <varlistentry>
56 <term>st</term>
57 <listitem>
58 Scalar structure, or array of structures if at least one value is a non-scalar
59 cells array.
60 <para/>
40 </listitem> 61 </listitem>
41 </varlistentry> 62 </varlistentry>
42 </variablelist> 63 </variablelist>
43 </refsection> 64 </refsection>
44 <refsection> 65 <refsection>
45 <title>Description</title> 66 <title>Description</title>
67 <refsect3>
68 <title>Scalar structure</title>
69 <para>
70 <emphasis role="bold">If none of values <literal>value1</literal>,
71 <literal>value2</literal>, ..., <literal>valueN</literal> is a non-scalar
72 cells array</emphasis>,
73 <literal>st = struct(field1, value1, field2, value2, ...)</literal> builds
74 a scalar structure <varname>st</varname> (of size 1×1) with fields and values
75 <literal>st.field1=value1</literal>, <literal>st.field2=value2</literal>, ...,
76 <literal>st.fieldN=valueN</literal>.
77 </para>
78 <para>
79 The value of any field of such a scalar structure can be a scalar or an array.
80 The sizes of values of distinct fields can be distinct. Example:
81 <literal>st = struct("u",[2 3], "v",[%t %f ; %f %t], "w","Hello")</literal> is
82 perfectly allowed and sets <literal>st.u=[2 3]</literal>,
83 <literal>st.v=[%t %f ; %f %t]</literal>, and <literal>st.w="Hello"</literal>
84 </para>
85 <para>
86 It is possible to assign a scalar or non-scalar cells array to the field of a
87 scalar structure by embedding it in a scalar cell. Examples:
88 <literal>st = struct("num",1:3, "c",{{sin}})</literal> will set
89 <literal>st.num=1:3</literal> and <literal>st.c={sin}</literal> ; while
90 <literal>st = struct("text","Hello", "test",{{1, sin ; %t %z}})</literal> will set
91 <literal>st.text="Hello"</literal> and <literal>st.test={1,sin;%t,%z}</literal>.
92 </para>
93 </refsect3>
94 <refsect3>
95 <title>Array of structures</title>
96 <para>
97 struct(..) allows to build any array -- vector, matrix or ND-array -- of structures.
98 All elements of the array have then the same set of fields <varname>field1</varname>,
99 <varname>field2</varname>, .., <varname>fieldN</varname>.
100 </para>
101 <para>
102 Indeed, <emphasis role="bold">when at least one of the given values is a non-scalar
103 cells array</emphasis>
104 <literal>C</literal>, <literal>st=struct(..,field,C,..)</literal> builds an array
105 of structures with <literal>size(st)==size(C)</literal>, and sets
106 <literal>st(i).field=C{i}</literal> for any index i.
107 </para>
108 <para>
109 In this case, any scalar values defined for some other specified fields are
110 replicated and set for all <varname>st</varname> elements.
111 </para>
112 <para>
113 Example #1: <literal>st=struct("u", {-1,%f,%z})</literal> defines a 1×3 row vector
114 of structures with a single field "u" with values <literal>st(1).u=-1</literal>,
115 <literal>st(2).u=%f</literal>, and <literal>st(3).u=%z</literal>.
116 </para>
117 <para>
118 Example #2: <literal>st=struct("u", {-1 ; %f}, "t", "Hi")</literal> defines a 2×1
119 column vector of structures with two fields "u" and "t" with values
120 <literal>st(1,1).u=-1</literal>, <literal>st(1,1).t="Hi"</literal>,
121 <literal>st(2,1).u=%f</literal>, <literal>st(2,1).t="Hi"</literal>.
122 </para>
123 </refsect3>
124 <note>
125 <literal>type(st)</literal> returns <literal>17</literal>,
126 and <literal>typeof(st)</literal> returns <literal>"st"</literal>.
127 </note>
128 </refsection>
129 <refsection>
130 <title>Examples</title>
131 <programlisting role="example"><![CDATA[
132// Create a scalar Dates structure
133Dates = struct('day',25, 'month','DEC', 'year',2006)
134Dates.month = 'AUG' // change the month
135Dates.year = 1973; // change the year
136Dates.weekday = "Saturday" // Add a new field
137
138// Create a 2nd element, to make Dates a vector of dates:
139Dates(1,2).year = 2020
140Dates(2) // Note that the default fields value is []
141
142// Building the full Dates(2) structure element for all fields.
143// The same fields can be declared in any other order:
144Dates(2) = struct('year',2000, 'day',29, 'weekday',"Tuesday", 'month', "FEB")
145Dates(2)
146Dates(2,3) = struct('weekday',"Sunday", 'day',7, 'month',"FEB", 'year',2021)
147Dates(2,3)
148size(Dates)
149length(Dates)
150 ]]></programlisting>
151 <screen><![CDATA[
152--> Dates = struct('day',25, 'month','DEC', 'year',2006)
153 Dates =
154 day = 25
155 month = "DEC"
156 year = 2006
157
158--> Dates.month = 'AUG' // change the month
159 Dates =
160 day = 25
161 month = "AUG"
162 year = 2006
163
164--> Dates.year = 1973; // change the year
165--> Dates.weekday = "Saturday" // Add a new field
166 Dates =
167 day = 25
168 month = "AUG"
169 year = 1973
170 weekday = "Saturday"
171
172--> // Create a 2nd element, to make Dates a vector of dates:
173--> Dates(1,2).year = 2020
174 Dates =
175 1x2 struct with fields:
176 ["day", "month", "year", "weekday"]
177
178--> Dates(2) // Note that the default fields value is []
179 ans =
180 day = []
181 month = []
182 year = 2020
183 weekday = []
184
185--> // Building the full Dates(2) structure element for all fields.
186--> // The same fields can be declared in any other order:
187--> Dates(2) = struct('year',2000, 'day',29, 'weekday',"Tuesday", 'month', "FEB")
188 Dates =
189 1x2 struct with fields:
190 ["day", "month", "year", "weekday"]
191
192--> Dates(2)
193 ans =
194 day = 29
195 month = "FEB"
196 year = 2000
197 weekday = "Tuesday"
198
199--> Dates(2,3) = struct('weekday',"Sunday", 'day',7, 'month',"FEB", 'year',2021)
200 Dates =
201 2x3 struct with fields:
202 ["day", "month", "year", "weekday"]
203
204--> Dates(2,3)
205 ans =
206 day = 7
207 month = "FEB"
208 year = 2021
209 weekday = "Sunday"
210
211--> size(Dates)
212 ans =
213 2. 3.
214
215--> length(Dates)
216 ans =
217 6.
218]]></screen>
46 <para> 219 <para>
47 This function returns a struct with the fields names 220 <emphasis role="bold">Array of structures built from scratch:</emphasis>
48 <varname>field1</varname>, <varname>field2</varname>, ..., and the fields values
49 corresponding <varname>value1</varname>, <varname>value2</varname>, ...
50 </para> 221 </para>
222 <programlisting role="example"><![CDATA[
223Dates = struct("day",{10 3 ; 25 17}, "month",{"SEP" "JUN" ; "APR" "NOV"}, "year",2020)
224Dates(2,1)
225 ]]></programlisting>
226 <screen><![CDATA[
227--> Dates = struct("day",{10 3 ; 25 17}, "month",{"SEP" "JUN" ; "APR" "NOV"}, "year",2020)
228 Dates =
229 2x2 struct with fields:
230 ["day", "month", "year"]
231
232--> Dates(2,1)
233 ans =
234 day = 25
235 month = "APR"
236 year = 2020
237]]></screen>
51 <para> 238 <para>
52 Note that <literal>type(st)</literal> returns <literal>17</literal>, and <literal>typeof(st)</literal> returns <literal>st</literal>. 239 <emphasis role="bold">Structure with cells as a field's value:</emphasis>
53 </para> 240 </para>
54 </refsection>
55 <refsection>
56 <title>Examples</title>
57 <programlisting role="example"><![CDATA[ 241 <programlisting role="example"><![CDATA[
58//create a struct date 242test = struct("number", %pi, "bool",[%f %f], "myCell",{{2 "-5";(1-%z)^3,%t}})
59date_st=struct('day',25,'month' ,'DEC','year',2006) 243test.myCell
60//change the month 244test.myCell{2,1}
61date_st.month='AUG'; 245 ]]></programlisting>
62//change the year 246 <screen><![CDATA[
63date_st.year=1973; 247--> test = struct("number", %pi, "bool",[%f %f], "myCell",{{2 "-5";(1-%z)^3,%t}})
64//change the day 248 test =
65date_st.day=19; 249 number = 3.1415927
66//add a new field 250 bool = [%f,%f]
67date_st.semaine=32 251 myCell: [2x2 cell]
252
253--> test.myCell
254 ans =
255 [1x1 constant ] [1x1 string ]
256 [1x1 polynomial] [1x1 boolean]
68 257
69//create a structure test 258--> test.myCell{2,1}
70test=struct('list1',list('testlist',1,2), 'matrix1', [1 2 3; 4 5 6], 'boolean1', %t); 259 ans =
71//add a polynom 260 1 -3z +3z² -z³
72s=poly(0,'s') 261]]></screen>
73test.pol1=s;
74//add a state-space
75A=[0,1;0,0]; B=[1;1];C=[1,1];
76test.ss1=syslin('c',A,B,C);
77//Show the list
78test.list1
79getfield(3,test)
80//Show the type
81type(test)
82 ]]></programlisting>
83 </refsection> 262 </refsection>
84 <refsection role="see also"> 263 <refsection role="see also">
85 <title>See also</title> 264 <title>See also</title>
86 <simplelist type="inline"> 265 <simplelist type="inline">
87 <member> 266 <member>
88 <link linkend="cell">cell</link> 267 <link linkend="fieldnames">fieldnames</link>
89 </member> 268 </member>
90 <member> 269 <member>
91 <link linkend="mlist">mlist</link> 270 <link linkend="tree_show">tree_show</link>
92 </member> 271 </member>
93 <member> 272 <member>
94 <link linkend="tlist">tlist</link> 273 <link linkend="makecell">makecell</link>
95 </member> 274 </member>
96 <member> 275 <member>
97 <link linkend="getfield">getfield</link> 276 <link linkend="mlist">mlist</link>
98 </member> 277 </member>
99 <member> 278 <member>
100 <link linkend="setfield">setfield</link> 279 <link linkend="tlist">tlist</link>
101 </member> 280 </member>
102 </simplelist> 281 </simplelist>
103 </refsection> 282 </refsection>
diff --git a/scilab/modules/data_structures/help/fr_FR/struct.xml b/scilab/modules/data_structures/help/fr_FR/struct.xml
deleted file mode 100644
index 64154064..0000000
--- a/scilab/modules/data_structures/help/fr_FR/struct.xml
+++ /dev/null
@@ -1,91 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<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="struct">
3 <refnamediv>
4 <refname>struct</refname>
5 <refpurpose>creer une struct</refpurpose>
6 </refnamediv>
7 <refsynopsisdiv>
8 <title>Séquence d'appel</title>
9 <synopsis>st=struct(field1,value1,field2,value2, ...)</synopsis>
10 </refsynopsisdiv>
11 <refsection>
12 <title>Paramètres</title>
13 <variablelist>
14 <varlistentry>
15 <term>field1, field2, ...</term>
16 <listitem>
17 <para>noms des champs (chaines de caracteres)</para>
18 </listitem>
19 </varlistentry>
20 <varlistentry>
21 <term>value1, value2, ...</term>
22 <listitem>
23 <para>les valeurs des champs (acceptent tous types de données
24 (double, matrice de doubles,des cells, char, ...)
25 </para>
26 </listitem>
27 </varlistentry>
28 </variablelist>
29 </refsection>
30 <refsection>
31 <title>Description</title>
32 <para>
33 La fonction <function>struct</function> retourne une struct avec des noms de
34 champs <varname>field1</varname>, <varname>field2</varname>, .., et dont les valeurs
35 respectives sont <varname>value1</varname>, <varname>value2</varname>,
36 ...
37 </para>
38 <para>
39 Notez que <literal>type(st)</literal> retourne <literal>17</literal> et que <literal>typeof(st)</literal> retourne <literal>st</literal>.
40 </para>
41 </refsection>
42 <refsection>
43 <title>Exemples</title>
44 <programlisting role="example"><![CDATA[
45//creer une struct: date les champs sont: 'jour' (valeur: 25), 'mois' (valeur: 'DEC'), 'annee' (valeur: 2006)
46date_st=struct('jour',25,'mois','DEC','annee',2006)
47
48// changer la valeur des champs
49date_st.jour=19;
50date_st.mois='AOU';
51date_st.annee=1973;
52
53// ajouter un champ 'semaine'
54date_st.semaine=32
55
56//creation d'une structure test
57test=struct('list1',list('testlist',1,2), 'matrix1', [1 2 3; 4 5 6], 'boolean1', %t);
58//ajout d'un polynôme
59s=poly(0,'s')
60test.pol1=s;
61//ajout d'un système linéaire (représentation d'état)
62A=[0,1;0,0]; B=[1;1];C=[1,1];
63test.ss1=syslin('c',A,B,C);
64//Affichage de la liste
65test.list1
66getfield(3,test)
67//Affichage du type
68type(test)
69 ]]></programlisting>
70 </refsection>
71 <refsection role="see also">
72 <title>Voir aussi</title>
73 <simplelist type="inline">
74 <member>
75 <link linkend="cell">cell</link>
76 </member>
77 <member>
78 <link linkend="mlist">mlist</link>
79 </member>
80 <member>
81 <link linkend="tlist">tlist</link>
82 </member>
83 <member>
84 <link linkend="getfield">getfield</link>
85 </member>
86 <member>
87 <link linkend="setfield">setfield</link>
88 </member>
89 </simplelist>
90 </refsection>
91</refentry>
diff --git a/scilab/modules/data_structures/help/ja_JP/struct.xml b/scilab/modules/data_structures/help/ja_JP/struct.xml
deleted file mode 100644
index f5115ce..0000000
--- a/scilab/modules/data_structures/help/ja_JP/struct.xml
+++ /dev/null
@@ -1,73 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
14 *
15 -->
16<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="struct">
17 <refnamediv>
18 <refname>struct</refname>
19 <refpurpose>構造体を作成する</refpurpose>
20 </refnamediv>
21 <refsynopsisdiv>
22 <title>呼び出し手順</title>
23 <synopsis>st=struct(field1,value1,field2,value2...)</synopsis>
24 </refsynopsisdiv>
25 <refsection>
26 <title>パラメータ</title>
27 <variablelist>
28 <varlistentry>
29 <term>field1, field2, ..</term>
30 <listitem>
31 <para>フィールド名を表す文字列</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term>value1, value2, ..</term>
36 <listitem>
37 <para>フィールドの値を表すデータ型 (double, char, int, ...)</para>
38 </listitem>
39 </varlistentry>
40 </variablelist>
41 </refsection>
42 <refsection>
43 <title>説明</title>
44 <para>この関数はフィールド名
45 <literal>fields1</literal>, <literal>field2</literal>, ..., を有し,
46 その値が<literal>value1</literal>, <literal>value2</literal>, ...
47 となる構造体を返します.
48 </para>
49 </refsection>
50 <refsection>
51 <title>例</title>
52 <programlisting role="example"><![CDATA[
53// create a struct date
54date=struct('day',25,'month' ,'DEC','year',2006)
55//change the month
56date.month='AUG';
57// change the year
58date.year=1973;
59//change the day
60date.day=19;
61// add a new field
62date.semaine=32
63 ]]></programlisting>
64 </refsection>
65 <refsection role="see also">
66 <title>参照</title>
67 <simplelist type="inline">
68 <member>
69 <link linkend="cell">cell</link>
70 </member>
71 </simplelist>
72 </refsection>
73</refentry>
diff --git a/scilab/modules/data_structures/help/pt_BR/struct.xml b/scilab/modules/data_structures/help/pt_BR/struct.xml
deleted file mode 100644
index 65923d8..0000000
--- a/scilab/modules/data_structures/help/pt_BR/struct.xml
+++ /dev/null
@@ -1,79 +0,0 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises
7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
10 * This file was originally licensed under the terms of the CeCILL v2.1,
11 * and continues to be available under such terms.
12 * For more information, see the COPYING file which you should have received
13 * along with this program.
14 *
15 -->
16<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="struct" xml:lang="pt">
17 <refnamediv>
18 <refname>struct</refname>
19 <refpurpose>criando um struct (estrutura)</refpurpose>
20 </refnamediv>
21 <refsynopsisdiv>
22 <title>Seqüência de Chamamento</title>
23 <synopsis>st=struct(field1,value1,field2,value2...)</synopsis>
24 </refsynopsisdiv>
25 <refsection>
26 <title>Parâmetros</title>
27 <variablelist>
28 <varlistentry>
29 <term>field1, field2, ..</term>
30 <listitem>
31 <para>strings, representam os nomes dos campos</para>
32 </listitem>
33 </varlistentry>
34 <varlistentry>
35 <term>value1, value2, ..</term>
36 <listitem>
37 <para>todos os tipos de dados (double, char, int, ...), representam
38 os valores dos campos
39 </para>
40 </listitem>
41 </varlistentry>
42 </variablelist>
43 </refsection>
44 <refsection>
45 <title>Descrição</title>
46 <para>Esta função retorna uma estrutura com campos de nomes
47 <literal>fields1</literal>, <literal>field2</literal>, ..., e valores
48 correspondentes <literal>value1</literal>, <literal>value2</literal>,
49 ...
50 </para>
51 </refsection>
52 <refsection>
53 <title>Exemplos</title>
54 <programlisting role="example"><![CDATA[
55// criando um dado struct
56date_st=struct('dia',25,'mes' ,'DEZ','ano',2006)
57
58//mudando o mes
59date_st.mes='AGO';
60
61// mudando o ano
62date_st.ano=1973;
63
64//mudando o dia
65date_st.dia=19;
66
67// adicionando um novo campo
68date_st.semana=32
69 ]]></programlisting>
70 </refsection>
71 <refsection role="see also">
72 <title>Ver Também</title>
73 <simplelist type="inline">
74 <member>
75 <link linkend="cell">cell</link>
76 </member>
77 </simplelist>
78 </refsection>
79</refentry>
diff --git a/scilab/modules/data_structures/help/ru_RU/struct.xml b/scilab/modules/data_structures/help/ru_RU/struct.xml
index 6ad5727..a76e7f6 100644
--- a/scilab/modules/data_structures/help/ru_RU/struct.xml
+++ b/scilab/modules/data_structures/help/ru_RU/struct.xml
@@ -1,9 +1,9 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0" encoding="UTF-8"?>
2<!-- 2<!--
3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab 3 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4 * Copyright (C) 2006-2008 - INRIA 4 * Copyright (C) 2006 - 2008 - INRIA
5 *
6 * Copyright (C) 2012 - 2016 - Scilab Enterprises 5 * Copyright (C) 2012 - 2016 - Scilab Enterprises
6 * Copyright (C) 2020 - Samuel GOUGEON
7 * 7 *
8 * This file is hereby licensed under the terms of the GNU GPL v2.0, 8 * This file is hereby licensed under the terms of the GNU GPL v2.0,
9 * pursuant to article 5.3.4 of the CeCILL v.2.1. 9 * pursuant to article 5.3.4 of the CeCILL v.2.1.
@@ -13,14 +13,18 @@
13 * along with this program. 13 * along with this program.
14 * 14 *
15 --> 15 -->
16<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="struct"> 16<refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
17 xmlns:svg="http://www.w3.org/2000/svg" xmlns:db="http://docbook.org/ns/docbook"
18 xmlns:scilab="http://www.scilab.org" xml:lang="ru" xml:id="struct">
17 <refnamediv> 19 <refnamediv>
18 <refname>struct</refname> 20 <refname>struct</refname>
19 <refpurpose>соа структуру</refpurpose> 21 <refpurpose>строт струтуру ли мив структур</refpurpose>
20 </refnamediv> 22 </refnamediv>
21 <refsynopsisdiv> 23 <refsynopsisdiv>
22 <title>Синтаксис</title> 24 <title>Синтаксис</title>
23 <synopsis>st = struct(field1, value1, field2, value2, ...)</synopsis> 25 <synopsis>
26 st = struct(field1, value1, field2, value2, ...)
27 </synopsis>
24 </refsynopsisdiv> 28 </refsynopsisdiv>
25 <refsection> 29 <refsection>
26 <title>Аргументы</title> 30 <title>Аргументы</title>
@@ -28,52 +32,256 @@
28 <varlistentry> 32 <varlistentry>
29 <term>field1, field2, ...</term> 33 <term>field1, field2, ...</term>
30 <listitem> 34 <listitem>
31 <para>строки, представляющие имена полей.</para> 35 строки: имена полей структуры с учётом регистра. Разрешены
36 расширенные не-ascii UTF-символы.
37 <para/>
32 </listitem> 38 </listitem>
33 </varlistentry> 39 </varlistentry>
34 <varlistentry> 40 <varlistentry>
35 <term>value1, value2, ...</term> 41 <term>value1, value2, ...</term>
36 <listitem> 42 <listitem>
37 <para> 43 данные, присвоенные соответствующим полям. Поддерживаются все
38 все типы данных (<literal>double</literal>, <literal>char</literal>, <literal>int</literal>, ...), представляющие значения полей. 44 типы данных. Если несколько значений являются нескалярными
39 </para> 45 cell-массивами, то они должны быть одинакового размера. Для
46 любого cell-скаляра cell-контейнер удаляется и его содержимое
47 рассматривается и присваивается полю как единое целое. Обработка
48 cell-массивов описана ниже.
49 <para/>
50 </listitem>
51 </varlistentry>
52 <varlistentry>
53 <term>st</term>
54 <listitem>
55 скалярная структура или массив структур, если хотя бы одно
56 значение является нескалярным cell-массивом.
57 <para/>
40 </listitem> 58 </listitem>
41 </varlistentry> 59 </varlistentry>
42 </variablelist> 60 </variablelist>
43 </refsection> 61 </refsection>
44 <refsection> 62 <refsection>
45 <title>Описание</title> 63 <title>Описание</title>
46 <para> 64 <refsect3>
47 Эта функция возвращает структуру с именами полей 65 <title>Скалярная структура</title>
48 <varname>fields1</varname>, <varname>field2</varname>, ..., и значениями полей, соответственно, <varname>value1</varname>, <varname>value2</varname>, ... 66 <para>
49 </para> 67 <emphasis role="bold">Если ни одно из значений <literal>value1</literal>,
68 <literal>value2</literal>, ..., <literal>valueN</literal> не
69 является нескалярным cell-массивом</emphasis>, то
70 <literal>st = struct(field1, value1, field2, value2, ...)</literal> строит
71 скалярную структуру <varname>st</varname> (размером 1×1) с полями
72 и значениями <literal>st.field1=value1</literal>,
73 <literal>st.field2=value2</literal>, ..., <literal>st.fieldN=valueN</literal>.
74 </para>
75 <para>
76 Значение любого поля такой скалярной структуры может быть скаляром
77 или массивом. Размеры значений разных полей могут быть разными.
78 Например:
79 <literal>st = struct("u",[2 3], "v",[%t %f ; %f %t], "w","Hello")</literal>
80 совершенно допустимо и устанавливает <literal>st.u=[2 3]</literal>,
81 <literal>st.v=[%t %f ; %f %t]</literal> и <literal>st.w="Hello"</literal>.
82 </para>
83 <para>
84 Можно присвоить скалярные или нескалярные cell-массивы полю
85 скалярной структуры, встраивая её в скалярный cell-массив. Например:
86 <literal>st = struct("num",1:3, "c",{{sin}})</literal> установит
87 <literal>st.num=1:3</literal> и <literal>st.c={sin}</literal> ;
88 в то время, как
89 <literal>st = struct("text","Hello", "test",{{1, sin ; %t %z}})</literal>
90 установит
91 <literal>st.text="Hello"</literal> и <literal>st.test={1,sin;%t,%z}</literal>.
92 </para>
93 </refsect3>
94 <refsect3>
95 <title>Массив структур</title>
96 <para>
97 struct(..) позволяет строить любой массив структур -- вектор,
98 матрицу или ND-массив. Все элементы массива имеют одинаковый набор
99 полей <varname>field1</varname>, <varname>field2</varname>, ...,
100 <varname>fieldN</varname>.
101 </para>
102 <para>
103 Действительно, <emphasis role="bold">если хотя бы одно из указанных
104 значений является нескалярным cell-массивом</emphasis> <literal>C</literal>,
105 то <literal>st=struct(..,field,C,..)</literal> строит массив структур
106 с <literal>size(st)==size(C)</literal> и устанавливает
107 <literal>st(i).field=C{i}</literal> для любого индекса <literal>i</literal>.
108 </para>
109 <para>
110 В этом случае любые скалярные величины, определённые для других определённых
111 полей, копируются и устанавливаются для всех элементов <varname>st</varname>.
112 </para>
113 <para>
114 Пример №1: <literal>st=struct("u", {-1,%f,%z})</literal> определяет
115 вектор-строку 1×3 структур с единственным полем "u" со значениями
116 <literal>st(1).u=-1</literal>, <literal>st(2).u=%f</literal> и
117 <literal>st(3).u=%z</literal>.
118 </para>
119 <para>
120 Пример №2: <literal>st=struct("u", {-1 ; %f}, "t", "Hi")</literal>
121 определяет вектор-столбец 2×1 структур с двумя полями "u" и "t"
122 со значениями <literal>st(1,1).u=-1</literal>,
123 <literal>st(1,1).t="Hi"</literal>, <literal>st(2,1).u=%f</literal>,
124 <literal>st(2,1).t="Hi"</literal>.
125 </para>
126 </refsect3>
127 <note>
128 <literal>type(st)</literal> возвращает <literal>17</literal>,
129 а <literal>typeof(st)</literal> возвращает <literal>"st"</literal>.
130 </note>
50 </refsection> 131 </refsection>
51 <refsection> 132 <refsection>
52 <title>Примеры</title> 133 <title>Примеры</title>
53 <programlisting role="example"><![CDATA[ 134 <programlisting role="example"><![CDATA[
54//создадим структуру данных 135// Создать скалярную структуру Dates
55date_st=struct('day',25,'month' ,'DEC','year',2006) 136Dates = struct('day',25, 'month','DEC', 'year',2006)
137Dates.month = 'AUG' // изменить месяц
138Dates.year = 1973; // изменить год
139Dates.weekday = "Saturday" // добавить новое поле
140
141// Создать второй элемент, чтобы сделать Dates вектором дат:
142Dates(1,2).year = 2020
143Dates(2) // Заметьте, что значение поля по умолчанию равно []
144
145// Построение элемента полной структуры Dates(2) для всех полей.
146// Одинаковые поля можно декларировать в любом порядке:
147Dates(2) = struct('year',2000, 'day',29, 'weekday',"Tuesday", 'month', "FEB")
148Dates(2)
149Dates(2,3) = struct('weekday',"Sunday", 'day',7, 'month',"FEB", 'year',2021)
150Dates(2,3)
151size(Dates)
152length(Dates)
153 ]]></programlisting>
154 <screen><![CDATA[
155--> Dates = struct('day',25, 'month','DEC', 'year',2006)
156 Dates =
157 day = 25
158 month = "DEC"
159 year = 2006
56 160
57//изменим месяц 161--> Dates.month = 'AUG' // change the month
58date_st.month='AUG'; 162 Dates =
163 day = 25
164 month = "AUG"
165 year = 2006
59 166
60//изменим год 167--> Dates.year = 1973; // change the year
61date_st.year=1973; 168--> Dates.weekday = "Saturday" // Add a new field
169 Dates =
170 day = 25
171 month = "AUG"
172 year = 1973
173 weekday = "Saturday"
62 174
63//изменим день 175--> // Create a 2nd element, to make Dates a vector of dates:
64date_st.day=19; 176--> Dates(1,2).year = 2020
177 Dates =
178 1x2 struct with fields:
179 ["day", "month", "year", "weekday"]
65 180
66//добавим новое поле 181--> Dates(2) // Note that the default fields value is []
67date_st.semaine=32 182 ans =
68 ]]></programlisting> 183 day = []
184 month = []
185 year = 2020
186 weekday = []
187
188--> // Building the full Dates(2) structure element for all fields.
189--> // The same fields can be declared in any other order:
190--> Dates(2) = struct('year',2000, 'day',29, 'weekday',"Tuesday", 'month', "FEB")
191 Dates =
192 1x2 struct with fields:
193 ["day", "month", "year", "weekday"]
194
195--> Dates(2)
196 ans =
197 day = 29
198 month = "FEB"
199 year = 2000
200 weekday = "Tuesday"
201
202--> Dates(2,3) = struct('weekday',"Sunday", 'day',7, 'month',"FEB", 'year',2021)
203 Dates =
204 2x3 struct with fields:
205 ["day", "month", "year", "weekday"]
206
207--> Dates(2,3)
208 ans =
209 day = 7
210 month = "FEB"
211 year = 2021
212 weekday = "Sunday"
213
214--> size(Dates)
215 ans =
216 2. 3.
217
218--> length(Dates)
219 ans =
220 6.
221]]></screen>
222 <para>
223 <emphasis role="bold">Массив структур, построенный с нуля:</emphasis>
224 </para>
225 <programlisting role="example"><![CDATA[
226Dates = struct("day",{10 3 ; 25 17}, "month",{"SEP" "JUN" ; "APR" "NOV"}, "year",2020)
227Dates(2,1)
228 ]]></programlisting>
229 <screen><![CDATA[
230--> Dates = struct("day",{10 3 ; 25 17}, "month",{"SEP" "JUN" ; "APR" "NOV"}, "year",2020)
231 Dates =
232 2x2 struct with fields:
233 ["day", "month", "year"]
234
235--> Dates(2,1)
236 ans =
237 day = 25
238 month = "APR"
239 year = 2020
240]]></screen>
241 <para>
242 <emphasis role="bold">Структура с cell-массивами в качестве значения
243 полей:</emphasis>
244 </para>
245 <programlisting role="example"><![CDATA[
246test = struct("number", %pi, "bool",[%f %f], "myCell",{{2 "-5";(1-%z)^3,%t}})
247test.myCell
248test.myCell{2,1}
249 ]]></programlisting>
250 <screen><![CDATA[
251--> test = struct("number", %pi, "bool",[%f %f], "myCell",{{2 "-5";(1-%z)^3,%t}})
252 test =
253 number = 3.1415927
254 bool = [%f,%f]
255 myCell: [2x2 cell]
256
257--> test.myCell
258 ans =
259 [1x1 constant ] [1x1 string ]
260 [1x1 polynomial] [1x1 boolean]
261
262--> test.myCell{2,1}
263 ans =
264 1 -3z +3z² -z³
265]]></screen>
69 </refsection> 266 </refsection>
70 <refsection role="see also"> 267 <refsection role="see also">
71 <title>Смотрите также</title> 268 <title>Смотрите также</title>
72 <simplelist type="inline"> 269 <simplelist type="inline">
73 <member> 270 <member>
74 <link linkend="cell">cell</link> 271 <link linkend="fieldnames">fieldnames</link>
272 </member>
273 <member>
274 <link linkend="tree_show">tree_show</link>
275 </member>
276 <member>
277 <link linkend="makecell">makecell</link>
278 </member>
279 <member>
280 <link linkend="mlist">mlist</link>
281 </member>
282 <member>
283 <link linkend="tlist">tlist</link>
75 </member> 284 </member>
76 </simplelist> 285 </simplelist>
77 </refsection> 286 </refsection>
78</refentry> 287</refentry>
79