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:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:lang="en" xml:id="insertion">
4 <refname>insertion</refname>
5 <refpurpose>partial variable assignation
9 <refnamediv xml:id="assignation">
10 <refname>assignation</refname>
11 <refpurpose>partial variable assignation</refpurpose>
18 l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
19 l(k1)...(kn)(i,j)=a or l(list(k1,...,kn,list(i,j))=a
23 <title>Arguments</title>
28 <para>matrix of any kind (constant, sparse, polynomial,...)</para>
46 <para>indices with integer value</para>
52 <para>new entry value</para>
58 <title>Description</title>
61 <term>MATRIX CASE</term>
64 If <literal>x</literal> is a matrix the indices <literal>i</literal> and <literal>j</literal>, may be:
68 <term>Real scalars or vectors or matrices</term>
70 <para>In this case the values given as indices should be positive and
71 only their integer part are taken into account.
76 If <literal>a</literal> is a matrix with
78 <literal>(size(i,'*'),size(j,'*'))</literal>,
79 <literal>x(i,j)=a</literal> returns a new <literal>x</literal> matrix
80 such as <literal>x(int(i(l)),int(j(k)))=a(l,k) </literal> for
81 <literal>l</literal> from 1 to
82 <literal>size(i,'*')</literal> and <literal>k</literal> from
83 1 to <literal>size(j,'*')</literal>, other initial
84 entries of <literal>x</literal> are unchanged.
89 If <literal>a</literal> is a scalar
90 <literal>x(i,j)=a</literal> returns a new <literal>x</literal> matrix
91 such as <literal>x(int(i(l)),int(j(k)))=a</literal> for
92 <literal>l</literal> from 1 to <literal>size(i,'*')</literal>
93 and <literal>k</literal> from 1 to
94 <literal>size(j,'*')</literal>, other initial entries
95 of <literal>x</literal> are unchanged.
100 If <literal>i</literal> or <literal>j</literal>
101 maximum value exceed corresponding <literal>x</literal> matrix
102 dimension, array <literal>x</literal> is previously extended to the
103 required dimensions with zeros entries for standard
104 matrices, 0 length character string for string matrices and
105 false values for boolean matrices.
110 <literal>x(i,j)=[]</literal> kills rows
111 specified by <literal>i</literal> if <literal>j</literal> matches all
112 columns of <literal>x</literal> or kills columns specified by
113 <literal>j</literal> if <literal>i</literal> matches all rows of
114 <literal>x</literal>. In other cases <literal>x(i,j)=[]</literal>
120 <literal>x(i)=a</literal> with an <literal>a</literal>
121 vector returns a new <literal>x</literal> matrix such as
122 <literal>x(int(i(l)))=a(l)</literal> for <literal>l</literal> from 1 to
123 <literal>size(i,'*')</literal>, other initial entries
124 of <literal>x</literal> are unchanged.
129 <literal>x(i)=a</literal> with an <literal>a</literal>
130 scalar returns a new <literal>x</literal> matrix such as
131 <literal>x(int(i(l)))=a</literal> for <literal>l</literal> from 1 to
132 <literal>size(i,'*')</literal>, other initial entries
133 of <literal>x</literal> are unchanged.
136 If <literal>i</literal> maximum value exceed
137 <literal>size(x,1)</literal>, <literal>x</literal> is previously
138 extended to the required dimension with zeros entries for
139 standard matrices, 0 length character string for string
140 matrices and false values for boolean matrices.
147 <literal>x</literal> is a 1x1
150 matrix <literal>a</literal> may be a row (respectively a
151 column) vector with dimension
152 <literal>size(i,'*')</literal>. Resulting
153 <literal>x</literal> matrix is a row (respectively a column)
162 <literal>x</literal> is a row
165 vector <literal>a</literal> must be a row vector with
166 dimension <literal>size(i,'*')</literal>
174 <literal>x</literal> is a column
177 vector <literal>a</literal> must be a column vector with
178 dimension <literal>size(i,'*')</literal>
186 <literal>x</literal> is a general
189 matrix <literal>a</literal> must be a row or column vector
190 with dimension <literal>size(i,'*')</literal> and
191 <literal>i</literal> maximum value cannot exceed
192 <literal>size(x,'*')</literal>.
200 <literal>x(i)=[]</literal> kills entries
201 specified by <literal>i</literal>.
208 <term>The : symbol</term>
211 The <literal>:</literal> symbol stands for "all elements".
216 <literal>x(i,:)=a</literal> is interpreted as
217 <literal>x(i,1:size(x,2))=a</literal>
222 <literal>x(:,j)=a</literal> is interpreted as
223 <literal>x(1:size(x,1),j)=a</literal>
228 <literal>x(:)=a</literal> returns in
229 <literal>x</literal> the <literal>a</literal> matrix reshaped
230 according to <literal>x</literal>
231 dimensions. <literal>size(x,'*')</literal> must be
232 equal to <literal>size(a,'*')</literal>.
239 <term>Vectors of boolean</term>
242 If an index (<literal>i</literal> or <literal>j</literal>) is a vector
243 of booleans it is interpreted as <literal>find(i)</literal> or
244 respectively <literal>find(j)</literal>.
249 <term>Polynomials</term>
252 If an index (<literal>i</literal> or <literal>j</literal>) is a vector of
253 polynomials or implicit polynomial vector it is interpreted
254 as <literal>horner(i,m)</literal> or respectively
255 <literal>horner(j,n)</literal> where <literal>m</literal> and
256 <literal>n</literal> are associated <literal>x</literal> dimensions.
257 Even if this feature works for all polynomials, it is
258 recommended to use polynomials in <literal>$</literal> for
267 <term>LIST OR TLIST CASE</term>
271 <para>If they are present
272 the <literal>ki</literal> give the path to a sub-list entry of
273 <literal>l</literal> data structure. They allow a recursive insertion
274 without intermediate copies. The <literal>l(k1)...(kn)(i)=a</literal>
275 and <literal>l(list(k1,...,kn,i)=a)</literal> instructions are
279 <literal>lk1 = l(k1)</literal>
282 <literal> .. = .. </literal>
285 <literal>lkn = lkn-1(kn)</literal>
288 <literal>lkn(i) = a</literal>
291 <literal>lkn-1(kn) = lkn</literal>
294 <literal> .. = .. </literal>
297 <literal>l(k1) = lk1</literal>
300 And the <literal>l(k1)...(kn)(i,j)=a</literal> and <literal>l(list(k1,...,kn,list(i,j))=a</literal>
301 instructions are interpreted as:
304 <literal>lk1 = l(k1)</literal>
307 <literal> .. = .. </literal>
310 <literal>lkn = lkn-1(kn)</literal>
313 <literal>lkn(i,j) = a</literal>
316 <literal>lkn-1(kn) = lkn</literal>
319 <literal> .. = .. </literal>
322 <literal>l(k1)= lk1</literal>
327 <literal>i</literal> may be :
331 <para> a real non negative scalar (only its integer part is taken into account).
332 <literal>l(0)=a</literal> adds an entry on the "left"
333 of the list. <literal>l(i)=a</literal> sets the <literal>i</literal>
334 entry of the list <literal>l</literal> to <literal>a</literal>. If
335 <literal>i>size(l)</literal>, <literal>l</literal> is previously
336 extended with zero length entries (undefined).
337 <literal>l(i)=null()</literal> deletes the <literal>i</literal>th list
343 a polynomial. If <literal>i</literal> is a
344 polynomial it is interpreted as <literal>horner(i,m)</literal>
345 where <literal>m=size(l)</literal>. Even if this feature works
346 for all polynomials, it is recommended to use polynomials
347 in <literal>$</literal> for readability.
354 <literal>k1,..kn</literal> may be :
359 real positive scalar.
363 <para> a polynomial, interpreted as
364 <literal>horner(ki,m)</literal> where <literal>m</literal> is the
365 corresponding sub-list size.
369 <para> a character string associated with a
381 <title>Remarks</title>
383 For soft coded matrix types such as rational functions and state space linear systems, <literal>x(i)</literal> syntax must not be used for vector entry insertion due to confusion with list entry insertion. <literal>x(1,j)</literal> or <literal>x(i,1)</literal> syntax must be used.
387 <title>Examples</title>
388 <programlisting role="example"><![CDATA[
394 a(1,3:-1:1)=[77 44 99]
402 a(1,%pi)=1 //equivalent to a(1,3)=1
407 b=[1/%s,(%s+1)/(%s-1)]
410 b(2)=[1 2] // the numerator
411 // LIST OR TLIST CASE
415 l(%pi)=1 //equivalent to l(3)=1
416 l(6)=['one more';'added']
419 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
421 dts(2)('b')(1,2)=-100
424 <refsection role="see also">
425 <title>See also</title>
426 <simplelist type="inline">
428 <link linkend="find">find</link>
431 <link linkend="horner">horner</link>
434 <link linkend="parentheses">parentheses</link>
437 <link linkend="extraction">extraction</link>