* Bug 16620 fixed: polyint() introduced
[scilab.git] / scilab / modules / elementary_functions / help / pt_BR / 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:ns3="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="insertion" xml:lang="pt">
3     <refnamediv>
4         <refname>insertion</refname>
5         <refpurpose>atribuição ou modificação parcial de variáveis</refpurpose>
6     </refnamediv>
7     <refnamediv xml:id="assignation">
8         <refname>assignation</refname>
9         <refpurpose>atribuição parcial de variáveis</refpurpose>
10     </refnamediv>
11     <refsynopsisdiv>
12         <title>Seqüência de Chamamento</title>
13         <synopsis>x(i,j)=a
14             x(i)=a
15             l(i)=a
16             l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
17             l(k1)...(kn)(i,j)=a or l(list(k1,...,kn,list(i,j))=a
18         </synopsis>
19     </refsynopsisdiv>
20     <refsection>
21         <title>Parâmetros</title>
22         <variablelist>
23             <varlistentry>
24                 <term>x</term>
25                 <listitem>
26                     <para>matriz de qualquer tipo</para>
27                 </listitem>
28             </varlistentry>
29             <varlistentry>
30                 <term>l</term>
31                 <listitem>
32                     <para>lista</para>
33                 </listitem>
34             </varlistentry>
35             <varlistentry>
36                 <term>i,j</term>
37                 <listitem>
38                     <para>índices</para>
39                 </listitem>
40             </varlistentry>
41             <varlistentry>
42                 <term>k1,...kn</term>
43                 <listitem>
44                     <para>índices com valores inteiros</para>
45                 </listitem>
46             </varlistentry>
47             <varlistentry>
48                 <term>a</term>
49                 <listitem>
50                     <para>novo valor de entrada</para>
51                 </listitem>
52             </varlistentry>
53         </variablelist>
54     </refsection>
55     <refsection>
56         <title>Descrição</title>
57         <variablelist>
58             <varlistentry>
59                 <term>CASO DE MATRIZES</term>
60                 <listitem>
61                     <para>
62                         Se <literal>x</literal> é uma matriz, os índices
63                         <literal>i</literal> e <literal>j</literal>, podem ser:
64                     </para>
65                     <variablelist>
66                         <varlistentry>
67                             <term>Escalares reais, vetores ou matrizes</term>
68                             <listitem>
69                                 <para>neste caso, os valores fornecidos como índices devem ser
70                                     inteiros e apenas suas partes inteiras são levadas em
71                                     consideração.
72                                 </para>
73                                 <itemizedlist>
74                                     <listitem>
75                                         <para>
76                                             Se <literal>a</literal> é uma matriz com dimensões
77                                             <literal>(size(i,'*'),size(j,'*'))</literal>,
78                                             <literal>x(i,j)=a</literal> retorna uma nova matriz
79                                             <literal>x</literal> tal que
80                                             <literal>x(int(i(l)),int(j(k)))=a(l,k) </literal> para
81                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
82                                             e <literal>k</literal> de 1 a
83                                             <literal>size(j,'*')</literal>, as outras entradas
84                                             iniciais de <literal>x</literal> não são
85                                             modificadas.
86                                         </para>
87                                     </listitem>
88                                     <listitem>
89                                         <para>
90                                             Se <literal>a</literal> é um escalar,
91                                             <literal>x(i,j)=a</literal> retorna uma nova matriz
92                                             <literal>x</literal> tal que
93                                             <literal>x(int(i(l)),int(j(k)))=a</literal> para
94                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
95                                             e <literal>k</literal> de 1 a
96                                             <literal>size(j,'*')</literal>, as outras entradas
97                                             iniciais de <literal>x</literal> não são
98                                             modificadas.
99                                         </para>
100                                     </listitem>
101                                     <listitem>
102                                         <para>
103                                             Se o valor máximo de <literal>i</literal> ou
104                                             <literal>j</literal> exceder a dimensão correspondente da
105                                             matriz <literal>x</literal> , o array <literal>x</literal>
106                                             é previamente estendido para as dimensões requeridas com
107                                             entradas 0 para matrizes padrões, strings de comprimento 0
108                                             para matrizes de strings e valores falsos para matrizes de
109                                             booleanos.
110                                         </para>
111                                     </listitem>
112                                     <listitem>
113                                         <para>
114                                             <literal>x(i,j)=[]</literal> cancela linhas
115                                             especificadas por <literal>i</literal> se
116                                             <literal>j</literal> corresponde a todas as colunas de
117                                             <literal>x</literal> ou cancela colunas especificadas por
118                                             <literal>j</literal> se <literal>i</literal> corresponde a
119                                             todas as linhas de <literal>x</literal>. Em outros casos
120                                             <literal>x(i,j)=[]</literal> produz um erro.
121                                         </para>
122                                     </listitem>
123                                     <listitem>
124                                         <para>
125                                             <literal>x(i)=a</literal> com <literal>a</literal>
126                                             um vetor retorna a nova matriz <literal>x</literal> tal
127                                             que <literal>x(int(i(l)))=a(l)</literal> para
128                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
129                                             , outras entradas iniciais de <literal>x</literal> não são
130                                             modificadas.
131                                         </para>
132                                     </listitem>
133                                     <listitem>
134                                         <para>
135                                             <literal>x(i)=a</literal> com <literal>a</literal>
136                                             um escalar retorna uma nova matriz <literal>x</literal>
137                                             tal que <literal>x(int(i(l)))=a</literal> para
138                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
139                                             , outras entradas iniciais de <literal>x</literal> não são
140                                             modificadas.
141                                         </para>
142                                         <para>
143                                             Se o valor máximo de <literal>i</literal> exceder
144                                             <literal>size(x,1)</literal>, <literal>x</literal> é
145                                             previamente estendida para a dimensão requerida com
146                                             entradas 0 para matrizes padrões, strings de comprimento 0
147                                             para matrizes de strings e valores falsos para matrizes de
148                                             booleanos.
149                                         </para>
150                                         <variablelist>
151                                             <varlistentry>
152                                                 <term>Se</term>
153                                                 <listitem>
154                                                     <para>
155                                                         <literal>x</literal> é uma matriz 1x1
156                                                     </para>
157                                                     <para>
158                                                         <literal>a</literal> pode ser um vetor linha
159                                                         (respectivamente coluna) com dimensão
160                                                         <literal>size(i,'*')</literal>. A matriz
161                                                         <literal>x</literal> resultante é um vetor linha
162                                                         (respectivamente coluna).
163                                                     </para>
164                                                 </listitem>
165                                             </varlistentry>
166                                             <varlistentry>
167                                                 <term>Se</term>
168                                                 <listitem>
169                                                     <para>
170                                                         <literal>x</literal> é um vetor linha
171                                                     </para>
172                                                     <para>
173                                                         <literal>a</literal> deve ser um vetor linha
174                                                         de dimensão <literal>size(i,'*')</literal>
175                                                     </para>
176                                                 </listitem>
177                                             </varlistentry>
178                                             <varlistentry>
179                                                 <term>Se</term>
180                                                 <listitem>
181                                                     <para>
182                                                         <literal>x</literal> é um vetor coluna
183                                                     </para>
184                                                     <para>
185                                                         <literal>a</literal> deve ser um vetor coluna
186                                                         de dimensão <literal>size(i,'*')</literal>
187                                                     </para>
188                                                 </listitem>
189                                             </varlistentry>
190                                             <varlistentry>
191                                                 <term>Se</term>
192                                                 <listitem>
193                                                     <para>
194                                                         <literal>x</literal> é uma matriz geral
195                                                     </para>
196                                                     <para>
197                                                         <literal>a</literal> deve ser um vetor linha
198                                                         ou coluna de dimensão <literal>size(i,'*')</literal>
199                                                         e o valor máximo de <literal>i</literal> não pode
200                                                         exceder <literal>size(x,'*')</literal>,
201                                                     </para>
202                                                 </listitem>
203                                             </varlistentry>
204                                         </variablelist>
205                                     </listitem>
206                                     <listitem>
207                                         <para>
208                                             <literal>x(i)=[]</literal> cancela entradas
209                                             especificadas por <literal>i</literal>.
210                                         </para>
211                                     </listitem>
212                                 </itemizedlist>
213                             </listitem>
214                         </varlistentry>
215                         <varlistentry>
216                             <term>O símbolo :</term>
217                             <listitem>
218                                 <para>
219                                     O símbolo <literal>':'</literal> significa "todos os
220                                     elementos".
221                                 </para>
222                                 <itemizedlist>
223                                     <listitem>
224                                         <para>
225                                             <literal>x(i,:)=a</literal> é interpretado como
226                                             <literal>x(i,1:size(x,2))=a</literal>
227                                         </para>
228                                     </listitem>
229                                     <listitem>
230                                         <para>
231                                             <literal>x(:,j)=a</literal> é interpretado como
232                                             <literal>x(1:size(x,1),j)=a</literal>
233                                         </para>
234                                     </listitem>
235                                     <listitem>
236                                         <para>
237                                             <literal>x(:)=a</literal> retorna em
238                                             <literal>x</literal> a matriz <literal>a</literal> de
239                                             forma redefinida de acordo com as dimensões de x.
240                                             <literal>size(x,'*')</literal> deve ser igual a
241                                             <literal>size(a,'*')</literal>
242                                         </para>
243                                     </listitem>
244                                 </itemizedlist>
245                             </listitem>
246                         </varlistentry>
247                         <varlistentry>
248                             <term>Vetores de booleanos</term>
249                             <listitem>
250                                 <para>
251                                     se um índice (<literal>i</literal> ou
252                                     <literal>j</literal> ) é um vetor de booleanos, é interpretado
253                                     como <literal>find(i)</literal> ou, respectivamente,
254                                     <literal>find(j)</literal>
255                                 </para>
256                             </listitem>
257                         </varlistentry>
258                         <varlistentry>
259                             <term>Polinômios</term>
260                             <listitem>
261                                 <para>
262                                     se um índice (<literal>i</literal> ou
263                                     <literal>j</literal> ) é um vetor de polinômios ou um vetor de
264                                     polinômios implícito, é interpretado como
265                                     <literal>horner(i,m)</literal> ou respectivamente
266                                     <literal>horner(j,n)</literal> onde <literal>m</literal> e
267                                     <literal>n</literal> são as dimensões associadas de
268                                     <literal>x</literal>. Mesmo se esse recurso funcionar para
269                                     todos os polinômios, é recomendado utilizar polinômios em
270                                     <literal>$</literal> para legibilidade.
271                                 </para>
272                             </listitem>
273                         </varlistentry>
274                     </variablelist>
275                 </listitem>
276             </varlistentry>
277             <varlistentry>
278                 <term>CASO DE LISTAS OU TLISTS</term>
279                 <listitem>
280                     <itemizedlist>
281                         <listitem>
282                             <para>
283                                 Se estiverem presentes, os <literal>ki</literal> fornecem
284                                 o endereço para uma entrada de sub-lista da estrutura de dados
285                                 <literal>l</literal> data structure. Eles permitem uma extração
286                                 recursiva sem cópias intermediárias. As instruções
287                                 <literal>l(k1)...(kn)(i)=a</literal> e
288                                 <literal>l(list(k1,...,kn,i)=a)</literal> são interpretadas
289                                 como:
290                             </para>
291                             <para>
292                                 <literal>lk1 = l(k1)</literal>
293                                 <literal> .. = ..
294                                 </literal>
295                             </para>
296                             <para>
297                                 <literal>lkn = lkn-1(kn)</literal>
298                                 <literal> lkn(i) =
299                                     a
300                                 </literal>
301                             </para>
302                             <para>
303                                 <literal>lkn-1(kn) = lkn</literal>
304                                 <literal> .. = ..
305                                 </literal>
306                                 <literal>l(k1) = lk1</literal>
307                             </para>
308                             <para>
309                                 E as instruções <literal>l(k1)...(kn)(i,j)=a</literal> e
310                                 <literal>l(list(k1,...,kn,list(i,j))=a</literal> são
311                                 interpretadas como:
312                             </para>
313                             <para>
314                                 <literal>lk1 = l(k1)</literal>
315                                 <literal> .. = ..
316                                 </literal>
317                             </para>
318                             <para>
319                                 <literal>lkn = lkn-1(kn)</literal>
320                                 <literal>lkn(i,j) =
321                                     a
322                                 </literal>
323                             </para>
324                             <para>
325                                 <literal>lkn-1(kn) = lkn</literal>
326                                 <literal> .. = ..
327                                 </literal>
328                                 <literal>l(k1)= lk1</literal>
329                             </para>
330                         </listitem>
331                         <listitem>
332                             <para>
333                                 <literal>i</literal> pode ser :
334                             </para>
335                             <itemizedlist>
336                                 <listitem>
337                                     <para>Um escalar real não-negativo.
338                                         <literal>l(0)=a</literal> adiciona uma entrada à "esquerda"
339                                         da lista, <literal>l(i)=a</literal> configura a entrada
340                                         <literal>i</literal> da lista <literal>l</literal> como
341                                         <literal>a</literal>. Se <literal>i&gt;size(l)</literal>,
342                                         <literal>l</literal> é previamente estendido com entradas de
343                                         comprimento 0 (indefinidas). <literal>l(i)=null()</literal>
344                                         suprime a <literal>i</literal>-ésima entrada da
345                                         lista.
346                                     </para>
347                                 </listitem>
348                                 <listitem>
349                                     <para>
350                                         Um polinômio. Se <literal>i</literal> é um polinômio,
351                                         é interpretado como <literal>horner(i,m)</literal> onde
352                                         <literal>m=size(l)</literal>. Mesmo se este recurso
353                                         funcionar para todos os polinômios, é recomendado utilizar
354                                         polinômios em <literal>$</literal> para legibilidade.
355                                     </para>
356                                 </listitem>
357                             </itemizedlist>
358                         </listitem>
359                         <listitem>
360                             <para>
361                                 <literal>k1,..kn</literal> podem ser :
362                             </para>
363                             <itemizedlist>
364                                 <listitem>
365                                     <para>Escalares reais positivos.</para>
366                                 </listitem>
367                                 <listitem>
368                                     <para>Polinômios, interpretados como
369                                         <literal>horner(ki,m)</literal> onde <literal>m</literal> é
370                                         o tamanho da sub-lista correspondente.
371                                     </para>
372                                 </listitem>
373                                 <listitem>
374                                     <para>Strings associados a nomes de entradas de uma
375                                         sub-lista.
376                                     </para>
377                                 </listitem>
378                             </itemizedlist>
379                         </listitem>
380                     </itemizedlist>
381                 </listitem>
382             </varlistentry>
383         </variablelist>
384     </refsection>
385     <refsection>
386         <title>Observações</title>
387         <para>Para tipos de matrizes "soft-coded" como funções racionais e
388             sistemas lineares de espaços de estados, a sintaxe <literal>x(i)</literal>
389             não pode ser usada para inserção de entradas em vetores devido a confusões
390             com inserção de entradas em listas. A sintaxe <literal>x(1,j)</literal> ou
391             <literal>x(i,1)</literal> deve ser usada.
392         </para>
393     </refsection>
394     <refsection>
395         <title>Exemplos</title>
396         <programlisting role="example"><![CDATA[
397 // CASO DE MATRIZES
398 a=[1 2 3;4 5 6]
399 a(1,2)=10
400 a([1 1],2)=[-1;-2]
401 a(:,1)=[8;5]
402 a(1,3:-1:1)=[77 44 99]
403 a(1)=%s
404 a(6)=%s+1
405 a(:)=1:6
406 a([%t %f],1)=33
407 a(1:2,$-1)=[2;4]
408 a($:-1:1,1)=[8;7]
409 a($)=123
410 //
411 x='teste'
412 x([4 5])=['4','5']
413 //
414 b=[1/%s,(%s+1)/(%s-1)]
415 b(1,1)=0
416 b(1,$)=b(1,$)+1
417 b(2)=[1 2] // o numerador
418 // CASO DE LISTAS OU TLISTS
419 l=list(1,'qwerw',%s)
420 l(1)='Modificado'
421 l(0)='Adicionado'
422 l(6)=['mais um';'adicionado']
423 //
424 //
425 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
426 dts(2).a=33
427 dts(2)('b')(1,2)=-100
428  ]]></programlisting>
429     </refsection>
430     <refsection role="see also">
431         <title>Ver Também</title>
432         <simplelist type="inline">
433             <member>
434                 <link linkend="find">find</link>
435             </member>
436             <member>
437                 <link linkend="horner">horner</link>
438             </member>
439             <member>
440                 <link linkend="parentheses">parentheses</link>
441             </member>
442             <member>
443                 <link linkend="extraction">extraction</link>
444             </member>
445         </simplelist>
446     </refsection>
447 </refentry>