~ubuntu-branches/ubuntu/hoary/scilab/hoary

« back to all changes in this revision

Viewing changes to man/programming/insertion.cat

  • Committer: Bazaar Package Importer
  • Author(s): Torsten Werner
  • Date: 2005-01-09 22:58:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050109225821-473xr8vhgugxxx5j
Tags: 3.0-12
changed configure.in to build scilab's own malloc.o, closes: #255869

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
insertion          Scilab Group          Scilab Function          insertion
2
 
NAME
3
 
   insertion - matrix and list insertion or modification
4
 
  
5
 
CALLING SEQUENCE
6
 
 x(i,j)=a
7
 
 x(i)=a
8
 
 l(i)=a
9
 
 l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
10
 
 l(k1)...(kn)(i,j)=a   or l(list(k1,...,kn,list(i,j))=a
11
 
PARAMETERS
12
 
 x               : matrix  of any  kind (constant, sparse, polynomial,...)
13
 
                 
14
 
 l               : list 
15
 
                 
16
 
 i,j             : indices
17
 
                 
18
 
 k1,...kn        : indices  with integer value
19
 
                 
20
 
 a               : new entry value
21
 
                 
22
 
DESCRIPTION
23
 
 MATRIX CASE
24
 
          i and j, may be:
25
 
       
26
 
      -   real scalars or vectors or matrices with positive elements. 
27
 
          
28
 
         *   if a is a matrix with dimensions (size(i,'*'),size(j,'*'))
29
 
             x(i,j)=a returns a new x matrix such as
30
 
             x(int(i(l)),int(j(k)))=a(l,k)  for  l from 1 to size(i,'*')
31
 
             and k from 1 to size(j,'*'), other initial entries of x are
32
 
             unchanged. 
33
 
             
34
 
            if a is a scalar  x(i,j)=a returns a new x matrix such as
35
 
             x(int(i(l)),int(j(k)))=a  for  l from 1 to size(i,'*') and k
36
 
             from 1 to size(j,'*'), other initial entries of x are
37
 
             unchanged.   If i or  j maximum value exceed corresponding x
38
 
             matrix dimension x is previously extended to the required
39
 
             dimensions with zeros entries for standard matrices, 0 length
40
 
             character string for string matrices and false values for
41
 
             boolean matrices. 
42
 
             
43
 
         *   x(i,j)=[] kills rows specified by i if j matches all columns
44
 
             of x or kills columns specified by j if i matches all rows of
45
 
             x. In other cases x(i,j)=[] produce an error.
46
 
             
47
 
         *   x(i)=a  with a a vector returns a new x matrix such as
48
 
             x(int(i(l)))=a(l) for  l from 1 to size(i,'*') , other initial
49
 
             entries of x are unchanged.
50
 
             
51
 
            x(i)=a  with a a scalar returns a new x matrix such as
52
 
             x(int(i(l)))=a for  l from 1 to size(i,'*') , other initial
53
 
             entries of x are unchanged.
54
 
             
55
 
            If i maximum value exceed  size(x,1), x is previously extended
56
 
             to the required dimension with zeros entries for standard
57
 
             matrices, 0 length character string for string matrices and
58
 
             false values for boolean matrices.  
59
 
             
60
 
            if  x is a 1x1 matrix a may be a row (respectively a column) 
61
 
                vector with  dimension size(i,'*'). Resulting x matrix is a
62
 
                row (respectively a column) vector
63
 
                
64
 
            if  x is a row vector a must be a row vector with  dimension 
65
 
                size(i,'*')
66
 
                
67
 
            if  x is a column vector a must be a column vector with 
68
 
                dimension  size(i,'*')
69
 
                
70
 
            if  x is a general matrix a must be a row or column vector
71
 
                with  dimension size(i,'*') and i maximum value cannot
72
 
                exceed size(x,'*'),
73
 
                
74
 
         *   x(i)=[] kills entries specified by i.
75
 
             
76
 
         - the : symbol which stands for "all elements". 
77
 
          
78
 
         *   x(i,:)=a is interpreted as x(i,1:size(x,2))=a 
79
 
             
80
 
         *   x(:,j)=a is interpreted as x(1:size(x,1),j)=a 
81
 
             
82
 
         *   x(:)=a returns in x the  a matrix reshaped according to x
83
 
             dimensions. size(x,'*') must be equal to size(a,'*')
84
 
             
85
 
         
86
 
          
87
 
      -   vector of boolean. If an index (i  or j )is a vector of booleans
88
 
          it is interpreted as find(i) or respectively  find(j) 
89
 
          
90
 
      -   a polynomial.  If an index (i  or j )is a vector of polynomials
91
 
          or implicit polynomial vector it is interpreted as horner(i,m) or
92
 
          respectively  horner(j,n) where m and n are associated x
93
 
          dimensions.  Even if this feature works for all polynomials, it
94
 
          is recommended to use polynomials in $ for readability.  
95
 
          
96
 
 LIST OR TLIST CASE
97
 
        If they are present the ki give the path to a sub-list entry of l data
98
 
       structure. They allow a recursive extraction without intermediate
99
 
       copies.  The  l(k1)...(kn)(i)=a and  l(list(k1,...,kn,i)=a)
100
 
       instructions are interpreted as:  lk1   = l(k1)   ..   = ..      lkn
101
 
         = lkn-1(kn)   lkn(i) = a  lkn-1(kn) = lkn   ..   = ..      l(k1) =
102
 
       lk1  And the  l(k1)...(kn)(i,j)=a and l(list(k1,...,kn,list(i,j))=a
103
 
       instructions are  interpreted as:  lk1   = l(k1)   ..   = ..     
104
 
       lkn   = lkn-1(kn)  lkn(i,j) = a  lkn-1(kn) = lkn   ..   = ..     
105
 
       l(k1) = lk1
106
 
       
107
 
          -   a real non negative scalar.  l(0)=a adds an entry on the
108
 
              "left" of the list   l(i)=a sets the i entry of the list l to
109
 
              a. if i>size(l), l is previously extended with zero length
110
 
              entries (undefined).   l(i)=null() suppress the ith list
111
 
              entry.
112
 
              
113
 
          -   a polynomial.  If i  is a  polynomial  it is interpreted as
114
 
              horner(i,m) where m=size(l).  Even if this feature works for
115
 
              all polynomials, it is recommended to use polynomials in $
116
 
              for readability.  
117
 
              
118
 
          k1,..kn may be : 
119
 
           
120
 
      -    real positive scalar.  
121
 
           
122
 
      -    a polynomial,interpreted as horner(ki,m) where m is the
123
 
           corresponding sub-list size. 
124
 
           
125
 
REMARKS
126
 
  - a character string associated with a sub-list entry name.
127
 
  For soft coded matrix types such as rational functions and state space
128
 
  linear systems, x(i) syntax may not be used for vector entry insertion
129
 
  due to confusion with list entry insertion. x(1,j) or x(i,1) syntax must
130
 
  be used. 
131
 
  
132
 
EXAMPLE
133
 
 // MATRIX CASE
134
 
 a=[1 2 3;4 5 6]
135
 
 a(1,2)=10
136
 
 a([1 1],2)=[-1;-2]
137
 
 a(:,1)=[8;5]
138
 
 a(1,3:-1:1)=[77 44 99]
139
 
 a(1)=%s
140
 
 a(6)=%s+1
141
 
 a(:)=1:6
142
 
 a([%t %f],1)=33
143
 
 a(1:2,$-1)=[2;4]
144
 
 a($:-1:1,1)=[8;7]
145
 
 a($)=123
146
 
 //
147
 
 x='test'
148
 
 x([4 5])=['4','5']
149
 
 //
150
 
 b=[1/%s,(%s+1)/(%s-1)]
151
 
 b(1,1)=0
152
 
 b(1,$)=b(1,$)+1
153
 
 b(2)=[1 2] // the numerator
154
 
 // LIST OR TLIST CASE
155
 
 l=list(1,'qwerw',%s)
156
 
 l(1)='Changed'
157
 
 l(0)='Added'
158
 
 l(6)=['one more';'added']
159
 
 //
160
 
 //
161
 
 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
162
 
 dts(2)('a')=33
163
 
 dts(2)('b')(1,2)=-100
164
 
SEE ALSO
165
 
   find, horner, parents, extraction   
166