OSDN Git Service

3fe5f4b638ba66dec897303d55ecfdcbc34d340f
[linuxjm/LDP_man-pages.git] / release / man3 / drand48.3
1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2 .\"
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
7 .\"
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
12 .\"
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein.  The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
19 .\" professionally.
20 .\"
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" %%%LICENSE_END
24 .\"
25 .\" References consulted:
26 .\"     Linux libc source code
27 .\"     Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
28 .\"     386BSD man pages
29 .\" Modified Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
30 .\"*******************************************************************
31 .\"
32 .\" This file was generated with po4a. Translate the source file.
33 .\"
34 .\"*******************************************************************
35 .TH DRAND48 3 2013\-06\-21 "" "Linux Programmer's Manual"
36 .SH 名前
37 drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
38 lcong48 \- 一様分布する疑似乱数を生成する関数
39 .SH 書式
40 .nf
41 \fB#include <stdlib.h>\fP
42 .sp
43 \fBdouble drand48(void);\fP
44 .sp
45 \fBdouble erand48(unsigned short \fP\fIxsubi\fP\fB[3]);\fP
46 .sp
47 \fBlong int lrand48(void);\fP
48 .sp
49 \fBlong int nrand48(unsigned short \fP\fIxsubi\fP\fB[3]);\fP
50 .sp
51 \fBlong int mrand48(void);\fP
52 .sp
53 \fBlong int jrand48(unsigned short \fP\fIxsubi\fP\fB[3]);\fP
54 .sp
55 \fBvoid srand48(long int \fP\fIseedval\fP\fB);\fP
56 .sp
57 \fBunsigned short *seed48(unsigned short \fP\fIseed16v\fP\fB[3]);\fP
58 .sp
59 \fBvoid lcong48(unsigned short \fP\fIparam\fP\fB[7]);\fP
60 .fi
61 .sp
62 .in -4n
63 glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7)  参照):
64 .in
65 .sp
66 .ad l
67 .\" .BR drand48 (),
68 .\" .BR erand48 (),
69 .\" .BR lrand48 (),
70 .\" .BR nrand48 (),
71 .\" .BR mrand48 (),
72 .\" .BR jrand48 (),
73 .\" .BR srand48 (),
74 .\" .BR seed48 (),
75 .\" .BR lcong48 ():
76 上記の全ての関数: _SVID_SOURCE || _XOPEN_SOURCE
77 .ad b
78 .SH 説明
79 これらの関数は線形合同アルゴリズムと 48ビット整数演算を用いて 疑似乱数を生成する。
80 .PP
81 関数 \fBdrand48\fP()  と \fBerand48\fP()  は、区間 [0.0, 1.0) で 一様分布する非負の倍精度浮動小数点実数値を返す。
82 .PP
83 関数 \fBlrand48\fP()  と \fBnrand48\fP()  は 0 と 2^31 の間で一様分布する 非負のロング整数を返す。
84 .PP
85 関数 \fBmrand48\fP()  と \fBjrand48\fP()  は \-2^31 と 2^31 の間で一様分布する符号付きロング整数を返す。
86 .PP
87 関数 \fBsrand48\fP(), \fBseed48\fP(), \fBlcong48\fP()  は初期化関数 である。 関数 \fBdrand48\fP(),
88 \fBlrand48\fP(), \fBmrand48\fP()  を 使用する前に、これらの初期化関数のいずれかを呼ぶべきである。 関数
89 \fBerand48\fP(), \fBnrand48\fP(), \fBjrand48\fP()  は初めに 初期化関数を呼ぶことを必要としない。
90 .PP
91 ここで説明しているすべての関数は 48ビットの整数の シーケンス (\fIXi\fP) を生成することで 機能している。生成方法は以下の線形合同の式による。
92 .sp
93 .nf
94 .RS
95 \fBXn+1 = (aXn + c) mod m,\fP
96 .RE
97 .fi
98 .sp
99 ここで n >= 0 である。 パラメータが \fIm\fP = 2^48 であるため、48ビット整数演算が行われている。 \fBlcong48\fP()
100 が呼ばれていない場合、\fIa\fP と \fIc\fP は以下の式で与えられる。
101 .sp
102 .nf
103 .RS
104 \fBa = 0x5DEECE66D\fP
105 \fBc = 0xB\fP
106 .RE
107 .fi
108 .sp
109 関数 \fBdrand48\fP(), \fBerand48\fP(), \fBlrand48\fP(), \fBnrand48\fP(), \fBmrand48\fP(),
110 \fBjrand48\fP()  で返される値は次のようにして計算される。 はじめに、次の48ビットの \fIXi\fP が計算される。
111 そして、返すべきデータの型に依存した適切な ビット数が \fIXi\fP の上位ビットからコピーされる。 最後に、この値を返り値に変換する。
112 .PP
113 関数 \fBdrand48\fP(), \fBlrand48\fP(), \fBmrand48\fP()  は 最後に生成された48ビットの \fIXi\fP
114 を内部バッファに格納する。 配列の形の引数 \fIxsubi\fP に個々の \fIXi\fP の値を 格納できるような領域を確保することを、 関数
115 \fBerand48\fP(), \fBnrand48\fP(), \fBjrand48\fP()  は、 呼び出し側のプログラムに要求する。
116 これらの関数は、はじめてそれらの関数を呼ぶ前に \fIXi\fP の初期値を配列に 代入することで初期化される。
117 .PP
118 初期化関数 \fBsrand48\fP()  は、\fIXi\fP の 上位32ビットを引数 \fIseedval\fP に設定する。
119 下位の16ビットは、適当に決められた値である0x330Eに設定される。
120 .PP
121 初期化関数 \fBseed48\fP()  は、\fIXi\fP の値を、 配列の形をした引数である \fIseed16v\fP の中で指定された
122 48ビットの値に設定する。 \fIXi\fP の前の値は内部バッファにコピーされ、このバッファへのポインタが \fBseed48\fP()  によって返される。
123 .PP
124 初期化関数 \fBlcong48\fP()  は使用者が \fIXi\fP, \fIa\fP, \fIc\fP の 初期値を指定するための関数である。
125 配列の形をした引数の要素はそれぞれ、\fIparam[0\-2]\fP は \fIXi\fP を、 \fIparam[3\-5]\fP は \fIa\fP
126 を、\fIparam[6]\fP は \fIc\fP を指定するもの である。 \fBlcong48\fP()  が呼ばれた後で、 \fBsrand48\fP()  か
127 \fBseed48\fP()  を呼ぶと、前述の \fIa\fP と \fIc\fP の 標準値が再び設定される。
128 .SH 属性
129 .SS "マルチスレッディング (pthreads(7) 参照)"
130 関数 \fBdrand48\fP(), \fBerand48\fP(), \fBlrand48\fP(), \fBnrand48\fP(), \fBmrand48\fP(),
131 \fBjrand48\fP(), \fBsrand48\fP(), \fBseed48\fP(), \fBlcong48\fP() は、
132 乱数生成に使用する状態情報をグローバルに保持する。 そのため、 これらの関数はスレッドセーフではない。
133 .SH 準拠
134 SVr4, POSIX.1\-2001.
135 .SH 注意
136 SVID 3 ではこれらの関数は時代遅れと宣言されている。 SVID 3 では \fBrand\fP(3)  が代わりに使用されるべきだと記述されている。
137 .SH 関連項目
138 \fBrand\fP(3), \fBrandom\fP(3)
139 .SH この文書について
140 この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.52 の一部
141 である。プロジェクトの説明とバグ報告に関する情報は
142 http://www.kernel.org/doc/man\-pages/ に書かれている。