table of contents
DRAND48(3) | Manual do Programador do Linux | DRAND48(3) |
NOME¶
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48, lcong48 - gera números pseudo-randômicos distribuidos uniformemente
SINOPSE¶
#include <stdlib.h>
double drand48(void);
double erand48(unsigned short xsubi[3]);
long int lrand48(void);
long int nrand48(unsigned short xsubi[3]);
long int mrand48(void);
long int jrand48(unsigned short xsubi[3]);
void srand48(long int seedval);
unsigned short *seed48(unsigned short seed16v[3]);
void lcong48(unsigned short param[7]);
Requisitos de macro de teste de recursos para o glibc (consulte
feature_test_macros(7)):
All functions shown above: _XOPEN_SOURCE
|| /* Glibc since 2.19: */ _DEFAULT_SOURCE
|| /* Glibc versions <= 2.19: */ _SVID_SOURCE
DESCRIÇÃO¶
Essas funções geram números pseudo-randômicos usando o algoritmo de congruência linear e aritmética inteira de 48-bit.
The drand48() and erand48() functions return nonnegative double-precision floating-point values uniformly distributed over the interval [0.0, 1.0).
The lrand48() and nrand48() functions return nonnegative long integers uniformly distributed over the interval [0, 2^31).
The mrand48() and jrand48() functions return signed long integers uniformly distributed over the interval [-2^31, 2^31).
The srand48(), seed48() and lcong48() functions are initialization functions, one of which should be called before using drand48(), lrand48() or mrand48(). The functions erand48(), nrand48() and jrand48() do not require an initialization function to be called first.
Todas as funções trabalham gerando uma sequencia de inteiros 48-bit, Xi, de acordo com a formula de congruência linear:
Xn+1 = (aXn + c) mod m, onde n >= 0
O parâmetro m = 2^48, portanto uma aritmética de inteiro 48-bit é realizada.A não ser que lcong48() seja chamada, a e c são obtidos por:
a = 0x5DEECE66D c = 0xB
O valor retornado por qualquer uma das funções drand48(), erand48(), lrand48(), nrand48(), mrand48() ou jrand48() é computado para primeira geração do próximo 48-bit Xi na sequência. Então, o número apropriado de bits, de acordo com o tipo de item de dado a ser retornado, é copiado dos bits de mais alta ordem de Xi e transformado no valor retornado.
The functions drand48(), lrand48() and mrand48() store the last 48-bit Xi generated in an internal buffer. The functions erand48(), nrand48() and jrand48() require the calling program to provide storage for the successive Xi values in the array argument xsubi. The functions are initialized by placing the initial value of Xi into the array before calling the function for the first time.
A função de inicialização srand48() ajusta os 32-bits de mais alta ordem de Xi para o argumento seedval. Os 16-bits de mais baixa ordem são ajustados arbitrariamente para o valor 0x330E.
A função de inicialização seed48() seta o valor de Xi para o valor 48-bit especificado no argumento vetor seed16v. O valor anterior de Xi é copiado em um buffer interno e um ponteiro para esse buffer é retornado por seed48().
The initialization function lcong48() allows the user to specify initial values for Xi, a and c. Array argument elements param[0-2] specify Xi, param[3-5] specify a, and param[6] specifies c. After lcong48() has been called, a subsequent call to either srand48() or seed48() will restore the standard values of a and c.
ATRIBUTOS¶
Para uma explicação dos termos usados nesta seção, consulte attributes(7).
Interface | Atributo | Valor |
drand48(), erand48(), lrand48(), nrand48(), mrand48(), jrand48(), srand48(), seed48(), lcong48() | Thread safety | MT-Unsafe race:drand48 |
The above functions record global state information for the random number generator, so they are not thread-safe.
DE ACORDO COM¶
POSIX.1-2001, POSIX.1-2008, SVr4.
VEJA TAMBÉM¶
COLOFÃO¶
Esta página faz parte da versão 4.16 do projeto Linux man-pages. Uma descrição do projeto, informações sobre relatórios de bugs e a versão mais recente desta página podem ser encontradas em https://www.kernel.org/doc/man-pages/.
TRADUÇÃO¶
A tradução para português brasileiro desta página man foi criada por Marcelo D. Beckmann <marcelobeckmann@yahoo.com> e André Luiz Fassone <lonely_wolf@ig.com.br>
Esta tradução é uma documentação livre; leia a Licença Pública Geral GNU Versão 3 ou posterior para as condições de direitos autorais. Nenhuma responsabilidade é aceita.
Se você encontrar algum erro na tradução desta página de manual, envie um e-mail para a lista de discussão de tradutores.
15 setembro 2017 |