6174e370a42c550dbddefdf33b9f7f1b4c679620
[scilab.git] / scilab / modules / core / help / ja_JP / 1_keywords / extraction.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:ns5="http://www.w3.org/1999/xhtml" xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:db="http://docbook.org/ns/docbook" xmlns:scilab="http://www.scilab.org" xml:id="extraction" xml:lang="ja">
3     <refnamediv>
4         <refname>extraction</refname>
5         <refpurpose>行列およびリストのエントリの展開</refpurpose>
6     </refnamediv>
7     <refsynopsisdiv>
8         <title>呼出し手順</title>
9         <synopsis>
10             x(i)
11             x(i,j)
12             x(i,j,k,..)
13             [...]=l(i)
14             [...]=l(k1)...(kn)(i) または [...]=l(list(k1,...,kn,i))
15             l(k1)...(kn)(i,j) または l(list(k1,...,kn,list(i,j))
16         </synopsis>
17     </refsynopsisdiv>
18     <refsection>
19         <title>パラメータ</title>
20         <variablelist>
21             <varlistentry>
22                 <term>x</term>
23                 <listitem>
24                     <para>任意の型の行列</para>
25                 </listitem>
26             </varlistentry>
27             <varlistentry>
28                 <term>l</term>
29                 <listitem>
30                     <para>リスト変数</para>
31                 </listitem>
32             </varlistentry>
33             <varlistentry>
34                 <term>i,j, k</term>
35                 <listitem>
36                     <para>添え字</para>
37                 </listitem>
38             </varlistentry>
39             <varlistentry>
40                 <term>k1,...kn</term>
41                 <listitem>
42                     <para>添え字</para>
43                 </listitem>
44             </varlistentry>
45         </variablelist>
46     </refsection>
47     <refsection>
48         <title>説明</title>
49         <variablelist>
50             <varlistentry>
51                 <term>行列の場合</term>
52                 <listitem>
53                     <para>
54                         <literal>i</literal>, <literal>j</literal>,
55                         <literal>k</literal>,.. は以下のようになります:
56                     </para>
57                     <variablelist>
58                         <varlistentry>
59                             <term>
60                                 正の要素を有する実数のスカラーまたはベクトルまたは行列.
61                             </term>
62                             <listitem>
63                                 <itemizedlist>
64                                     <listitem>
65                                         <para>
66                                             <literal>r=x(i,j)</literal> は,
67                                             1 から<literal>size(i,'*')</literal>の
68                                             <literal>l</literal>および
69                                             1 から <literal>size(j,'*')</literal>の
70                                             <literal>k</literal>について
71                                             <literal>r(l,k)=x(int(i(l)),int(j(k)))</literal>となるような
72                                             行列<literal>r</literal>を作成します.
73                                         </para>
74                                         <para>
75                                             <literal>i</literal> (<literal>j</literal>) の
76                                             最大値は<literal>size(x,1)</literal>
77                                             (<literal>size(x,2)</literal>)以下とする必要があります.
78                                         </para>
79                                     </listitem>
80                                     <listitem>
81                                         <para>
82                                             1x1行列 <literal>x</literal>を指定した
83                                             <literal>r=x(i)</literal>は,
84                                             1 から<literal>size(i,1)</literal>の<literal>l</literal>および
85                                             1 から <literal>size(i,2)</literal>の<literal>k</literal>
86                                             について, <literal>r(l,k)=x(int(i(l)),int(i(k)))</literal>
87                                             となるような
88                                             行列 <literal>r</literal> を構築します.
89                                         </para>
90                                         <para>
91                                             この場合,全てのエントリが1に等しい場合にのみ,
92                                             添え字 <literal>i</literal>が有効です.
93                                         </para>
94                                     </listitem>
95                                     <listitem>
96                                         <para>
97                                             <literal>x</literal>を指定した行ベクトル<literal>r=x(i)</literal>は,
98                                             1から<literal>size(i,'*')</literal>の<literal>l</literal>
99                                             について<literal>r(l)=x(int(i(l)))</literal>となるような
100                                             行ベクトル <literal>r</literal>を作成します.
101                                             <literal>i</literal>の最大値が
102                                             <literal>size(x,'*')</literal>以下とする必要があります.
103                                         </para>
104                                     </listitem>
105                                     <listitem>
106                                         <para>
107                                             1つ以上の列を有する行列<literal>x</literal>を指定した
108                                             <literal>r=x(i)</literal> は,
109                                             <literal>r(l)</literal>
110                                             (<literal>l</literal>は 1 から <literal>size(i,'*')</literal>)
111                                             が <literal>x</literal>の列の結合により作成された
112                                             列ベクトルの
113                                             エントリ<literal>int(i(l))</literal>を含むような
114                                             列ベクトル<literal>r</literal>を作成します.
115                                         </para>
116                                         <para>
117                                             <literal>i</literal> の最大値は
118                                             <literal>size(x,'*')</literal>以下である必要があります.
119                                         </para>
120                                     </listitem>
121                                 </itemizedlist>
122                             </listitem>
123                         </varlistentry>
124                         <varlistentry>
125                             <term>
126                                 記号 <literal> : </literal>
127                             </term>
128                             <listitem>
129                                 <para><literal/>
130                                     は "全ての要素"を意味します.
131                                 </para>
132                                 <itemizedlist>
133                                     <listitem>
134                                         <para>
135                                             <literal>r=x(i,:)</literal> は,
136                                             1から<literal>size(i,'*')</literal>の<literal>l</literal>,
137                                             1から<literal>size(x,2)</literal>の<literal>k</literal>について,
138                                             <literal>r(l,k)=x(int(i(l)),k))</literal>となるような
139                                             行列 <literal>r</literal> を作成します.
140                                         </para>
141                                     </listitem>
142                                     <listitem>
143                                         <para>
144                                             <literal>r=x(:,j)</literal> は,
145                                             1から<literal>size(r,1)</literal>の<literal>l</literal>,
146                                             1から<literal>size(j,'*')</literal>の<literal>k</literal>について,
147                                             <literal>r(l,k)=x(l,int(j(k)))</literal>となるような
148                                             行列 <literal>r</literal> を作成します.
149                                         </para>
150                                     </listitem>
151                                     <listitem>
152                                         <para>
153                                             <literal>r=x(:)</literal> は,
154                                             <literal>x</literal>列の列結合により
155                                             列ベクトル<literal>r</literal>を作成します.
156                                             これは,<literal>matrix(x,size(x,'*'),1)</literal>と等価です.
157                                         </para>
158                                     </listitem>
159                                 </itemizedlist>
160                             </listitem>
161                         </varlistentry>
162                         <varlistentry>
163                             <term>論理値のベクトル</term>
164                             <listitem>
165                                 <para>
166                                     添え字 (<literal>i</literal> または
167                                     <literal>j</literal> ) が論理値のベクトルの場合,それぞれ
168                                     <literal>find(i)</literal>または<literal>find(j)</literal>
169                                     として解釈されます.
170                                 </para>
171                             </listitem>
172                         </varlistentry>
173                         <varlistentry>
174                             <term>多項式</term>
175                             <listitem>
176                                 <para>
177                                     添え字 (<literal>i</literal> または
178                                     <literal>j</literal> )が多項式のベクトルまたは
179                                     暗黙の多項式ベクトルの場合,それぞれ
180                                     <literal>horner(i,m)</literal>または
181                                     <literal>horner(j,n)</literal>と解釈されます.
182                                     ただし,<literal>m</literal> および<literal>n</literal>
183                                     は<literal>x</literal>の次元に関連します.
184                                     この機能は全ての多項式に対して動作しますが,
185                                     可読性を確保するために, <literal>$</literal>に
186                                     多項式を使用することが推奨されます.
187                                 </para>
188                             </listitem>
189                         </varlistentry>
190                     </variablelist>
191                     <para>
192                         2より大きな次元の行列(参照:<link linkend="hypermatrices">ハイパー行列</link>)の場合,
193                         最も右の次元が1に等しくなると
194                         次元が自動的に縮小されます.
195                     </para>
196                 </listitem>
197             </varlistentry>
198             <varlistentry>
199                 <term>list または tlist の場合</term>
200                 <listitem>
201                     <para>
202                         指定された場合,
203                         <literal>ki</literal>は<literal>l</literal>データ構造
204                         のサブリストのエントリへのパスを指定します.
205                         これにより,中間的なコピーをすることなく再帰的な展開が
206                         可能になります.
207                         命令は以下のようになります:
208                     </para>
209                     <para>
210                         <literal>[...]=l(k1)...(kn)(i)</literal>
211                     </para>
212                     <para>および</para>
213                     <para>
214                         <literal>[...]=l(list(k1,...,kn,i))</literal>
215                     </para>
216                     <para>は以下のように解釈されます:</para>
217                     <para>
218                         <literal>lk1 = l(k1)</literal><literal> .. = .. </literal><literal>lkn = lkn-1(kn)</literal><literal>[...] = lkn(i)</literal>
219                         そして,<literal>l(k1)...(kn)(i,j)</literal> および
220                     </para>
221                     <para>
222                         <literal>l(list(k1,...,kn,list(i,j))</literal> 命令は
223                         以下のように解釈されます: <literal>lk1 = l(k1)</literal> <literal> .. = ..
224                         </literal>
225                         <literal>lkn = lkn-1(kn)</literal> <literal>
226                             lkn(i,j)
227                         </literal>
228                         <literal>i</literal> および <literal>j</literal>については後述します.
229                         パスが複数のリストの要素を指す場合,
230                         この命令は,選択した要素と同じ数の左辺の引数を有する必要があります.
231                         しかし,展開構文を関数の中で使用した場合,
232                         リストの要素を返す入力の呼出し手順が
233                         関数の呼び出し手順に追加されます.
234                     </para>
235                     <para>
236                         <literal> l(list())</literal> は
237                         <literal> l</literal>と同じであることに注意してください.
238                     </para>
239                     <variablelist>
240                         <varlistentry>
241                             <term>i および j は以下のようになります :</term>
242                             <listitem>
243                                 <variablelist>
244                                     <varlistentry>
245                                         <term>正の要素を有する実数のスカラーまたはベクトルまたは行列.</term>
246                                         <listitem>
247                                             <para>
248                                                 <literal>[r1,...rn]=l(i)</literal> は
249                                                 リスト l から要素<literal>i(k)</literal>を展開し,これを
250                                                 1から<literal>size(i,'*')</literal>までの <literal>k</literal>
251                                                 について <literal>rk</literal> に保存します.
252                                             </para>
253                                         </listitem>
254                                     </varlistentry>
255                                     <varlistentry>
256                                         <term>
257                                             記号 <literal> : </literal>
258                                         </term>
259                                         <listitem>
260                                             <para>"全ての要素"を意味します.</para>
261                                         </listitem>
262                                     </varlistentry>
263                                     <varlistentry>
264                                         <term>論理値のベクトル.</term>
265                                         <listitem>
266                                             <para>
267                                                 <literal>i</literal> が論理値のベクトルの場合,
268                                                 <literal>find(i)</literal>と解釈されます.
269                                             </para>
270                                         </listitem>
271                                     </varlistentry>
272                                     <varlistentry>
273                                         <term>多項式.</term>
274                                         <listitem>
275                                             <para>
276                                                 <literal>i</literal> が多項式のベクトルまたは
277                                                 暗黙の多項式ベクトルの場合,
278                                                 <literal>horner(i,m)</literal>として解釈されます.
279                                                 ただし,<literal>m=size(l)</literal>です.
280                                                 この機能は全ての多項式に関して動作しますが,
281                                                 可読性を良くするために,多項式を<literal>$</literal>の
282                                                 中で使用することを推奨します.
283                                             </para>
284                                         </listitem>
285                                     </varlistentry>
286                                 </variablelist>
287                             </listitem>
288                         </varlistentry>
289                         <varlistentry>
290                             <term>k1,..kn は以下のようになります. :</term>
291                             <listitem>
292                                 <variablelist>
293                                     <varlistentry>
294                                         <term>実数の正のスカラー,</term>
295                                         <listitem>
296                                             <para/>
297                                         </listitem>
298                                     </varlistentry>
299                                     <varlistentry>
300                                         <term>多項式,</term>
301                                         <listitem>
302                                             <para>
303                                                 は<literal>horner(ki,m)</literal>と解釈されます.
304                                                 ただし,<literal>m</literal>は対応するサブリストの大きさです.
305                                             </para>
306                                         </listitem>
307                                     </varlistentry>
308                                     <varlistentry>
309                                         <term>文字列</term>
310                                         <listitem>
311                                             <para>サブリストのエントリ名に関連します.</para>
312                                         </listitem>
313                                     </varlistentry>
314                                 </variablelist>
315                             </listitem>
316                         </varlistentry>
317                     </variablelist>
318                 </listitem>
319             </varlistentry>
320         </variablelist>
321     </refsection>
322     <refsection>
323         <title>注意</title>
324         <para>
325             有理関数や状態空間線形システムのようにソフトウエアで作成される行列の型の場合,
326             リストの要素の展開と区別できないため,
327             <literal>x(i)</literal> 構文をベクトル要素の展開には使用できない可能性が
328             あります.
329             この場合,
330             <literal>x(1,j)</literal> または <literal>x(i,1)</literal>構文を使用する必要があります.
331         </para>
332     </refsection>
333     <refsection>
334         <title>例</title>
335         <programlisting role="example"><![CDATA[
336 // 行列の場合
337 a=[1 2 3;4 5 6]
338 a(1,2)
339 a([1 1],2)
340 a(:,1)
341 a(:,3:-1:1)
342 a(1)
343 a(6)
344 a(:)
345 a([%t %f %f %t])
346 a([%t %f],[2 3])
347 a(1:2,$-1)
348 a($:-1:1,2)
349 a($)
350 //
351 x='test'
352 x([1 1;1 1;1 1])
353 //
354 b=[1/%s,(%s+1)/(%s-1)]
355 b(1,1)
356 b(1,$)
357 b(2) // 分子
358 // LIST または TLIST の場合
359 l=list(1,'qwerw',%s)
360 l(1)
361 [a,b]=l([3 2])
362 l($)
363 x=tlist(l(2:3)) // lの末尾2要素を有する tlist を作成
364 //
365 dts=list(1,tlist(['x';'a';'b'],10,[2 3]));
366 dts(2)('a')
367 dts(2)('b')(1,2)
368 [a,b]=dts(2)(['a','b'])
369  ]]></programlisting>
370     </refsection>
371     <refsection role="see also">
372         <title>参照</title>
373         <simplelist type="inline">
374             <member>
375                 <link linkend="find">find</link>
376             </member>
377             <member>
378                 <link linkend="horner">horner</link>
379             </member>
380             <member>
381                 <link linkend="parentheses">parentheses</link>
382             </member>
383         </simplelist>
384     </refsection>
385 </refentry>