1 <?xml version="1.0" encoding="UTF-8"?>
2 <refentry xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:svg="http://www.w3.org/2000/svg" xmlns:mml="http://www.w3.org/1998/Math/MathML"
4 xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org"
5 xml:lang="en" xml:id="insertion">
7 <refname>insertion</refname>
8 <refpurpose>partial variable assignation
12 <refnamediv xml:id="assignation">
13 <refname>assignation</refname>
14 <refpurpose>partial variable assignation</refpurpose>
21 l(k1)...(kn)(i)=a or l(list(k1,...,kn,i))=a
22 l(k1)...(kn)(i,j)=a or l(list(k1,...,kn,list(i,j))=a
26 <title>Arguments</title>
31 <para>matrix of any kind (constant, sparse, polynomial,...)</para>
49 <para>indices with integer value</para>
55 <para>new entry value</para>
61 <title>Description</title>
63 <title>Matrix case</title>
65 If <literal>x</literal> is a matrix the indices <literal>i</literal> and <literal>j</literal>, may be:
69 <term>Real scalars or vectors or matrices</term>
71 <para>In this case the values given as indices should be positive and
72 only their integer part are taken into account.
77 If <literal>a</literal> is a matrix with
79 <literal>(size(i,'*'),size(j,'*'))</literal>,
80 <literal>x(i,j)=a</literal> returns a new <literal>x</literal> matrix
81 such as <literal>x(int(i(l)),int(j(k)))=a(l,k) </literal> for
82 <literal>l</literal> from 1 to
83 <literal>size(i,'*')</literal> and <literal>k</literal> from
84 1 to <literal>size(j,'*')</literal>, other initial
85 entries of <literal>x</literal> are unchanged.
90 If <literal>a</literal> is a scalar
91 <literal>x(i,j)=a</literal> returns a new <literal>x</literal> matrix
92 such as <literal>x(int(i(l)),int(j(k)))=a</literal> for
93 <literal>l</literal> from 1 to <literal>size(i,'*')</literal>
94 and <literal>k</literal> from 1 to
95 <literal>size(j,'*')</literal>, other initial entries
96 of <literal>x</literal> are unchanged.
101 If <literal>i</literal> or <literal>j</literal>
102 maximum value exceed corresponding <literal>x</literal> matrix
103 dimension, array <literal>x</literal> is previously extended to the
104 required dimensions with zeros entries for standard
105 matrices, 0 length character string for string matrices and
106 false values for boolean matrices.
111 <literal>x(i,j)=[]</literal> kills rows
112 specified by <literal>i</literal> if <literal>j</literal> matches all
113 columns of <literal>x</literal> or kills columns specified by
114 <literal>j</literal> if <literal>i</literal> matches all rows of
115 <literal>x</literal>. In other cases <literal>x(i,j)=[]</literal>
121 <literal>x(i)=a</literal> with an <literal>a</literal>
122 vector returns a new <literal>x</literal> matrix such as
123 <literal>x(int(i(l)))=a(l)</literal> for <literal>l</literal> from 1 to
124 <literal>size(i,'*')</literal>, other initial entries
125 of <literal>x</literal> are unchanged.
130 <literal>x(i)=a</literal> with an <literal>a</literal>
131 scalar returns a new <literal>x</literal> matrix such as
132 <literal>x(int(i(l)))=a</literal> for <literal>l</literal> from 1 to
133 <literal>size(i,'*')</literal>, other initial entries
134 of <literal>x</literal> are unchanged.
137 If <literal>i</literal> maximum value exceed
138 <literal>size(x,1)</literal>, <literal>x</literal> is previously
139 extended to the required dimension with zeros entries for
140 standard matrices, 0 length character string for string
141 matrices and false values for boolean matrices.
148 <literal>x</literal> is a 1x1
151 matrix <literal>a</literal> may be a row (respectively a
152 column) vector with dimension
153 <literal>size(i,'*')</literal>. Resulting
154 <literal>x</literal> matrix is a row (respectively a column)
163 <literal>x</literal> is a row
166 vector <literal>a</literal> must be a row vector with
167 dimension <literal>size(i,'*')</literal>
175 <literal>x</literal> is a column
178 vector <literal>a</literal> must be a column vector with
179 dimension <literal>size(i,'*')</literal>
187 <literal>x</literal> is a general
190 matrix <literal>a</literal> must be a row or column vector
191 with dimension <literal>size(i,'*')</literal> and
192 <literal>i</literal> maximum value cannot exceed
193 <literal>size(x,'*')</literal>.
201 <literal>x(i)=[]</literal> kills entries
202 specified by <literal>i</literal>.
209 <term>The : symbol</term>
212 The <literal>:</literal> symbol stands for "all elements".
217 <literal>x(i,:)=a</literal> is interpreted as
218 <literal>x(i,1:size(x,2))=a</literal>
223 <literal>x(:,j)=a</literal> is interpreted as
224 <literal>x(1:size(x,1),j)=a</literal>
229 <literal>x(:)=a</literal> returns in
230 <literal>x</literal> the <literal>a</literal> matrix reshaped
231 according to <literal>x</literal>
232 dimensions. <literal>size(x,'*')</literal> must be
233 equal to <literal>size(a,'*')</literal>.
240 <term>Vectors of boolean</term>
243 If an index (<literal>i</literal> or <literal>j</literal>) is a vector
244 of booleans it is interpreted as <literal>find(i)</literal> or
245 respectively <literal>find(j)</literal>.
250 <term>Polynomials</term>
253 If an index (<literal>i</literal> or <literal>j</literal>) is a vector of
254 polynomials or implicit polynomial vector it is interpreted
255 as <literal>horner(i,m)</literal> or respectively
256 <literal>horner(j,n)</literal> where <literal>m</literal> and
257 <literal>n</literal> are associated <literal>x</literal> dimensions.
258 Even if this feature works for all polynomials, it is
259 recommended to use polynomials in <literal>$</literal> for
267 <title>List or Tlist case</title>
270 <para>If they are present
271 the <literal>ki</literal> give the path to a sub-list entry of
272 <literal>l</literal> data structure. They allow a recursive insertion
273 without intermediate copies. The <literal>l(k1)...(kn)(i)=a</literal>
274 and <literal>l(list(k1,...,kn,i)=a)</literal> instructions are
278 <literal>lk1 = l(k1)</literal>
281 <literal> .. = .. </literal>
284 <literal>lkn = lkn-1(kn)</literal>
287 <literal>lkn(i) = a</literal>
290 <literal>lkn-1(kn) = lkn</literal>
293 <literal> .. = .. </literal>
296 <literal>l(k1) = lk1</literal>
299 And the <literal>l(k1)...(kn)(i,j)=a</literal> and <literal>l(list(k1,...,kn,list(i,j))=a</literal>
300 instructions are interpreted as:
303 <literal>lk1 = l(k1)</literal>
306 <literal> .. = .. </literal>
309 <literal>lkn = lkn-1(kn)</literal>
312 <literal>lkn(i,j) = a</literal>
315 <literal>lkn-1(kn) = lkn</literal>
318 <literal> .. = .. </literal>
321 <literal>l(k1)= lk1</literal>
326 <literal>i</literal> may be :
330 <para> a real non negative scalar (only its integer part is taken into account).
331 <literal>l(0)=a</literal> adds an entry on the "left"
332 of the list. <literal>l(i)=a</literal> sets the <literal>i</literal>
333 entry of the list <literal>l</literal> to <literal>a</literal>. If
334 <literal>i>size(l)</literal>, <literal>l</literal> is previously
335 extended with zero length entries (undefined).
336 <literal>l(i)=null()</literal> deletes the <literal>i</literal>th list
342 a polynomial. If <literal>i</literal> is a
343 polynomial it is interpreted as <literal>horner(i,m)</literal>
344 where <literal>m=size(l)</literal>. Even if this feature works
345 for all polynomials, it is recommended to use polynomials
346 in <literal>$</literal> for readability.
353 <literal>k1,..kn</literal> may be :
358 real positive scalar.
362 <para> a polynomial, interpreted as
363 <literal>horner(ki,m)</literal> where <literal>m</literal> is the
364 corresponding sub-list size.
368 <para> a character string associated with a
377 <title>Remarks</title>
379 For soft coded matrix types such as rational functions and state space linear
380 systems, <literal>x(i)</literal> syntax must not be used for vector entry
381 insertion due to confusion with list entry insertion. <literal>x(1,j)</literal>
382 or <literal>x(i,1)</literal> syntax must be used.
387 <title>Examples</title>
388 <para>Matrix cases:</para>
389 <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
412 <para>List or Tlist cases:</para>
413 <programlisting role="example"><![CDATA[
414 l = list(1,'qwerw',%s)
417 l(%pi) = 1 // equivalent to l(3)=1
418 l(6) = ['one more';'added']
421 dts = list(1, tlist(['x';'a';'b'],10,[2 3]));
423 dts(2)('b')(1,2) = -100
426 <refsection role="see also">
427 <title>See also</title>
428 <simplelist type="inline">
430 <link linkend="extraction">extraction</link>
433 <link linkend="colon">colon</link>
436 <link linkend="find">find</link>
439 <link linkend="horner">horner</link>
442 <link linkend="parentheses">parentheses</link>