OSDN Git Service

(split) Import translated manuals from JM CVS Repository.
[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)