File: extraction.cat

package info (click to toggle)
scilab 2.6-4
  • links: PTS
  • area: non-free
  • in suites: woody
  • size: 54,632 kB
  • ctags: 40,267
  • sloc: ansic: 267,851; fortran: 166,549; sh: 10,005; makefile: 4,119; tcl: 1,070; cpp: 233; csh: 143; asm: 135; perl: 130; java: 39
file content (153 lines) | stat: -rw-r--r-- 5,567 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
extraction         Scilab Group         Scilab Function          extraction
NAME
   extraction - matrix and list entry extraction
  
CALLING SEQUENCE
 x(i,j)
 x(i)
 [...]=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))
PARAMETERS
 x               : matrix  of any  possible types
                 
 l               : list variable
                 
 i,j             : indices
                 
 k1,...kn        : indices
                 
DESCRIPTION
 MATRIX CASE
          i and j, can be:
       
      -   real scalars or vectors or matrices with positive elements. 
          
         *   r=x(i,j) designs the matrix r such as
             r(l,k)=x(int(i(l)),int(j(k))) for  l from 1 to size(i,'*') and
             k from 1 to size(j,'*').   i (j) Maximum value must be less or
             equal to size(x,1) (size(x,2)).
             
         *   r=x(i) with x a 1x1 matrix designs the matrix r such as
             r(l,k)=x(int(i(l)),int(i(k))) for  l from 1 to size(i,1) and k
             from 1 to size(i,2).   Note that in this case index i is valid
             only if  all its entries are equal to one.
             
         *   r=x(i) with x a row vector designs the row vector r such as
             r(l)=x(int(i(l))) for l from 1 to size(i,'*')  i  Maximum
             value must be less or equal to size(x,'*').
             
         *   r=x(i) with x a matrix with one or more columns designs the
             column vector r such as r(l) (l from 1 to size(i,'*')) designs
             the int(i(l)) entry of the column vector formed by the
             concatenation of the x's columns.  i  Maximum value must be
             less or equal to size(x,'*').
             
         
          
      -   the  :  symbol which stands for "all elements". 
          
         *   r=x(i,:) designs the matrix r such as r(l,k)=x(int(i(l)),k))
             for  l from 1 to size(i,'*') and k from 1 to size(x,2)
             
         *   r=x(:,j) designs the matrix r such as r(l,k)=x(l,int(j(k)))
             for  l from 1 to size(r,1) and k from 1 to  size(j,'*').
             
         *   r=x(:) designs the column vector r formed by the column
             concatenations of x columns. It is equivalent to
             matrix(x,size(x,'*'),1).
             
         
          
      -   vector of boolean. If an index (i  or j )is a vector of booleans
          it is interpreted as find(i) or respectively  find(j) 
          
      -   a polynomial.  If an index (i  or j )is a vector of polynomials
          or implicit polynomial vector it is interpreted as horner(i,m) or
          respectively  horner(j,n) where m and n are associated x
          dimensions.  Even if this feature works for all polynomials, it
          is recommended to use polynomials in $ for readability.  
          
 LIST OR TLIST CASE
         If they are present the ki give the path to a sub-list entry of l data
       structure. They allow a recursive extraction without intermediate
       copies.  The [...]=l(k1)...(kn)(i) and [...]=l(list(k1,...,kn,i))
       instructions are interpreted as:  lk1   = l(k1)   ..   = ..      lkn
         = lkn-1(kn)  [...] = lkn(i)  And the  l(k1)...(kn)(i,j) and
       l(list(k1,...,kn,list(i,j)) instructions are  interpreted as:  lk1  
       = l(k1)   ..   = ..      lkn   = lkn-1(kn)          lkn(i,j) i and
       j, 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.
       
      Note that,  l(list() is the same as  l.
       
      -   real scalar or vector or matrix with positive elements.   
          [r1,...rn]=l(i) extracts the i(k) elements from the list l and
          store them in rk variable  for  k from 1 to size(i,'*') 
          
      -   the  :  symbol which stands for "all elements". 
          
      -   a vector of booleans. If i is a vector of booleans it is
          interpreted as find(i).
          
      -   a polynomial.  If i  is a vector of polynomials or implicit
          polynomial vector it is interpreted as horner(i,m) where
          m=size(l).  Even if this feature works for all polynomials, it is
          recommended to use polynomials in $ for readability.  
          
 k1,..kn may be :
        
       
      -   real positive scalar.  
          
      -   a polynomial,interpreted as horner(ki,m) where m is the
          corresponding sub-list size. 
          
REMARKS
  - a character string associated with a sub-list entry name.
  For soft coded matrix types such as rational functions and state space
  linear systems, x(i) syntax may not be used for vector element extraction
  due to confusion with list element extraction. x(1,j) or x(i,1) syntax
  must be used.
  
EXAMPLE
 // 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'])
 
SEE ALSO
   find, horner, parents