File: extraction.xml

package info (click to toggle)
scilab 5.2.2-9
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 334,832 kB
  • ctags: 52,586
  • sloc: xml: 526,945; ansic: 223,590; fortran: 163,080; java: 56,934; cpp: 33,840; tcl: 27,936; sh: 20,397; makefile: 9,908; ml: 9,451; perl: 1,323; cs: 614; lisp: 30
file content (396 lines) | stat: -rw-r--r-- 12,877 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
<?xml version="1.0" encoding="UTF-8"?>
<refentry version="5.0-subset Scilab" xml:id="extraction" xml:lang="en"
          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">
  <info>
    <pubdate>$LastChangedDate: 2008-03-26 08:50:39 +0000 (mer, 26 mar 2008)
    $</pubdate>
  </info>

  <refnamediv>
    <refname>extraction</refname>

    <refpurpose>matrix and list entry extraction</refpurpose>
  </refnamediv>

  <refsynopsisdiv>
    <title>Calling Sequence</title>

    <synopsis>
      x(i)
      x(i,j)
      x(i,j,k,..)
      [...]=l(i)
      [...]=l(k1)...(kn)(i) or [...]=l(list(k1,...,kn,i))
      l(k1)...(kn)(i,j) or l(list(k1,...,kn,list(i,j))
    </synopsis>
  </refsynopsisdiv>

  <refsection>
    <title>Parameters</title>

    <variablelist>
      <varlistentry>
        <term>x</term>

        <listitem>
          <para>matrix of any possible types</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>l</term>

        <listitem>
          <para>list variable</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>i,j, k</term>

        <listitem>
          <para>indices</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>k1,...kn</term>

        <listitem>
          <para>indices</para>
        </listitem>
      </varlistentry>
    </variablelist>
  </refsection>

  <refsection>
    <title>Description</title>

    <variablelist>
      <varlistentry>
        <term>MATRIX CASE</term>

        <listitem>
          <para><literal>i</literal>, <literal>j</literal>,
          <literal>k</literal>,.. can be:</para>

          <variablelist>
            <varlistentry>
              <term>a real scalar or a vector or a matrix with positive
              elements.</term>

              <listitem>
                <itemizedlist>
                  <listitem>
                    <para><literal>r=x(i,j)</literal> builds the matrix
                    <literal>r</literal> such as
                    <literal>r(l,k)=x(int(i(l)),int(j(k)))</literal> for
                    <literal>l</literal> from 1 to
                    <literal>size(i,'*')</literal> and <literal>k</literal>
                    from 1 to <literal>size(j,'*')</literal>.</para>

                    <para><literal>i</literal> (<literal>j</literal>) Maximum
                    value must be less or equal to
                    <literal>size(x,1)</literal>
                    (<literal>size(x,2)</literal>).</para>
                  </listitem>

                  <listitem>
                    <para><literal>r=x(i)</literal> with <literal>x</literal>
                    a 1x1 matrix builds the matrix <literal>r</literal> such
                    as <literal>r(l,k)=x(int(i(l)),int(i(k)))</literal> for
                    <literal>l</literal> from 1 to
                    <literal>size(i,1)</literal> and <literal>k</literal> from
                    1 to <literal>size(i,2)</literal>.</para>

                    <para>Note that in this case index <literal>i</literal> is
                    valid only if all its entries are equal to one.</para>
                  </listitem>

                  <listitem>
                    <para><literal>r=x(i)</literal> with <literal>x</literal>
                    a row vector builds the row vector <literal>r</literal>
                    such as <literal>r(l)=x(int(i(l)))</literal> for
                    <literal>l</literal> from 1 to
                    <literal>size(i,'*')</literal><literal>i</literal> Maximum
                    value must be less or equal to
                    <literal>size(x,'*')</literal>.</para>
                  </listitem>

                  <listitem>
                    <para><literal>r=x(i)</literal> with <literal>x</literal>
                    a matrix with one or more columns builds the column vector
                    <literal>r</literal> such as <literal>r(l)</literal>
                    (<literal>l</literal> from 1 to
                    <literal>size(i,'*')</literal>) contains the
                    <literal>int(i(l))</literal> entry of the column vector
                    formed by the concatenation of the <literal>x</literal>'s
                    columns.</para>

                    <para><literal>i</literal> Maximum value must be less or
                    equal to <literal>size(x,'*')</literal>.</para>
                  </listitem>
                </itemizedlist>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>the symbol <literal> : </literal></term>

              <listitem>
                <para><literal /> which stands for "all elements".</para>

                <itemizedlist>
                  <listitem>
                    <para><literal>r=x(i,:)</literal> builds the matrix
                    <literal>r</literal> such as
                    <literal>r(l,k)=x(int(i(l)),k))</literal> for
                    <literal>l</literal> from 1 to
                    <literal>size(i,'*')</literal> and <literal>k</literal>
                    from 1 to <literal>size(x,2)</literal></para>
                  </listitem>

                  <listitem>
                    <para><literal>r=x(:,j)</literal> builds the matrix
                    <literal>r</literal> such as
                    <literal>r(l,k)=x(l,int(j(k)))</literal> for
                    <literal>l</literal> from 1 to
                    <literal>size(r,1)</literal> and <literal>k</literal> from
                    1 to <literal>size(j,'*')</literal>.</para>
                  </listitem>

                  <listitem>
                    <para><literal>r=x(:)</literal> builds the column vector
                    <literal>r</literal> formed by the column concatenations
                    of<literal> x</literal> columns. It is equivalent to
                    <literal>matrix(x,size(x,'*'),1)</literal>.</para>
                  </listitem>
                </itemizedlist>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>a vector of boolean</term>

              <listitem>
                <para>If an index (<literal>i</literal> or
                <literal>j</literal> ) is a vector of booleans it is
                interpreted as <literal>find(i)</literal> or respectively
                <literal>find(j)</literal></para>
              </listitem>
            </varlistentry>

            <varlistentry>
              <term>a polynomial</term>

              <listitem>
                <para>If an index (<literal>i</literal> or
                <literal>j</literal> ) is a vector of polynomials or implicit
                polynomial vector it is interpreted as
                <literal>horner(i,m)</literal> or respectively
                <literal>horner(j,n)</literal> where <literal>m</literal> and
                <literal>n</literal> are associated <literal>x</literal>
                dimensions. Even if this feature works for all polynomials, it
                is recommended to use polynomials in <literal>$</literal> for
                readability.</para>
              </listitem>
            </varlistentry>
	  </variablelist>
	  <para>For matrices with more than 2 dimensions (see:<link
	  linkend="hypermatrices">hypermatrices</link>) the dimensionality
	  is automatically reduced when right-most dimensions are equal to
	  1.</para>
        </listitem>
      </varlistentry>

      <varlistentry>
        <term>LIST OR TLIST CASE</term>

        <listitem>
          <para>If they are present the <literal>ki</literal> give the path to
          a sub-list entry of <literal>l</literal> data structure. They allow
          a recursive extraction without intermediate copies. The
          instructions</para>

          <para>
            <literal>[...]=l(k1)...(kn)(i)</literal>
          </para>

          <para>and</para>

          <para>
            <literal>[...]=l(list(k1,...,kn,i))</literal>
          </para>

          <para>are interpreted as:</para>

          <para><literal>lk1 = l(k1)</literal> <literal> .. = .. </literal>
          <literal>lkn = lkn-1(kn)</literal> <literal>[...] = lkn(i)</literal>
          And the <literal>l(k1)...(kn)(i,j)</literal> and</para>

          <para><literal>l(list(k1,...,kn,list(i,j))</literal> instructions
          are interpreted as: <literal>lk1 = l(k1)</literal> <literal> .. = ..
          </literal> <literal>lkn = lkn-1(kn)</literal> <literal>
          lkn(i,j)</literal> <literal>i</literal> and <literal>j</literal>,
          can be: When path points on more than one list component the
          instruction must have as many left hand side arguments as selected
          components. But if the extraction syntax is used within a function
          input calling sequence each returned list component is added to the
          function calling sequence.</para>

          <para>Note that, <literal> l(list())</literal> is the same as
          <literal> l</literal>.</para>

	  <variablelist>
	    <varlistentry>
	      <term>i and j may be :</term>
	      <listitem>
		<variablelist>
		  <varlistentry>
		    <term>real scalar or vector or matrix with positive
		    elements.</term>

		    <listitem>
		      <para><literal>[r1,...rn]=l(i)</literal> extracts the
		      <literal>i(k)</literal> elements from the list l and store
		      them in <literal>rk</literal> variables for
		      <literal>k</literal> from 1 to
		      <literal>size(i,'*')</literal></para>
		    </listitem>
		  </varlistentry>

		  <varlistentry>
		    <term>the symbol <literal> : </literal></term>
		    <listitem>
		      <para>which stands for "all elements".</para>
		    </listitem>
		  </varlistentry>

		  <varlistentry>
		    <term>a vector of booleans.</term>

		    <listitem>
		      <para>If <literal>i</literal> is a vector of booleans it is
		      interpreted as <literal>find(i)</literal>.</para>
		    </listitem>
		  </varlistentry>

		  <varlistentry>
		    <term>a polynomial.</term>

		    <listitem>
		      <para>If <literal>i</literal> is a vector of polynomials or
		      implicit polynomial vector it is interpreted as
		      <literal>horner(i,m)</literal> where
		      <literal>m=size(l)</literal>. Even if this feature works for
		      all polynomials, it is recommended to use polynomials in
		      <literal>$</literal> for readability.</para>
		    </listitem>
		  </varlistentry>
		</variablelist>
	      </listitem>
	    </varlistentry>
	    <varlistentry>
	      <term>k1,..kn may be :</term>
	      <listitem>
		<variablelist>
		  <varlistentry>
		    <term>real positive scalar,</term>
		    <listitem>
		      <para></para>
		    </listitem>
		  </varlistentry>

		  <varlistentry>
		    <term>a polynomial,</term>

		    <listitem>
		      <para>interpreted as <literal>horner(ki,m)</literal> where
		      <literal>m</literal> is the corresponding sub-list
		      size.</para>
		    </listitem>
		  </varlistentry>

		  <varlistentry>
		    <term>a character string</term>

		    <listitem>
		      <para>associated with a sub-list entry name.</para>
		    </listitem>
		  </varlistentry>
		</variablelist>
	      </listitem>
	    </varlistentry>
	  </variablelist>
	</listitem>
      </varlistentry>
    </variablelist>
  </refsection>

  <refsection>
    <title>Remarks</title>

    <para>For soft coded matrix types such as rational functions and state
    space linear systems, <literal>x(i)</literal> syntax may not be used for
    vector element extraction due to confusion with list element extraction.
    <literal>x(1,j)</literal> or <literal>x(i,1)</literal> syntax must be
    used.</para>
  </refsection>

  <refsection>
    <title>Examples</title>

    <programlisting role="example"><![CDATA[ 
// MATRIX CASE
a=[1 2 3;4 5 6]
a(1,2)
a([1 1],2)
a(:,1)
a(:,3:-1:1)
a(1)
a(6)
a(:)
a([%t %f %f %t])
a([%t %f],[2 3])
a(1:2,$-1)
a($:-1:1,2)
a($)
//
x='test'
x([1 1;1 1;1 1])
//
b=[1/%s,(%s+1)/(%s-1)]
b(1,1)
b(1,$)
b(2) // the numerator
// LIST OR TLIST CASE
l=list(1,'qwerw',%s)
l(1)
[a,b]=l([3 2])
l($)
x=tlist(l(2:3)) //form a tlist with the last 2 components of l
//
dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
dts(2)('a')
dts(2)('b')(1,2)
[a,b]=dts(2)(['a','b'])
 ]]></programlisting>
  </refsection>

  <refsection>
    <title>See Also</title>

    <simplelist type="inline">
      <member><link linkend="find">find</link></member>

      <member><link linkend="horner">horner</link></member>

      <member><link linkend="parents">parents</link></member>
    </simplelist>
  </refsection>
</refentry>