* Bug 16620 fixed: polyint() introduced
[scilab.git] / scilab / modules / elementary_functions / help / pt_BR / extraction.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:ns5="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="extraction" xml:lang="pt">
3     <refnamediv>
4         <refname>extraction</refname>
5         <refpurpose>extração de entradas de matrizes e listas</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>Seqüência de Chamamento</title>
9         <synopsis>
10             x(i)
11             x(i,j)
12             x(i,j,k,..)
13             [...]=l(i)
14             [...]=l(k1)...(kn)(i) ou [...]=l(list(k1,...,kn,i))
15             l(k1)...(kn)(i,j) or l(list(k1,...,kn,list(i,j))
16         </synopsis>
17     </refsynopsisdiv>
18     <refsection>
19         <title>Parâmetros</title>
20         <variablelist>
21             <varlistentry>
22                 <term>x</term>
23                 <listitem>
24                     <para>matriz de qualquer tipo possível</para>
25                 </listitem>
26             </varlistentry>
27             <varlistentry>
28                 <term>l</term>
29                 <listitem>
30                     <para>variável do tipo lista</para>
31                 </listitem>
32             </varlistentry>
33             <varlistentry>
34                 <term>i,j, k</term>
35                 <listitem>
36                     <para>índices</para>
37                 </listitem>
38             </varlistentry>
39             <varlistentry>
40                 <term>k1,...kn</term>
41                 <listitem>
42                     <para>índices</para>
43                 </listitem>
44             </varlistentry>
45         </variablelist>
46     </refsection>
47     <refsection>
48         <title>Descrição</title>
49         <variablelist>
50             <varlistentry>
51                 <term>CASO DE MATRIZES</term>
52                 <listitem>
53                     <para>
54                         <literal>i</literal>, <literal>j</literal>,
55                         <literal>k</literal>,.. podem ser:
56                     </para>
57                     <variablelist>
58                         <varlistentry>
59                             <term>escalares reais ou vetores ou matrizes com elementos
60                                 positivos.
61                             </term>
62                             <listitem>
63                                 <itemizedlist>
64                                     <listitem>
65                                         <para>
66                                             <literal>r=x(i,j)</literal> constrói a matriz
67                                             <literal>r</literal> tal que
68                                             <literal>r(l,k)=x(int(i(l)),int(j(k)))</literal> para
69                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
70                                             e <literal>k</literal> de 1 a
71                                             <literal>size(j,'*')</literal>. O valor máximo de<literal>
72                                                 i
73                                             </literal>
74                                             (<literal>j</literal>) deve ser menor do que
75                                             ou igual a <literal>size(x,1)</literal>
76                                             (<literal>size(x,2)</literal>).
77                                         </para>
78                                     </listitem>
79                                     <listitem>
80                                         <para>
81                                             <literal>r=x(i)</literal> com <literal>x</literal>
82                                             uma matriz 1x1 contrói a matriz <literal>r</literal> tal
83                                             que <literal>r(l,k)=x(int(i(l)),int(i(k)))</literal> para
84                                             <literal>l</literal> de 1 a <literal>size(i,1)</literal> e
85                                             <literal>k</literal> para 1 a
86                                             <literal>size(i,2)</literal>.
87                                         </para>
88                                         <para>
89                                             Note que, nesse caso, o índice <literal>i</literal>
90                                             é válido apenas se todas as suas entradas são iguais a
91                                             1.
92                                         </para>
93                                     </listitem>
94                                     <listitem>
95                                         <para>
96                                             <literal>r=x(i)</literal> com <literal>x</literal>
97                                             um vetor linha constrói o vetor linha <literal>r</literal>
98                                             tal que <literal>r(l)=x(int(i(l)))</literal> para
99                                             <literal>l</literal> de 1 a
100                                             <literal>size(i,'*')</literal><literal>i</literal> deve
101                                             ter valor máximo menor do que ou igual a
102                                             <literal>size(x,'*')</literal>.
103                                         </para>
104                                     </listitem>
105                                     <listitem>
106                                         <para>
107                                             <literal>r=x(i)</literal> com <literal>x</literal>
108                                             uma matriz com uma ou mais colunas constrói o vetor coluna
109                                             <literal>r</literal> tal que <literal>r(l)</literal>
110                                             (<literal>l</literal> de 1 a
111                                             <literal>size(i,'*')</literal>) contém a entrada
112                                             <literal>int(i(l))</literal> do vetor coluna formado pela
113                                             concatenação das colunas de <literal>x</literal>.
114                                         </para>
115                                         <para>
116                                             <literal>i</literal> deve ter valor máximo menor do
117                                             que ou igual a <literal>size(x,'*')</literal>.
118                                         </para>
119                                     </listitem>
120                                 </itemizedlist>
121                             </listitem>
122                         </varlistentry>
123                         <varlistentry>
124                             <term>
125                                 O símbolo <literal> ':'</literal>
126                             </term>
127                             <listitem>
128                                 <para><literal/>
129                                     significa "todos os
130                                     elementos".
131                                 </para>
132                                 <itemizedlist>
133                                     <listitem>
134                                         <para>
135                                             <literal>r=x(i,:)</literal> constrói uma matriz
136                                             <literal>r</literal> tal que
137                                             <literal>r(l,k)=x(int(i(l)),k))</literal> para
138                                             <literal>l</literal> de 1 a <literal>size(i,'*')</literal>
139                                             and <literal>k</literal> from 1 to
140                                             <literal>size(x,2)</literal>
141                                         </para>
142                                     </listitem>
143                                     <listitem>
144                                         <para>
145                                             <literal>r=x(:,j)</literal> constrói a matriz
146                                             <literal>r</literal> tal que
147                                             <literal>r(l,k)=x(l,int(j(k)))</literal> para
148                                             <literal>l</literal> de 1 a <literal>size(r,1)</literal> e
149                                             <literal>k</literal> de 1 a
150                                             <literal>size(j,'*')</literal>.
151                                         </para>
152                                     </listitem>
153                                     <listitem>
154                                         <para>
155                                             <literal>r=x(:)</literal> constrói o vetor coluna
156                                             <literal>r</literal> formado pelas concatenações das
157                                             colunas de<literal> x</literal>. É equivalente a
158                                             <literal>matrix(x,size(x,'*'),1)</literal>.
159                                         </para>
160                                     </listitem>
161                                 </itemizedlist>
162                             </listitem>
163                         </varlistentry>
164                         <varlistentry>
165                             <term>vetor de booleanos</term>
166                             <listitem>
167                                 <para>
168                                     Se um índice (<literal>i</literal> ou
169                                     <literal>j</literal> ) é um vetor de booleanos, é interpretado
170                                     como <literal>find(i)</literal> ou respectivamente
171                                     <literal>find(j)</literal>
172                                 </para>
173                             </listitem>
174                         </varlistentry>
175                         <varlistentry>
176                             <term>um polinômio</term>
177                             <listitem>
178                                 <para>
179                                     Se um índice (<literal>i</literal> ou
180                                     <literal>j</literal> ) é um vetor de polinômios ou um vetor de
181                                     polinômios implícito, é interpretado como
182                                     <literal>horner(i,m)</literal> ou respectivamente
183                                     <literal>horner(j,n)</literal> onde <literal>m</literal> e
184                                     <literal>n</literal> são as dimensões associadas a
185                                     <literal>x</literal>. Mesmo se este recurso funcionar para
186                                     todos os polinômios, é recomendado utilizar polinômios em
187                                     <literal>$</literal> para legibilidade.
188                                 </para>
189                             </listitem>
190                         </varlistentry>
191                     </variablelist>
192                     <para>
193                         Para matrizes com mais de duas dimensoes (ver:<link linkend="hypermatrices">hypermatrices</link>), a dimensionalidade é
194                         automaticamente reduzida quando as dimensões mais a direita são
195                         1.
196                     </para>
197                 </listitem>
198             </varlistentry>
199             <varlistentry>
200                 <term>CASO DE LISTAS OU TLISTS</term>
201                 <listitem>
202                     <para>
203                         Se estiverem presentes, os <literal>ki</literal> fornecem o
204                         endereço para uma entrada de sub-lista da estrutura de dados
205                         <literal>l</literal> Eles permitem uma extração recursiva sem cópias
206                         intermediárias. As instruções
207                     </para>
208                     <para>
209                         <literal>[...]=l(k1)...(kn)(i)</literal>
210                     </para>
211                     <para>e</para>
212                     <para>
213                         <literal>[...]=l(list(k1,...,kn,i))</literal>
214                     </para>
215                     <para>são interpretadas como:</para>
216                     <para>
217                         <literal>lk1 = l(k1)</literal><literal> .. = .. </literal><literal>lkn = lkn-1(kn)</literal><literal>[...] = lkn(i)</literal>
218                         e as instruções <literal>l(k1)...(kn)(i,j)</literal> e
219                     </para>
220                     <para>
221                         <literal>l(list(k1,...,kn,list(i,j))</literal> são
222                         interpretadas como: <literal>lk1 = l(k1)</literal> <literal> .. = ..
223                         </literal>
224                         <literal>lkn = lkn-1(kn)</literal> <literal>
225                             lkn(i,j)
226                         </literal>
227                         <literal>i</literal> e <literal>j</literal>,
228                         podendo ser: quando pontos de endereço sobre mais de um componente
229                         da lista, a instrução deve ter tantos argumentos do lado esquerdo
230                         quanto os componentes selecionados. Mas se a sintaxe de extração é
231                         usada dentro da seqüência de chamamento de entrada de uma função,
232                         cada componente da lista retornado é adicionado à seqüência de
233                         chamamento da função.
234                     </para>
235                     <para>
236                         Note que, <literal> l(list())</literal> é o mesmo que
237                         <literal> l</literal>.
238                     </para>
239                     <variablelist>
240                         <varlistentry>
241                             <term>i e j podem ser :</term>
242                             <listitem>
243                                 <variablelist>
244                                     <varlistentry>
245                                         <term>escalares reais ou vetores ou matrizes de elementos
246                                             positivos
247                                         </term>
248                                         <listitem>
249                                             <para>
250                                                 <literal>[r1,...rn]=l(i)</literal> extrai os
251                                                 elementos <literal>i(k)</literal> da lista l e
252                                                 armazena-os em variáveis <literal>rk</literal> para
253                                                 <literal>k</literal> de 1 a
254                                                 <literal>size(i,'*')</literal>
255                                             </para>
256                                         </listitem>
257                                     </varlistentry>
258                                     <varlistentry>
259                                         <term>
260                                             O símbolo <literal> : </literal>
261                                         </term>
262                                         <listitem>
263                                             <para>significa "todos os elementos".</para>
264                                         </listitem>
265                                     </varlistentry>
266                                     <varlistentry>
267                                         <term>um vetor de booleanos</term>
268                                         <listitem>
269                                             <para>
270                                                 Se <literal>i</literal> é um vetor de booleanos, é
271                                                 interpretado como <literal>find(i)</literal>.
272                                             </para>
273                                         </listitem>
274                                     </varlistentry>
275                                     <varlistentry>
276                                         <term>um polinômio</term>
277                                         <listitem>
278                                             <para>
279                                                 Se <literal>i</literal> é um vetor de polinômios
280                                                 ou um vetor de polinômios implícito, é interpretado como
281                                                 <literal>horner(i,m)</literal> onde
282                                                 <literal>m=size(l)</literal>. Mesmo que este recurso
283                                                 funcione para todos os polinômios, é recomendado
284                                                 utilizar polinômios em <literal>$</literal> para
285                                                 legibilidade.
286                                             </para>
287                                         </listitem>
288                                     </varlistentry>
289                                 </variablelist>
290                             </listitem>
291                         </varlistentry>
292                         <varlistentry>
293                             <term>k1,..kn podem ser :</term>
294                             <listitem>
295                                 <variablelist>
296                                     <varlistentry>
297                                         <term>escalares reais posistivos</term>
298                                         <listitem>
299                                             <para/>
300                                         </listitem>
301                                     </varlistentry>
302                                     <varlistentry>
303                                         <term>um polinômio</term>
304                                         <listitem>
305                                             <para>
306                                                 interpretado como <literal>horner(ki,m)</literal>
307                                                 onde <literal>m</literal> é o tamanho da sub-lista
308                                                 correspondente.
309                                             </para>
310                                         </listitem>
311                                     </varlistentry>
312                                     <varlistentry>
313                                         <term>string</term>
314                                         <listitem>
315                                             <para>associado ao nome da entrada da sub-lista .</para>
316                                         </listitem>
317                                     </varlistentry>
318                                 </variablelist>
319                             </listitem>
320                         </varlistentry>
321                     </variablelist>
322                 </listitem>
323             </varlistentry>
324         </variablelist>
325     </refsection>
326     <refsection>
327         <title>Observações</title>
328         <para>Para tipos de matrizes "soft-coded" como funções racionais e
329             sistemas lineares de espaços de estados, a sintaxe <literal>x(i)</literal>
330             não pode ser usada para extração de elementos de vetores devido a
331             confusões com extração de elementos de listas. A sintaxe
332             <literal>x(1,j)</literal> ou <literal>x(i,1)</literal> deve ser
333             usada.
334         </para>
335     </refsection>
336     <refsection>
337         <title>Exemplos</title>
338         <programlisting role="example"><![CDATA[
339 // CASO DE MATRIZES
340 a=[1 2 3;4 5 6]
341 a(1,2)
342 a([1 1],2)
343 a(:,1)
344 a(:,3:-1:1)
345 a(1)
346 a(6)
347 a(:)
348 a([%t %f %f %t])
349 a([%t %f],[2 3])
350 a(1:2,$-1)
351 a($:-1:1,2)
352 a($)
353 //
354 x='teste'
355 x([1 1;1 1;1 1])
356 //
357 b=[1/%s,(%s+1)/(%s-1)]
358 b(1,1)
359 b(1,$)
360 b(2) // o numerador
361 // CASO DE LISTAS OU TLISTS
362 l=list(1,'qwerw',%s)
363 l(1)
364 [a,b]=l([3 2])
365 l($)
366 x=tlist(l(2:3)) //forma um tlist com os últimos dois componentes de l
367 //
368 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
369 dts(2)('a')
370 dts(2)('b')(1,2)
371 [a,b]=dts(2)(['a','b'])
372  ]]></programlisting>
373     </refsection>
374     <refsection role="see also">
375         <title>Ver Também</title>
376         <simplelist type="inline">
377             <member>
378                 <link linkend="find">find</link>
379             </member>
380             <member>
381                 <link linkend="horner">horner</link>
382             </member>
383             <member>
384                 <link linkend="parentheses">parentheses</link>
385             </member>
386         </simplelist>
387     </refsection>
388 </refentry>