b828f8c4977694523812657fede0c11d6d904fe5
[scilab.git] / scilab / modules / core / help / ja_JP / 1_keywords / insertion.xml
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="ja" xml:id="insertion">
3     <refnamediv>
4         <refname>insertion</refname>
5         <refpurpose>変数への部分的な代入または修正</refpurpose>
6     </refnamediv>
7     <refnamediv xml:id="assignation">
8         <refname>assignation</refname>
9         <refpurpose>変数への部分的な代入</refpurpose>
10     </refnamediv>
11     <refsynopsisdiv>
12         <title>呼出し手順</title>
13         <synopsis>x(i,j)=a
14             x(i)=a
15             l(i)=a
16             l(k1)...(kn)(i)=a または l(list(k1,...,kn,i))=a
17             l(k1)...(kn)(i,j)=a または l(list(k1,...,kn,list(i,j))=a
18         </synopsis>
19     </refsynopsisdiv>
20     <refsection>
21         <title>パラメータ</title>
22         <variablelist>
23             <varlistentry>
24                 <term>x</term>
25                 <listitem>
26                     <para>任意の型の行列 (定数, 疎行列, 多項式,...)</para>
27                 </listitem>
28             </varlistentry>
29             <varlistentry>
30                 <term>l</term>
31                 <listitem>
32                     <para>リスト</para>
33                 </listitem>
34             </varlistentry>
35             <varlistentry>
36                 <term>i,j</term>
37                 <listitem>
38                     <para>添え字</para>
39                 </listitem>
40             </varlistentry>
41             <varlistentry>
42                 <term>k1,...kn</term>
43                 <listitem>
44                     <para>整数値の添え字</para>
45                 </listitem>
46             </varlistentry>
47             <varlistentry>
48                 <term>a</term>
49                 <listitem>
50                     <para>新しいエントリの値</para>
51                 </listitem>
52             </varlistentry>
53         </variablelist>
54     </refsection>
55     <refsection>
56         <title>説明n</title>
57         <variablelist>
58             <varlistentry>
59                 <term>行列の場合</term>
60                 <listitem>
61                     <para>
62                         <literal>x</literal> が行列の場合,
63                         添え字 <literal>i</literal> および <literal>j</literal>, は次のようになります:
64                     </para>
65                     <variablelist>
66                         <varlistentry>
67                             <term>実数のスカラーまたはベクトルまたは行列</term>
68                             <listitem>
69                                 <para>この場合,添え字として指定される値は正である必要があり,
70                                     その整数部のみが使用されます.
71                                 </para>
72                                 <itemizedlist>
73                                     <listitem>
74                                         <para>
75                                             <literal>a</literal> が次元
76                                             <literal>(size(i,'*'),size(j,'*'))</literal>の行列の場合,
77                                             <literal>x(i,j)=a</literal> は,
78                                             <literal>l</literal>を1から <literal>size(i,'*')</literal>,
79                                             <literal>k</literal>を1から <literal>size(j,'*')</literal>として
80                                             <literal>x(int(i(l)),int(j(k)))=a(l,k) </literal>となるような
81                                             新たな行列 <literal>x</literal>を返します.
82                                             <literal>x</literal>のその他の初期エントリは変更されません.
83                                         </para>
84                                     </listitem>
85                                     <listitem>
86                                         <para>
87                                             <literal>a</literal> がスカラーの場合,
88                                             <literal>x(i,j)=a</literal> は,
89                                             <literal>l</literal>を1から<literal>size(i,'*')</literal>,
90                                             <literal>k</literal>を1から<literal>size(j,'*')</literal>として,
91                                             <literal>x(int(i(l)),int(j(k)))=a</literal>となるような
92                                             新しい行列 <literal>x</literal> を返します.
93                                             <literal>x</literal>のその他の初期エントリは変更されません.
94                                         </para>
95                                     </listitem>
96                                     <listitem>
97                                         <para>
98                                             <literal>i</literal> または <literal>j</literal>
99                                             の最大値が対応する行列 <literal>x</literal>の次元の最大値を
100                                             超える場合,配列 <literal>x</literal>は,必要な次元まで事前に拡張されます.
101                                             この際,標準の行列の場合は0,文字列行列の場合は長さ0の文字列,
102                                             論理値行列の場合は 値false,をエントリとして拡張されます.
103                                         </para>
104                                     </listitem>
105                                     <listitem>
106                                         <para>
107                                             <literal>x(i,j)=[]</literal> は,
108                                             <literal>j</literal>が<literal>x</literal>の全ての列にマッチする
109                                             場合,<literal>i</literal>で指定した行を削除します.
110                                             また,<literal>i</literal>が<literal>x</literal>の全ての行にマッチする
111                                             場合,<literal>j</literal>で指定した列を削除します.
112                                             その他の場合,<literal>x(i,j)=[]</literal>はエラーを発生します.
113                                         </para>
114                                     </listitem>
115                                     <listitem>
116                                         <para>
117                                             あるベクトル<literal>a</literal>を指定した<literal>x(i)=a</literal>は,
118                                             <literal>l</literal>を1から<literal>size(i,'*')</literal>として,
119                                             <literal>x(int(i(l)))=a(l)</literal>となるような新しい行列<literal>x</literal>
120                                             を返します.
121                                             <literal>x</literal>のその他の初期エントリは変更されません.
122                                         </para>
123                                     </listitem>
124                                     <listitem>
125                                         <para>
126                                             あるスカラー<literal>a</literal>を指定した<literal>x(i)=a</literal>は,
127                                             <literal>l</literal>を1から<literal>size(i,'*')</literal>として,
128                                             <literal>x(int(i(l)))=a</literal>となるような新しい行列<literal>x</literal>
129                                             を返します.
130                                             <literal>x</literal>のその他の初期エントリは変更されません.
131                                         </para>
132                                         <para>
133                                             <literal>i</literal>の最大値が<literal>size(x,1)</literal>より大きくなる場合,
134                                             配列 <literal>x</literal>は,必要な次元まで事前に拡張されます.
135                                             この際,標準の行列の場合は0,文字列行列の場合は長さ0の文字列,
136                                             論理値行列の場合は 値false,をエントリとして拡張されます.
137                                         </para>
138                                         <variablelist>
139                                             <varlistentry>
140                                                 <term/>
141                                                 <listitem>
142                                                     <para>
143                                                         <literal>x</literal> が 1x1行列 の場合,
144                                                     </para>
145                                                     <para>
146                                                         <literal>a</literal> は,次元
147                                                         <literal>size(i,'*')</literal>を有する
148                                                         行 (各要素が1列) ベクトルとなります.
149                                                         結果として,行列<literal>x</literal>は行ベクトル
150                                                         (各要素が1列)となります.
151                                                     </para>
152                                                 </listitem>
153                                             </varlistentry>
154                                             <varlistentry>
155                                                 <term/>
156                                                 <listitem>
157                                                     <para>
158                                                         <literal>x</literal> が行ベクトルの場合,
159                                                     </para>
160                                                     <para>
161                                                         <literal>a</literal> は次元<literal>size(i,'*')</literal>
162                                                         を有する行ベクトルである必要があります.
163                                                     </para>
164                                                 </listitem>
165                                             </varlistentry>
166                                             <varlistentry>
167                                                 <term/>
168                                                 <listitem>
169                                                     <para>
170                                                         <literal>x</literal> が列ベクトルの場合,
171                                                     </para>
172                                                     <para>
173                                                         <literal>a</literal> は次元<literal>size(i,'*')</literal>
174                                                         を有する列ベクトルである必要があります.
175                                                     </para>
176                                                 </listitem>
177                                             </varlistentry>
178                                             <varlistentry>
179                                                 <term/>
180                                                 <listitem>
181                                                     <para>
182                                                         <literal>x</literal> が一般の行列の場合,
183                                                     </para>
184                                                     <para>
185                                                         <literal>a</literal> は次元が<literal>size(i,'*')</literal>の
186                                                         行または列ベクトルである必要があります.
187                                                         また,<literal>i</literal>の最大値は<literal>size(x,'*')</literal>
188                                                         を超えることはできません.
189                                                     </para>
190                                                 </listitem>
191                                             </varlistentry>
192                                         </variablelist>
193                                     </listitem>
194                                     <listitem>
195                                         <para>
196                                             <literal>x(i)=[]</literal>は,
197                                             <literal>i</literal>で指定したエントリを削除します.
198                                         </para>
199                                     </listitem>
200                                 </itemizedlist>
201                             </listitem>
202                         </varlistentry>
203                         <varlistentry>
204                             <term>: 記号</term>
205                             <listitem>
206                                 <para>
207                                     <literal>:</literal>記号は"全ての要素"を意味します.
208                                 </para>
209                                 <itemizedlist>
210                                     <listitem>
211                                         <para>
212                                             <literal>x(i,:)=a</literal>は,
213                                             <literal>x(i,1:size(x,2))=a</literal>と解釈されます.
214                                         </para>
215                                     </listitem>
216                                     <listitem>
217                                         <para>
218                                             <literal>x(:,j)=a</literal>は,
219                                             <literal>x(1:size(x,1),j)=a</literal>と解釈されます.
220                                         </para>
221                                     </listitem>
222                                     <listitem>
223                                         <para>
224                                             <literal>x(:)=a</literal> は,
225                                             行列<literal>a</literal>をxの次元に変形した
226                                             <literal>x</literal>を返します.
227                                             <literal>size(x,'*')</literal> は,
228                                             <literal>size(a,'*')</literal>に等しい必要があります.
229                                         </para>
230                                     </listitem>
231                                 </itemizedlist>
232                             </listitem>
233                         </varlistentry>
234                         <varlistentry>
235                             <term>論理値のベクトル</term>
236                             <listitem>
237                                 <para>
238                                     添え字 (<literal>i</literal> または <literal>j</literal> )が
239                                     論理値のベクトルの場合,それぞれ<literal>find(i)</literal>または
240                                     <literal>find(j)</literal>として解釈されます.
241                                 </para>
242                             </listitem>
243                         </varlistentry>
244                         <varlistentry>
245                             <term>多項式</term>
246                             <listitem>
247                                 <para>
248                                     添え字 (<literal>i</literal> または <literal>j</literal> )が
249                                     多項式のベクトルまたは暗黙の多項式ベクトルの場合,
250                                     それぞれ <literal>horner(i,m)</literal>または<literal>horner(j,n)</literal>
251                                     と解釈されます.
252                                     ただし,<literal>m</literal> および<literal>n</literal>は
253                                     <literal>x</literal>の次元です.
254                                     この機能は全ての多項式で動作しますが,
255                                     可読性の維持のため,<literal>$</literal>の中で多項式を使用することを
256                                     推奨します.
257                                 </para>
258                             </listitem>
259                         </varlistentry>
260                     </variablelist>
261                 </listitem>
262             </varlistentry>
263             <varlistentry>
264                 <term>listまたはtlistの場合</term>
265                 <listitem>
266                     <itemizedlist>
267                         <listitem>
268                             <para>
269                                 指定された場合,
270                                 <literal>ki</literal>は<literal>l</literal>データ構造
271                                 のサブリストのエントリへのパスを指定します.
272                                 これにより,中間的なコピーをすることなく再帰的な挿入が
273                                 可能になります.
274                                 命令<literal>l(k1)...(kn)(i)=a</literal>および
275                                 <literal>l(list(k1,...,kn,i)=a)</literal>は
276                                 以下のように解釈されます:
277                             </para>
278                             <para>
279                                 <literal>lk1 = l(k1)</literal>
280                                 <literal> ..  = ..  </literal>
281                             </para>
282                             <para>
283                                 <literal>lkn = lkn-1(kn)</literal>
284                                 <literal> lkn(i) = a</literal>
285                             </para>
286                             <para>
287                                 <literal>lkn-1(kn) = lkn</literal>
288                                 <literal> ..  = ..  </literal>
289                                 <literal>l(k1) = lk1</literal>
290                             </para>
291                             <para>
292                                 命令<literal>l(k1)...(kn)(i,j)=a</literal> および  <literal>l(list(k1,...,kn,list(i,j))=a</literal>
293                                 は以下のように解釈されます:
294                             </para>
295                             <para>
296                                 <literal>lk1 = l(k1)</literal>
297                                 <literal> ..  = ..  </literal>
298                             </para>
299                             <para>
300                                 <literal>lkn = lkn-1(kn)</literal>
301                                 <literal>lkn(i,j) = a</literal>
302                             </para>
303                             <para>
304                                 <literal>lkn-1(kn) = lkn</literal>
305                                 <literal> ..  = ..  </literal>
306                                 <literal>l(k1)= lk1</literal>
307                             </para>
308                         </listitem>
309                         <listitem>
310                             <para>
311                                 <literal>i</literal> は以下のようになります :
312                             </para>
313                             <itemizedlist>
314                                 <listitem>
315                                     <para>
316                                         実数の非負のスカラー.
317                                         <literal>l(0)=a</literal>はリストの"左"にエントリを追加します.
318                                         <literal>l(i)=a</literal>はリストの<literal>i</literal>番目の
319                                         エントリに<literal>a</literal>を設定します.
320                                         <literal>i&gt;size(l)</literal>の場合,
321                                         <literal>l</literal>は長さ0のエントリ(未定義)で事前に拡張されます.
322                                         <literal>l(i)=null()</literal> は, <literal>i</literal>番目の
323                                         リストのエントリを削除します.
324                                     </para>
325                                 </listitem>
326                                 <listitem>
327                                     <para>
328                                         多項式.  <literal>i</literal> が多項式の場合,
329                                         <literal>horner(i,m)</literal>として解釈されます.
330                                         ただし, <literal>m=size(l)</literal>です.
331                                         この機能は全ての多項式で動作しますが,
332                                         可読性の維持のため,<literal>$</literal>の中で多項式を使用することを
333                                         推奨します.
334                                     </para>
335                                 </listitem>
336                             </itemizedlist>
337                         </listitem>
338                         <listitem>
339                             <para>
340                                 <literal>k1,..kn</literal> は次のようになります :
341                             </para>
342                             <itemizedlist>
343                                 <listitem>
344                                     <para>
345                                         実数の正のスカラー.
346                                     </para>
347                                 </listitem>
348                                 <listitem>
349                                     <para>
350                                         多項式,<literal>horner(ki,m)</literal>として解釈されます.
351                                         ただし,<literal>m</literal>は対応するサブリストの大きさです.
352                                     </para>
353                                 </listitem>
354                                 <listitem>
355                                     <para> サブリストのエントリ名を指す文字列.</para>
356                                 </listitem>
357                             </itemizedlist>
358                         </listitem>
359                     </itemizedlist>
360                 </listitem>
361             </varlistentry>
362         </variablelist>
363     </refsection>
364     <refsection>
365         <title>注意</title>
366         <para>
367             有理関数や状態空間線形システムのようにソフトウエアで作成される行列の型の場合,
368             リストの要素の展開と区別できないため,
369             <literal>x(i)</literal> 構文をベクトル要素の挿入には使用できない可能性が
370             あります.
371             この場合,
372             <literal>x(1,j)</literal> または <literal>x(i,1)</literal>構文を使用する必要があります.
373         </para>
374     </refsection>
375     <refsection>
376         <title>例</title>
377         <programlisting role="example"><![CDATA[
378 // MATRIX CASE
379 a=[1 2 3;4 5 6]
380 a(1,2)=10
381 a([1 1],2)=[-1;-2]
382 a(:,1)=[8;5]
383 a(1,3:-1:1)=[77 44 99]
384 a(1)=%s
385 a(6)=%s+1
386 a(:)=1:6
387 a([%t %f],1)=33
388 a(1:2,$-1)=[2;4]
389 a($:-1:1,1)=[8;7]
390 a($)=123
391 //
392 x='test'
393 x([4 5])=['4','5']
394 //
395 b=[1/%s,(%s+1)/(%s-1)]
396 b(1,1)=0
397 b(1,$)=b(1,$)+1
398 b(2)=[1 2] // the numerator
399 // LIST OR TLIST CASE
400 l=list(1,'qwerw',%s)
401 l(1)='Changed'
402 l(0)='Added'
403 l(6)=['one more';'added']
404 //
405 //
406 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
407 dts(2).a=33
408 dts(2)('b')(1,2)=-100
409  ]]></programlisting>
410     </refsection>
411     <refsection role="see also">
412         <title>参照</title>
413         <simplelist type="inline">
414             <member>
415                 <link linkend="find">find</link>
416             </member>
417             <member>
418                 <link linkend="horner">horner</link>
419             </member>
420             <member>
421                 <link linkend="parentheses">parentheses</link>
422             </member>
423             <member>
424                 <link linkend="extraction">extraction</link>
425             </member>
426         </simplelist>
427     </refsection>
428 </refentry>