OSDN Git Service

(split) Convert release and draft pages to UTF-8.
[linuxjm/LDP_man-pages.git] / draft / man3 / drand48.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" References consulted:
24 .\"     Linux libc source code
25 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26 .\"     386BSD man pages
27 .\" Modified Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
28 .\"
29 .\" Japanese Version Copyright (c) 1997 YOSHINO Takashi
30 .\"       all rights reserved.
31 .\" Translated Mon Jan 20 20:04:05 JST 1997
32 .\"       by YOSHINO Takashi <yoshino@civil.jcn.nihon-u.ac.jp>
33 .\"
34 .\" WORD: internal buffer  内部バッファ
35 .\"
36 .TH DRAND48 3  2007-07-26 "" "Linux Programmer's Manual"
37 .\"O .SH NAME
38 .SH 名前
39 .\"O drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
40 .\"O lcong48 \- generate uniformly distributed pseudo-random numbers
41 drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
42 lcong48 \- 一様分布する疑似乱数を生成する関数
43 .\"O .SH SYNOPSIS
44 .SH 書式
45 .nf
46 .B #include <stdlib.h>
47 .sp
48 .B double drand48(void);
49 .sp
50 .BI "double erand48(unsigned short " xsubi [3]);
51 .sp
52 .B long int lrand48(void);
53 .sp
54 .BI "long int nrand48(unsigned short " xsubi [3]);
55 .sp
56 .B long int mrand48(void);
57 .sp
58 .BI "long int jrand48(unsigned short " xsubi [3]);
59 .sp
60 .BI "void srand48(long int " seedval );
61 .sp
62 .BI "unsigned short *seed48(unsigned short " seed16v [3]);
63 .sp
64 .BI "void lcong48(unsigned short " param [7]);
65 .fi
66 .sp
67 .in -4n
68 .\"O Feature Test Macro Requirements for glibc (see
69 .\"O .BR feature_test_macros (7)):
70 glibc 向けの機能検査マクロの要件
71 .RB ( feature_test_macros (7)
72 参照):
73 .in
74 .sp
75 .ad l
76 .\"O All functions shown above:
77 上記の全ての関数:
78 .\" .BR drand48 (),
79 .\" .BR erand48 (),
80 .\" .BR lrand48 (),
81 .\" .BR nrand48 (),
82 .\" .BR mrand48 (),
83 .\" .BR jrand48 (),
84 .\" .BR srand48 (),
85 .\" .BR seed48 (),
86 .\" .BR lcong48 ():
87 _SVID_SOURCE || _XOPEN_SOURCE
88 .ad b
89 .\"O .SH DESCRIPTION
90 .SH 説明
91 .\"O These functions generate pseudo-random numbers using the linear congruential
92 .\"O algorithm and 48-bit integer arithmetic.
93 これらの関数は線形合同アルゴリズムと 48ビット整数演算を用いて
94 疑似乱数を生成する。
95 .PP
96 .\"O The
97 .\"O .BR drand48 ()
98 .\"O and
99 .\"O .BR erand48 ()
100 .\"O functions return nonnegative
101 .\"O double-precision floating-point values uniformly distributed between
102 .\"O [0.0, 1.0).
103 関数
104 .BR drand48 ()
105
106 .BR erand48 ()
107 は、区間 [0.0, 1.0) で
108 一様分布する非負の倍精度浮動小数点実数値を返す。
109 .PP
110 .\"O The
111 .\"O .BR lrand48 ()
112 .\"O and
113 .\"O .BR nrand48 ()
114 .\"O functions return nonnegative
115 .\"O long integers uniformly distributed between 0 and 2^31.
116 関数
117 .BR lrand48 ()
118
119 .BR nrand48 ()
120 は 0 と 2^31 の間で一様分布する
121 非負のロング整数を返す。
122 .PP
123 .\"O The
124 .\"O .BR mrand48 ()
125 .\"O and
126 .\"O .BR jrand48 ()
127 .\"O functions return signed long
128 .\"O integers uniformly distributed between \-2^31 and 2^31.
129 関数
130 .BR mrand48 ()
131
132 .BR jrand48 ()
133
134 \-2^31 と 2^31 の間で一様分布する符号付きロング整数を返す。
135 .PP
136 .\"O The
137 .\"O .BR srand48 (),
138 .\"O .BR seed48 ()
139 .\"O and
140 .\"O .BR lcong48 ()
141 .\"O functions are
142 .\"O initialization functions, one of which should be called before using
143 .\"O .BR drand48 (),
144 .\"O .BR lrand48 ()
145 .\"O or
146 .\"O .BR mrand48 ().
147 .\"O The functions
148 .\"O .BR erand48 (),
149 .\"O .BR nrand48 ()
150 .\"O and
151 .\"O .BR jrand48 ()
152 .\"O do not require
153 .\"O an initialization function to be called first.
154 関数
155 .BR srand48 (),
156 .BR seed48 (),
157 .BR lcong48 ()
158 は初期化関数
159 である。
160 関数
161 .BR drand48 (),
162 .BR lrand48 (),
163 .BR mrand48 ()
164
165 使用する前に、これらの初期化関数のいずれかを呼ぶべきである。
166 関数
167 .BR erand48 (),
168 .BR nrand48 (),
169 .BR jrand48 ()
170 は初めに
171 初期化関数を呼ぶことを必要としない。
172 .PP
173 .\"O All the functions work by generating a sequence of 48-bit integers,
174 .\"O \fIXi\fP, according to the linear congruential formula:
175 ここで説明しているすべての関数は 48ビットの整数の
176 シーケンス (\fIXi\fP) を生成することで
177 機能している。生成方法は以下の線形合同の式による。
178 .sp
179 .nf
180 .RS
181 .B Xn+1 = (aXn + c) mod m,
182 .RE
183 .fi
184 .sp
185 .\"O The parameter \fIm\fP = 2^48, hence 48-bit integer arithmetic is performed.
186 .\"O Unless
187 .\"O .BR lcong48 ()
188 .\"O is called, \fIa\fP and \fIc\fP are given by:
189 ここで n >= 0 である。
190 パラメータが \fIm\fP = 2^48 であるため、48ビット整数演算が行われている。
191 .BR lcong48 ()
192 が呼ばれていない場合、\fIa\fP と \fIc\fP は以下の式で与えられる。
193 .sp
194 .nf
195 .RS
196 .B a = 0x5DEECE66D
197 .B c = 0xB
198 .RE
199 .fi
200 .sp
201 .\"O The value returned by any of the functions
202 .\"O .BR drand48 (),
203 .\"O .BR erand48 (),
204 .\"O .BR lrand48 (),
205 .\"O .BR nrand48 (),
206 .\"O .BR mrand48 ()
207 .\"O or
208 .\"O .BR jrand48 ()
209 .\"O is
210 .\"O computed by first generating the next 48-bit \fIXi\fP in the sequence.
211 .\"O Then the appropriate number of bits, according to the type of data item to
212 .\"O be returned, is copied from the high-order bits of \fIXi\fP and transformed
213 .\"O into the returned value.
214 関数
215 .BR drand48 (),
216 .BR erand48 (),
217 .BR lrand48 (),
218 .BR nrand48 (),
219 .BR mrand48 (),
220 .BR jrand48 ()
221 で返される値は次のようにして計算される。
222 はじめに、次の48ビットの \fIXi\fP が計算される。
223 そして、返すべきデータの型に依存した適切な
224 ビット数が \fIXi\fP の上位ビットからコピーされる。
225 最後に、この値を返り値に変換する。
226 .PP
227 .\"O The functions
228 .\"O .BR drand48 (),
229 .\"O .BR lrand48 ()
230 .\"O and
231 .\"O .BR mrand48 ()
232 .\"O store
233 .\"O the last 48-bit \fIXi\fP generated in an internal buffer.
234 .\"O The functions
235 .\"O .BR erand48 (),
236 .\"O .BR nrand48 ()
237 .\"O and
238 .\"O .BR jrand48 ()
239 .\"O require the calling
240 .\"O program to provide storage for the successive \fIXi\fP values in the array
241 .\"O argument \fIxsubi\fP.
242 .\"O The functions are initialized by placing the initial
243 .\"O value of \fIXi\fP into the array before calling the function for the first
244 .\"O time.
245 関数
246 .BR drand48 (),
247 .BR lrand48 (),
248 .BR mrand48 ()
249
250 最後に生成された48ビットの \fIXi\fP を内部バッファに格納する。
251 配列の形の引数 \fIxsubi\fP に個々の \fIXi\fP の値を
252 格納できるような領域を確保することを、
253 関数
254 .BR erand48 (),
255 .BR nrand48 (),
256 .BR jrand48 ()
257 は、
258 呼び出し側のプログラムに要求する。
259 これらの関数は、はじめてそれらの関数を呼ぶ前に \fIXi\fP の初期値を配列に
260 代入することで初期化される。
261 .PP
262 .\"O The initializer function
263 .\"O .BR srand48 ()
264 .\"O sets the high order 32-bits of
265 .\"O \fIXi\fP to the argument \fIseedval\fP.
266 .\"O The low order 16-bits are set
267 .\"O to the arbitrary value 0x330E.
268 初期化関数
269 .BR srand48 ()
270 は、\fIXi\fP の
271 上位32ビットを引数 \fIseedval\fP に設定する。
272 下位の16ビットは、適当に決められた値である0x330Eに設定される。
273 .PP
274 .\"O The initializer function
275 .\"O .BR seed48 ()
276 .\"O sets the value of \fIXi\fP to
277 .\"O the 48-bit value specified in the array argument \fIseed16v\fP.
278 .\"O The
279 .\"O previous value of \fIXi\fP is copied into an internal buffer and a
280 .\"O pointer to this buffer is returned by
281 .\"O .BR seed48 ().
282 初期化関数
283 .BR seed48 ()
284 は、\fIXi\fP の値を、
285 配列の形をした引数である \fIseed16v\fP の中で指定された 48ビットの値に設定する。
286 \fIXi\fP の前の値は内部バッファにコピーされ、このバッファへのポインタが
287 .BR seed48 ()
288 によって返される。
289 .PP
290 .\"O The initialization function
291 .\"O .BR lcong48 ()
292 .\"O allows the user to specify
293 .\"O initial values for \fIXi\fP, \fIa\fP and \fIc\fP.
294 .\"O Array argument
295 .\"O elements \fIparam[0-2]\fP specify \fIXi\fP, \fIparam[3-5]\fP specify
296 .\"O \fIa\fP, and \fIparam[6]\fP specifies \fIc\fP.
297 .\"O After
298 .\"O .BR lcong48 ()
299 .\"O has been called, a subsequent call to either
300 .\"O .BR srand48 ()
301 .\"O or
302 .\"O .BR seed48 ()
303 .\"O will restore the standard values of \fIa\fP and \fIc\fP.
304 初期化関数
305 .BR lcong48 ()
306 は使用者が \fIXi\fP, \fIa\fP, \fIc\fP の
307 初期値を指定するための関数である。
308 配列の形をした引数の要素はそれぞれ、\fIparam[0-2]\fP は \fIXi\fP を、
309 \fIparam[3-5]\fP は \fIa\fP を、\fIparam[6]\fP は \fIc\fP を指定するもの
310 である。
311 .BR lcong48 ()
312 が呼ばれた後で、
313 .BR srand48 ()
314
315 .BR seed48 ()
316 を呼ぶと、前述の \fIa\fP と \fIc\fP の
317 標準値が再び設定される。
318 .SH 準拠
319 SVr4, POSIX.1-2001.
320 .\"O .SH NOTES
321 .SH 注意
322 .\"O These functions are declared obsolete by SVID 3, which states that
323 .\"O .BR rand (3)
324 .\"O should be used instead.
325 SVID 3 ではこれらの関数は時代遅れと宣言されている。
326 SVID 3 では
327 .BR rand (3)
328 が代わりに使用されるべきだと記述されている。
329 .\"O .SH "SEE ALSO"
330 .SH 関連項目
331 .BR rand (3),
332 .BR random (3)