b76838df0e2c558febc665082d527bfd5fe465d5
[scilab.git] / scilab / modules / elementary_functions / help / fr_FR / insertion.xml
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="insertion">
3     <refnamediv>
4         <refname>insertion</refname>
5         <refpurpose>insertion/modification dans une
6             variable
7         </refpurpose>
8     </refnamediv>
9     <refnamediv xml:id="affectation">
10         <refname>affectation</refname>
11         <refpurpose>affectation partielle d'une variable  </refpurpose>
12     </refnamediv>
13     <refsynopsisdiv>
14         <title>Séquence d'appel</title>
15         <synopsis>x(i,j)=a
16             x(i)=a
17             l(i)=a
18             l(k1)...(kn)(i)=a ou l(list(k1,...,kn,i))=a
19             l(k1)...(kn)(i,j)=a ou l(list(k1,...,kn,list(i,j))=a
20         </synopsis>
21     </refsynopsisdiv>
22     <refsection>
23         <title>Paramètres</title>
24         <variablelist>
25             <varlistentry>
26                 <term>x  </term>
27                 <listitem>
28                     <para>matrice de tout type
29                     </para>
30                 </listitem>
31             </varlistentry>
32             <varlistentry>
33                 <term>l  </term>
34                 <listitem>
35                     <para>liste
36                     </para>
37                 </listitem>
38             </varlistentry>
39             <varlistentry>
40                 <term>i,j  </term>
41                 <listitem>
42                     <para>indices
43                     </para>
44                 </listitem>
45             </varlistentry>
46             <varlistentry>
47                 <term>k1,...kn  </term>
48                 <listitem>
49                     <para>indices à valeurs entières
50                     </para>
51                 </listitem>
52             </varlistentry>
53             <varlistentry>
54                 <term>a  </term>
55                 <listitem>
56                     <para>nouvelles valeurs des termes
57                     </para>
58                 </listitem>
59             </varlistentry>
60         </variablelist>
61     </refsection>
62     <refsection>
63         <title>Description</title>
64         <variablelist>
65             <varlistentry>
66                 <term>CAS DES MATRICES</term>
67                 <listitem>
68                     <para/>
69                     <para>
70                         Si  <literal>x</literal> est un tableau <literal>i</literal> et <literal>j</literal> peuvent être :
71                     </para>
72                     <variablelist>
73                         <varlistentry>
74                             <term>Des scalaires, vecteurs ou matrices</term>
75                             <listitem>
76                                 <para>Dans ce cas, les valeurs données en
77                                     indices doivent être strictement positives. Seules les parties
78                                     entières sont prises en compte.
79                                 </para>
80                                 <itemizedlist>
81                                     <listitem>
82                                         <para>
83                                             Si <literal>a</literal> est une matrice de dimensions
84                                             <literal>(size(i,'*'),size(j,'*'))</literal>
85                                             <literal>x(i,j)=a</literal> renvoie une nouvelle matrice
86                                             <literal>x</literal> telle que <literal>x(int(i(l)),int(j(k)))=a(l,k)
87                                             </literal>
88                                             pour <literal>l</literal> variant de 1 à
89                                             <literal>size(i,'*')</literal> et <literal>k</literal> variant de
90                                             1 à <literal>size(j,'*')</literal>, les autres composantes
91
92                                             initiales de <literal>x</literal> sont inchangées.
93                                         </para>
94                                     </listitem>
95                                     <listitem>
96                                         <para>
97                                             Si <literal>a</literal> est un scalaire
98                                             <literal>x(i,j)=a</literal> renvoie une nouvelle matrice
99                                             <literal>x</literal> telle que <literal>x(int(i(l)),int(j(k)))=a </literal>
100                                             pour <literal>l</literal> variant de 1 à
101                                             <literal>size(i,'*')</literal> et <literal>k</literal> variant de
102                                             1 à <literal>size(j,'*')</literal>, les autres composantes
103                                             initiales de <literal>x</literal> sont inchangées.
104                                         </para>
105                                     </listitem>
106                                     <listitem>
107                                         <para>
108                                             Si la valeur maximum de <literal>i</literal> ou
109                                             <literal>j</literal> dépasse la dimension correspondante de
110                                             <literal>x</literal>, alors <literal>x</literal> est au préalable agrandie
111                                             aux dimensions adéquates en stockant des zéros pour les matrices
112                                             standard, des chaînes vides pour les matrices de chaînes de
113                                             caractères ou la valeur %F pour les matrices booléennes.
114                                         </para>
115                                     </listitem>
116                                     <listitem>
117                                         <para>
118                                             <literal>x(i,j)=[]</literal> détruit les lignes
119                                             spécifiées par <literal>i</literal> si <literal>j</literal> désigne toutes
120                                             les colonnes de <literal>x</literal> ou détruit les colonnes
121                                             spécifiées par <literal>j</literal> si <literal>i</literal> désigne toutes
122                                             les lignes de <literal>x</literal>. Dans tous les autres cas
123                                             <literal>x(i,j)=[]</literal> produit une erreur.
124                                         </para>
125                                     </listitem>
126                                     <listitem>
127                                         <para>
128                                             <literal>x(i)=a</literal> où <literal>a</literal> est un
129                                             vecteur renvoie une nouvelle matrice <literal>x</literal> telle que
130                                             <literal>x(int(i(l)))=a(l)</literal> pour <literal>l</literal> variant de 1
131                                             à <literal>size(i,'*')</literal> , les autres composantes
132                                             initiales de <literal>x</literal> sont inchangées.
133                                         </para>
134                                     </listitem>
135                                     <listitem>
136                                         <para>
137                                             <literal>x(i)=a</literal> où <literal>a</literal> est un
138                                             scalaire, renvoie une nouvelle matrice <literal>x</literal> telle que
139                                             <literal>x(int(i(l)))=a</literal> pour <literal>l</literal> variant de 1 à
140                                             <literal>size(i,'*')</literal> , les autres composantes
141                                             initiales de <literal>x</literal> sont inchangées.
142                                         </para>
143                                         <para>
144                                             Si la valeur maximum de <literal>i</literal> dépasse
145                                             <literal>size(x,1)</literal>, <literal>x</literal> est au préalable agrandie
146                                             aux dimensions adéquates en stockant des zéros pour les matrices
147                                             standard, des chaînes vides pour les matrices de chaînes de
148                                             caractères ou la valeur %F pour les matrices booléennes.
149                                         </para>
150                                         <variablelist>
151                                             <varlistentry>
152                                                 <term>Si</term>
153                                                 <listitem>
154                                                     <para>
155                                                         <literal>x</literal> est une matrice 1 x 1 <literal>a</literal> peut
156                                                         être un vecteur ligne (resp. colonne) de dimension
157                                                         <literal>size(i,'*')</literal>. La matrice
158                                                         <literal>x</literal> obtenue est un vecteur ligne
159                                                         (resp. colonne)
160                                                     </para>
161                                                 </listitem>
162                                             </varlistentry>
163                                             <varlistentry>
164                                                 <term>Si</term>
165                                                 <listitem>
166                                                     <para>
167                                                         <literal>x</literal> est un vecteur
168                                                         ligne (resp. colonne) <literal>a</literal> doit être un vecteur
169                                                         ligne (resp. colonne) de dimension
170                                                         <literal>size(i,'*')</literal>
171                                                     </para>
172                                                 </listitem>
173                                             </varlistentry>
174                                             <varlistentry>
175                                                 <term>Si</term>
176                                                 <listitem>
177                                                     <para>
178                                                         <literal>x</literal> est une matrice
179                                                         en général <literal>a</literal> doit être un vecteur ligne ou
180                                                         colonne de dimension <literal>size(i,'*')</literal> et
181                                                         la valeur maximum de<literal>i</literal> ne peut dépasser
182                                                         <literal>size(x,'*')</literal>,
183                                                     </para>
184                                                 </listitem>
185                                             </varlistentry>
186                                         </variablelist>
187                                     </listitem>
188                                     <listitem>
189                                         <para>
190                                             <literal>x(i)=[]</literal> supprime les termes
191
192
193                                             spécifiés par <literal>i</literal>.
194                                         </para>
195                                     </listitem>
196                                 </itemizedlist>
197                             </listitem>
198                         </varlistentry>
199                         <varlistentry>
200                             <term>Le : symbole</term>
201                             <listitem>
202                                 <para>
203                                     Le symbole <literal> : </literal> signifiant "tous les éléments".
204                                 </para>
205                                 <itemizedlist>
206                                     <listitem>
207                                         <para>
208                                             <literal>x(i,:)=a</literal> est interprété comme
209
210                                             <literal>x(i,1:size(x,2))=a</literal>
211                                         </para>
212                                     </listitem>
213                                     <listitem>
214                                         <para>
215                                             <literal>x(:,j)=a</literal> est interprété comme
216                                             <literal>x(1:size(x,1),j)=a</literal>
217                                         </para>
218                                     </listitem>
219                                     <listitem>
220                                         <para>
221                                             <literal>x(:)=a</literal> renvoie dans
222                                             <literal>x</literal> la matrice <literal>a</literal> remise en forme en
223                                             accord avec les dimensions de
224                                             x. <literal>size(x,'*')</literal> doit être égal
225                                             à<literal>size(a,'*')</literal>
226                                         </para>
227                                     </listitem>
228                                 </itemizedlist>
229                             </listitem>
230                         </varlistentry>
231                         <varlistentry>
232                             <term>Vecteurs de booléens</term>
233                             <listitem>
234                                 <para>  Si un indice
235
236                                     (<literal>i</literal> ou <literal>j</literal> ) est un vecteur de booléens, il
237                                     est interprété comme <literal>find(i)</literal> ou <literal>find(j)</literal>,
238                                     respectivement.
239                                 </para>
240                             </listitem>
241                         </varlistentry>
242                         <varlistentry>
243                             <term>Polynomes</term>
244                             <listitem>
245                                 <para>
246                                     Si un indice (<literal>i</literal> ou
247                                     <literal>j</literal> ) est un vecteur de polynômes ou de polynômes
248                                     implicites, il est interprété comme <literal>horner(i,m)</literal> ou
249                                     <literal>horner(j,n)</literal>, respectivement, où <literal>m</literal> et
250                                     <literal>n</literal> sont les dimensions de <literal>x</literal> associées.
251                                     Même si cette fonctionnalité marche pour tous les polynômes, il
252                                     est recommandé d'utiliser des polynômes dans <literal>$</literal>
253                                     par souci de lisibilité.
254                                 </para>
255                             </listitem>
256                         </varlistentry>
257                     </variablelist>
258                 </listitem>
259             </varlistentry>
260             <varlistentry>
261                 <term>CAS DES LISTES</term>
262                 <listitem>
263                     <itemizedlist>
264                         <listitem>
265                             <para>
266                                 S'ils sont présents les <literal>ki</literal> donnent le chemin
267                                 vers un terme d'une sous-liste de la liste
268                                 <literal>l</literal>. Ils permettent de faire une insertion récursive
269                                 directe sans utiliser de variable intermédiaire.  Les instructions
270                                 <literal>l(k1)...(kn)(i)=a</literal> et
271                                 <literal>l(list(k1,...,kn,i)=a)</literal> sont interprétées comme :
272                             </para>
273                             <para>
274                                 <literal>lk1 = l(k1)</literal>
275                                 <literal> ..  = ..  </literal>
276                             </para>
277                             <para>
278                                 <literal>lkn =   lkn-1(kn)</literal>
279                             </para>
280                             <para>
281                                 <literal>lkn(i) = a</literal>
282                                 <literal>lkn-1(kn) =lkn</literal>
283                                 <literal> ..  = ..</literal>
284                             </para>
285                             <para>
286                                 les instructions<literal>l(k1)...(kn)(i,j)=a</literal> et
287                                 <literal>l(list(k1,...,kn,list(i,j))=a</literal> sont interprétées
288                                 comme:
289                             </para>
290                             <para>
291                                 <literal>lk1 = l(k1)</literal>
292                                 <literal> ..  = ..  </literal>
293                             </para>
294                             <para>
295                                 <literal>lkn =lkn-1(kn)</literal>
296                                 <literal>lkn(i,j) = a</literal>
297                             </para>
298                             <para>
299                                 <literal>lkn-1(kn) = lkn</literal>
300                                 <literal> ..  = ..  </literal>
301                             </para>
302                             <para>
303                                 <literal>l(k1) = lk1</literal>
304                             </para>
305                         </listitem>
306                         <listitem>
307                             <para>
308                                 <literal>i</literal> peut être :
309                             </para>
310                             <itemizedlist>
311                                 <listitem>
312                                     <para>un scalaire réel positif (seule sa partie entière est prise en compte).
313                                         <literal>l(0)=a</literal> ajoute un terme "à gauche"
314                                         de la liste <literal>l(i)=a</literal> affecte <literal>a</literal> au
315                                         terme <literal>i</literal> de la liste <literal>l</literal>. Si
316                                         <literal>i&gt;size(l)</literal>, <literal>l</literal> est
317                                         préalablement agrandie et les termes créés sont de type
318                                         non-défini.  <literal>l(i)=null()</literal> supprime le terme
319                                         <literal>i</literal>th de la liste.
320                                     </para>
321                                 </listitem>
322                                 <listitem>
323                                     <para>
324                                         un polynôme. Si <literal>i</literal> est un
325
326                                         vecteur de polynômes ou de polynômes implicites il est
327                                         interprété comme <literal>horner(i,m)</literal> où
328                                         <literal>m=size(l)</literal>. Même si cette fonctionnalité marche
329                                         pour tous les polynômes, il est recommandé d'utiliser
330                                         des polynômes dans <literal>$</literal> par souci de lisibilité.
331                                     </para>
332                                 </listitem>
333                             </itemizedlist>
334                         </listitem>
335                         <listitem>
336                             <para>
337                                 <literal>k1,..kn</literal> peuvent être :
338                             </para>
339                             <itemizedlist>
340                                 <listitem>
341                                     <para>un polynôme, interprété comme
342                                         <literal>horner(ki,m)</literal> ou <literal>m</literal> est la taille de
343                                         la sous-liste correspondante.
344                                     </para>
345                                 </listitem>
346                                 <listitem>
347                                     <para>une chaîne de caractères associée à un nom
348
349                                         d'entrée de sous-liste.
350                                     </para>
351                                 </listitem>
352                             </itemizedlist>
353                         </listitem>
354                     </itemizedlist>
355                 </listitem>
356             </varlistentry>
357         </variablelist>
358     </refsection>
359     <refsection>
360         <title>Remarque</title>
361         <para>
362             Pour les matrices rationnelles et les systèmes dynamiques
363             linéaires stockés sous forme de représentation d'état, la
364             syntaxe <literal>x(i)</literal> ne doit pas être utilisée pour
365             l'insertion des éléments d'un vecteur, à cause de la
366             confusion possible avec l'insertion des éléments de liste. La
367             syntaxe <literal>x(1,j)</literal> où <literal>x(i,1)</literal> doit être
368             utilisée dans ce cas.
369         </para>
370     </refsection>
371     <refsection>
372         <title>Exemples</title>
373         <programlisting role="example"><![CDATA[
374 // CAS DES MATRICES
375 a=[1 2 3;4 5 6]
376 a(1,2)=10
377 a([1 1],2)=[-1;-2]
378 a(:,1)=[8;5]
379 a(1,3:-1:1)=[77 44 99]
380 a(1)=%s
381 a(6)=%s+1
382 a(:)=1:6
383 a([%t %f],1)=33
384 a(1:2,$-1)=[2;4]
385 a($:-1:1,1)=[8;7]
386 a($)=123
387 a(1,%pi)=1 //équivalent à a(1,3)=1
388 //
389 x='test'
390 x([4 5])=['4','5']
391 //
392 b=[1/%s,(%s+1)/(%s-1)]
393 b(1,1)=0
394 b(1,$)=b(1,$)+1
395 b(2)=[1 2] // le numérateur
396 // CAS des LISTES (types LIST et TLIST)
397 l=list(1,'qwerw',%s)
398 l(1)='Changed'
399 l(0)='Added'
400 l(%pi)=1 //équivalent à l(3)=1
401 l(6)=['one more';'added']
402 //
403 //
404 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
405 dts(2)('a')=33
406 dts(2)('b')(1,2)=-100
407  ]]></programlisting>
408     </refsection>
409     <refsection role="see also">
410         <title>Voir aussi</title>
411         <simplelist type="inline">
412             <member>
413                 <link linkend="find">find</link>
414             </member>
415             <member>
416                 <link linkend="horner">horner</link>
417             </member>
418             <member>
419                 <link linkend="parentheses">parentheses</link>
420             </member>
421             <member>
422                 <link linkend="extraction">extraction</link>
423             </member>
424         </simplelist>
425     </refsection>
426 </refentry>