File: insertion.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 (166 lines) | stat: -rw-r--r-- 6,442 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
insertion          Scilab Group          Scilab Function          insertion
NAME
   insertion - matrix and list insertion or modification
  
CALLING SEQUENCE
 x(i,j)=a
 x(i)=a
 l(i)=a
 l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
 l(k1)...(kn)(i,j)=a   or l(list(k1,...,kn,list(i,j))=a
PARAMETERS
 x               : matrix  of any  kind (constant, sparse, polynomial,...)
                 
 l               : list 
                 
 i,j             : indices
                 
 k1,...kn        : indices  with integer value
                 
 a               : new entry value
                 
DESCRIPTION
 MATRIX CASE
          i and j, may be:
       
      -   real scalars or vectors or matrices with positive elements. 
          
         *   if a is a matrix with dimensions (size(i,'*'),size(j,'*'))
             x(i,j)=a returns a new x matrix such as
             x(int(i(l)),int(j(k)))=a(l,k)  for  l from 1 to size(i,'*')
             and k from 1 to size(j,'*'), other initial entries of x are
             unchanged. 
             
            if a is a scalar  x(i,j)=a returns a new x matrix such as
             x(int(i(l)),int(j(k)))=a  for  l from 1 to size(i,'*') and k
             from 1 to size(j,'*'), other initial entries of x are
             unchanged.   If i or  j maximum value exceed corresponding x
             matrix dimension x is previously extended to the required
             dimensions with zeros entries for standard matrices, 0 length
             character string for string matrices and false values for
             boolean matrices. 
             
         *   x(i,j)=[] kills rows specified by i if j matches all columns
             of x or kills columns specified by j if i matches all rows of
             x. In other cases x(i,j)=[] produce an error.
             
         *   x(i)=a  with a a vector returns a new x matrix such as
             x(int(i(l)))=a(l) for  l from 1 to size(i,'*') , other initial
             entries of x are unchanged.
             
            x(i)=a  with a a scalar returns a new x matrix such as
             x(int(i(l)))=a for  l from 1 to size(i,'*') , other initial
             entries of x are unchanged.
             
            If i maximum value exceed  size(x,1), x is previously extended
             to the required dimension with zeros entries for standard
             matrices, 0 length character string for string matrices and
             false values for boolean matrices.  
             
            if  x is a 1x1 matrix a may be a row (respectively a column) 
                vector with  dimension size(i,'*'). Resulting x matrix is a
                row (respectively a column) vector
                
            if  x is a row vector a must be a row vector with  dimension 
                size(i,'*')
                
            if  x is a column vector a must be a column vector with 
                dimension  size(i,'*')
                
            if  x is a general matrix a must be a row or column vector
                with  dimension size(i,'*') and i maximum value cannot
                exceed size(x,'*'),
                
         *   x(i)=[] kills entries specified by i.
             
         - the : symbol which stands for "all elements". 
          
         *   x(i,:)=a is interpreted as x(i,1:size(x,2))=a 
             
         *   x(:,j)=a is interpreted as x(1:size(x,1),j)=a 
             
         *   x(:)=a returns in x the  a matrix reshaped according to x
             dimensions. size(x,'*') must be equal to size(a,'*')
             
         
          
      -   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)=a and  l(list(k1,...,kn,i)=a)
       instructions are interpreted as:  lk1   = l(k1)   ..   = ..      lkn
         = lkn-1(kn)   lkn(i) = a  lkn-1(kn) = lkn   ..   = ..      l(k1) =
       lk1  And the  l(k1)...(kn)(i,j)=a and l(list(k1,...,kn,list(i,j))=a
       instructions are  interpreted as:  lk1   = l(k1)   ..   = ..     
       lkn   = lkn-1(kn)  lkn(i,j) = a  lkn-1(kn) = lkn   ..   = ..     
       l(k1) = lk1
       
          -   a real non negative scalar.  l(0)=a adds an entry on the
              "left" of the list   l(i)=a sets the i entry of the list l to
              a. if i>size(l), l is previously extended with zero length
              entries (undefined).   l(i)=null() suppress the ith list
              entry.
              
          -   a polynomial.  If i  is a  polynomial  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 entry insertion
  due to confusion with list entry insertion. x(1,j) or x(i,1) syntax must
  be used. 
  
EXAMPLE
 // MATRIX CASE
 a=[1 2 3;4 5 6]
 a(1,2)=10
 a([1 1],2)=[-1;-2]
 a(:,1)=[8;5]
 a(1,3:-1:1)=[77 44 99]
 a(1)=%s
 a(6)=%s+1
 a(:)=1:6
 a([%t %f],1)=33
 a(1:2,$-1)=[2;4]
 a($:-1:1,1)=[8;7]
 a($)=123
 //
 x='test'
 x([4 5])=['4','5']
 //
 b=[1/%s,(%s+1)/(%s-1)]
 b(1,1)=0
 b(1,$)=b(1,$)+1
 b(2)=[1 2] // the numerator
 // LIST OR TLIST CASE
 l=list(1,'qwerw',%s)
 l(1)='Changed'
 l(0)='Added'
 l(6)=['one more';'added']
 //
 //
 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
 dts(2)('a')=33
 dts(2)('b')(1,2)=-100
SEE ALSO
   find, horner, parents, extraction