1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date. The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein. The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" References consulted:
.\" Linux libc source code
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
.\" 386BSD man pages
.\" Modified Sat Jul 24 19:46:03 1993 by Rik Faith (faith@cs.unc.edu)
.\"
.\" Traducido al castellano (con permiso) por:
.\" Sebastian Desimone (chipy@argenet.com.ar) (desimone@fasta.edu.ar)
.\" Translation fixed on Fri Apr 24 10:37:35 CEST 1998 by Gerardo
.\" Aburruzaga García <gerardo.aburruzaga@uca.es>
.\"
.TH DRAND48 3 "21 Enero 1995" "" "Manual del Programador de Linux"
.SH NOMBRE
drand48, erand48, lrand48, nrand48, mrand48, jrand48, srand48, seed48,
lcong48 \- generan números seudo-aleatorios distribuidos uniformemente
.SH SINOPSIS
.nf
.B #include <stdlib.h>
.sp
.B double drand48(void);
.sp
.BI "double erand48(unsigned short " xsubi [3]);
.sp
.B long int lrand48(void);
.sp
.BI "long int nrand48(unsigned short " xsubi [3]);
.sp
.B long int mrand48(void);
.sp
.BI "long int jrand48(unsigned short " xsubi [3]);
.sp
.BI "void srand48(long int " seedval );
.sp
.BI "unsigned short *seed48(unsigned short " seed16v [3]);
.sp
.BI "void lcong48(unsigned short " param [7]);
.fi
.SH DESCRIPCIÓN
Estas funciones generan números seudo-aleatorios usando el algoritmo
congruente lineal y artimética de enteros de 48 bits.
.PP
Las funciones \fBdrand48()\fP y \fBerand48()\fP devuelven valores en
coma flotante de doble precisión no negativos uniformemente distribuidos
entre [0.0, 1.0).
.PP
Las funciones \fBlrand48()\fP y \fBnrand48()\fP devuelven enteros largos
no negativos distribuidos uniformemente entre 0 y 2^31.
.PP
Las funciones \fBmrand48()\fP y \fBjrand48()\fP devuelven enteros largos
con signo distribuidos uniformemente entre \-2^31 y 2^31.
.PP
Las funciones \fBsrand48()\fP, \fBseed48()\fP y \fBlcong48()\fP son
funciones de inicialización, una de las cuales debe ser llamada antes de
usar \fBdrand48()\fP, \fBlrand48()\fP o \fBmrand48()\fP. Las funciones
\fBerand48()\fP, \fBnrand48()\fP y \fBjrand48()\fP no requieren que
una función de inicialización sea llamada primero.
.PP
Todas las funciones trabajan generando una secuencia de enteros de 48 bits,
\fIXi\fP, de acuerdo a la fórmula de congruencia lineal:
.sp
.nf
.RS
.B Xn+1 = (aXn + c) mod m, donde n >= 0
.RE
.fi
.sp
El parámetro \fIm\fP = 2^48, de aquí que la aritmética sea de 48 bits.
A menos que se llame a \fBlcong48()\fP, \fIa\fP y \fIc\fP son:
.sp
.nf
.RS
.B a = 0x5DEECE66D
.B c = 0xB
.RE
.fi
.sp
El valor devuelto por cualquiera de las funciones \fBdrand48()\fP,
\fBerand48()\fP, \fBlrand48()\fP, \fBnrand48()\fP, \fBmrand48()\fP o
\fBjrand48()\fP es calculado primero al generar el próximo \fIXi\fP de 48
bits en la secuencia. Entonces se copia el número apropiado de bits, de acuerdo
al tipo de dato a ser devuelto, desde los bits de mayor orden
de \fIXi\fP, y se transforman en el valor devuelto.
.PP
Las funciones \fBdrand48()\fP, \fBlrand48()\fP y \fBmrand48()\fP guardan
el último \fIXi\fP de 48 bits generado, en un búfr interno. Las funciones
\fBerand48()\fP, \fBnrand48()\fP y \fBjrand48()\fP requieren que el programa
que las llame proporcione almacenamiento para los sucesivos valores
\fIXi\fP en el argumento vector \fIxsubi\fP. Las funciones se inicializan
al colocar el valor inicial de \fIXi\fP en la cadena antes de llamar a la
función la primera vez.
.PP
La función inicializadora \fBsrand48()\fP asigna los 32 bits de mayor orden
de \fIXi\fP al argumento \fIseedval\fP. Los 16 bits de orden bajo se
rellenan con un valor arbitrario 0x330E.
.PP
La función inicializadora \fBseed48()\fP asigna el valor de \fIXi\fP al
valor de 48 bits especificado en el argumento vector \fIseed16v\fP. Los
valores anteriores de \fIXi\fP se copian en un búfer interno y
\fBseed48()\fP devuelve un puntero a este búfer interno.
.PP
La función inicializadora \fBlcong48()\fP permite al usuario especificar los
valores iniciales para \fIXi\fP, \fIa\fP y \fIc\fP. En los elementos
del argumento vector \fIparam[0-2]\fP se especifica \fIXi\fP, en
\fIparam[3-5]\fP se especifica \fIa\fP, y en \fIparam[6]\fP se
especifica \fIc\fP. Después de llamar a \fBlcong48()\fP,
una llamada a \fBsrand48()\fP o \fBseed48()\fP puede restaurar los
valores estándares de \fIa\fP y \fIc\fP.
.SH "CONFORME A"
SVID 3
.SH OBSERVACIONES
Estas funciones están declaradas como obsoletas por SVID 3, que dice
que en su lugar debe emplearse la función rand(3).
.SH "VÉASE TAMBIÉN"
.BR rand "(3), " random (3)
|