1 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" References consulted:
24 .\" Linux libc source code
25 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
27 .\" Modified Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
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>
34 .\" WORD: internal buffer 内部バッファ
36 .TH DRAND48 3 2007-07-26 "" "Linux Programmer's Manual"
38 drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
39 lcong48 \- 一様分布する疑似乱数を生成する関数
42 .B #include <stdlib.h>
44 .B double drand48(void);
46 .BI "double erand48(unsigned short " xsubi [3]);
48 .B long int lrand48(void);
50 .BI "long int nrand48(unsigned short " xsubi [3]);
52 .B long int mrand48(void);
54 .BI "long int jrand48(unsigned short " xsubi [3]);
56 .BI "void srand48(long int " seedval );
58 .BI "unsigned short *seed48(unsigned short " seed16v [3]);
60 .BI "void lcong48(unsigned short " param [7]);
65 .RB ( feature_test_macros (7)
80 _SVID_SOURCE || _XOPEN_SOURCE
83 これらの関数は線形合同アルゴリズムと 48ビット整数演算を用いて
91 一様分布する非負の倍精度浮動小数点実数値を返す。
105 \-2^31 と 2^31 の間で一様分布する符号付きロング整数を返す。
118 使用する前に、これらの初期化関数のいずれかを呼ぶべきである。
126 ここで説明しているすべての関数は 48ビットの整数の
127 シーケンス (\fIXi\fP) を生成することで
128 機能している。生成方法は以下の線形合同の式による。
132 .B Xn+1 = (aXn + c) mod m,
137 パラメータが \fIm\fP = 2^48 であるため、48ビット整数演算が行われている。
139 が呼ばれていない場合、\fIa\fP と \fIc\fP は以下の式で与えられる。
156 はじめに、次の48ビットの \fIXi\fP が計算される。
157 そして、返すべきデータの型に依存した適切な
158 ビット数が \fIXi\fP の上位ビットからコピーされる。
166 最後に生成された48ビットの \fIXi\fP を内部バッファに格納する。
167 配列の形の引数 \fIxsubi\fP に個々の \fIXi\fP の値を
175 これらの関数は、はじめてそれらの関数を呼ぶ前に \fIXi\fP の初期値を配列に
181 上位32ビットを引数 \fIseedval\fP に設定する。
182 下位の16ビットは、適当に決められた値である0x330Eに設定される。
187 配列の形をした引数である \fIseed16v\fP の中で指定された 48ビットの値に設定する。
188 \fIXi\fP の前の値は内部バッファにコピーされ、このバッファへのポインタが
194 は使用者が \fIXi\fP, \fIa\fP, \fIc\fP の
196 配列の形をした引数の要素はそれぞれ、\fIparam[0-2]\fP は \fIXi\fP を、
197 \fIparam[3-5]\fP は \fIa\fP を、\fIparam[6]\fP は \fIc\fP を指定するもの
204 を呼ぶと、前述の \fIa\fP と \fIc\fP の
209 SVID 3 ではこれらの関数は時代遅れと宣言されている。
212 が代わりに使用されるべきだと記述されている。