7e6aac1e4d05eb7d281551a44b969d64619deba7
[scilab.git] / scilab / modules / elementary_functions / help / ja_JP / searchandsort / gsort.xml
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!--
3  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
4  * Copyright (C) 2008 - INRIA
5  * 
6  * This file must be used under the terms of the CeCILL.
7  * This source file is licensed as described in the file COPYING, which
8  * you should have received as part of this distribution.  The terms
9  * are also available at    
10  * http://www.cecill.info/licences/Licence_CeCILL_V2.1-en.txt
11  *
12  -->
13 <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="gsort" xml:lang="ja">
14     <refnamediv>
15         <refname>gsort</refname>
16         <refpurpose>クイックソートアルゴリズムによるソート</refpurpose>
17     </refnamediv>
18     <refsynopsisdiv>
19         <title>呼び出し手順</title>
20         <synopsis>[B [,k]]=gsort(A)
21             [B [,k]]=gsort(A,option)
22             [B [,k]]=gsort(A,option,direction)
23         </synopsis>
24     </refsynopsisdiv>
25     <refsection>
26         <title>パラメータ</title>
27         <variablelist>
28             <varlistentry>
29                 <term>A</term>
30                 <listitem>
31                     <para>実数,整数または文字列のベクトル/行列または疎ベクトル.</para>
32                 </listitem>
33             </varlistentry>
34             <varlistentry>
35                 <term>option</term>
36                 <listitem>
37                     <para>文字列. ソートの種類(下記)を指定します:</para>
38                     <itemizedlist>
39                         <listitem>
40                             <para>
41                                 'r' : <literal>A</literal> の各列がソートされます
42                             </para>
43                         </listitem>
44                         <listitem>
45                             <para>
46                                 'c': <literal>A</literal> の各行がソートされます
47                             </para>
48                         </listitem>
49                         <listitem>
50                             <para>
51                                 'g': <literal>A</literal> の全要素がソートされます. 
52                                 デフォルト値です.
53                             </para>
54                         </listitem>
55                         <listitem>
56                             <para>
57                                 'lr': <literal>A</literal>の列の辞書式ソート
58                             </para>
59                         </listitem>
60                         <listitem>
61                             <para>
62                                 'lc': <literal>A</literal>のの行の辞書式ソート
63                             </para>
64                         </listitem>
65                     </itemizedlist>
66                 </listitem>
67             </varlistentry>
68             <varlistentry>
69                 <term>direction</term>
70                 <listitem>
71                     <para>文字列. ソートの方向を指定します:
72                         <literal>'i'</literal> は昇順,
73                         <literal>'d'</literal> は降順 (デフォルト)を意味します.
74                     </para>
75                 </listitem>
76             </varlistentry>
77             <varlistentry>
78                 <term>B</term>
79                 <listitem>
80                     <para>
81                         <literal>A</literal>と同じ型と次元の配列.
82                     </para>
83                 </listitem>
84             </varlistentry>
85             <varlistentry>
86                 <term>k</term>
87                 <listitem>
88                     <para>
89                         整数値を有し,<literal>A</literal>と同じ次元の実数配列.
90                         元の添え字を有します.
91                     </para>
92                 </listitem>
93             </varlistentry>
94         </variablelist>
95     </refsection>
96     <refsection>
97         <title>説明</title>
98         <para>
99             <literal>gsort</literal> は種々のデータ型に関する
100             "クイックソート" アルゴリズムです.
101         </para>
102         <itemizedlist>
103             <listitem>
104                 <para>
105                     <literal>B=gsort(A,'g')</literal>,
106                     <literal>B=gsort(A,'g','d')</literal> および
107                     <literal>B=gsort(A)</literal> は
108                     配列  <literal>A</literal>の要素を<literal>A(:)</literal>として
109                     降順にソートします.
110                 </para>
111                 <para>
112                     <literal>B=gsort(A,'g','i')</literal> は
113                     <literal>A</literal>の要素を昇順にソートします.
114                 </para>
115             </listitem>
116             <listitem>
117                 <para>
118                     <literal>B=gsort(A,'lr')</literal> は<literal>A</literal>
119                     の行を辞書的に降順にソートします.
120                     <literal>B</literal>は,
121                     <literal>B</literal>の各行が<literal>B(i,:)&gt;=B(j,:)</literal>
122                     (ただし,<literal>i&lt;j</literal>)となるように,
123                     行列<literal>A</literal>の行を並び替えることにより
124                     得られます.
125                 </para>
126                 <para>
127                     <literal>B=gsort(A,'lr','i')</literal> は
128                     昇順の辞書的ソートについても同様に動作します.
129                 </para>
130             </listitem>
131             <listitem>
132                 <para>
133                     <literal>B=gsort(A,'lc')</literal> 
134                     の列を辞書的に降順にソートします.
135                     <literal>B</literal>は,
136                     <literal>B</literal>の各列が<literal>B(:,i)&gt;=B(:,j)</literal>
137                     (ただし,<literal>i&lt;j</literal>となるように,
138                     行列<literal>A</literal>の列を並び替えることにより
139                     得られます.
140                 </para>
141                 <para>
142                     <literal>B=gsort(A,'lc','i')</literal> は
143                     昇順の辞書的ソートについても同様に動作します.
144                 </para>
145             </listitem>
146         </itemizedlist>
147         <para>二番目の戻り値引数が指定された場合, 
148             <literal>k</literal>に<literal>A</literal>のソートされた値の添え字が
149             代入されます.
150             <literal>[B,k]=gsort(A,'g')</literal>の場合,
151             <literal>B==A(k)</literal>となります.
152             <emphasis role="bold">このアルゴリズムは,等しい値を有する
153                 レコードの相対的な順序を保持します.
154             </emphasis>
155         </para>
156         <para>
157             <literal>v</literal> が複素数の場合, その要素は
158             大きさ,すなわち, abs(<literal>v</literal>) によりソートされます,
159             2番目の引数としては<literal>'g'</literal>のみが複素数で使用可能です.
160         </para>
161         <para>
162             <literal>v</literal> が <literal>%nan</literal> または
163             <literal>%inf</literal> を要素として有する場合, gsort は
164             これらを <literal>'d'</literal> の場合は先頭,
165             <literal>'i'</literal>の場合は末尾に置きます.
166         </para>
167     </refsection>
168     <refsection>
169         <title>例</title>
170         <programlisting role="example"> 
171             alr=[1,2,2;
172             1,2,1;
173             1,1,2;
174             1,1,1];
175             [alr1,k]=gsort(alr,'lr','i')
176             [alr1,k]=gsort(alr,'lc','i')
177             
178             v=int32(alr)
179             
180             gsort(v)
181             gsort(v,'lr','i')
182             gsort(v,'lc','i')
183             
184             v=['Scilab' '2.6'
185             'Scilab' '2.7'
186             'xcos' '2.7'
187             'Scilab' '3.1'
188             'xcos' '3.1'
189             'xcos' '4.0'
190             'Scilab' '4.0']
191             
192             gsort(v,'lr','i')
193             gsort(v,'lc','i')
194         </programlisting>
195     </refsection>
196     <refsection role="see also">
197         <title>参照</title>
198         <simplelist type="inline">
199             <member>
200                 <link linkend="find">find</link>
201             </member>
202         </simplelist>
203     </refsection>
204     <refsection>
205         <title>参考文献</title>
206         <para>Quick sort algorithm from Bentley &amp; McIlroy's "Engineering a
207             Sort Function". Software---Practice and Experience,
208             23(11):1249-1265
209         </para>
210     </refsection>
211 </refentry>