Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ././../../../../../../usr/man/man3sunmath/lcrans.3sunmath
Real path: /usr/share/man/man3sunmath/lcrans.3sunmath
Zurück
'\" te .\" Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. .TH lcrans 3SUNMATH "16 Jan 2017" "Solaris 11.4" "Sun Legacy Mathematical Library Functions" .SH NAME lcrans \- linear congruential pseudo-random number generators .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsunmath -lm\fR [ \fIlibrary\fR ... ] .fi .LP .nf \fB#include <sunmath.h>\fR .fi .LP .nf \fBint i_lcran_(void);\fR .fi .LP .nf \fBfloat r_lcran_(void);\fR .fi .LP .nf \fBdouble d_lcran_(void);\fR .fi .LP .nf \fBvoid i_lcrans_(int *\fR\fIx\fR\fB, int *\fR\fIn\fR\fB, int *\fR\fIl\fR\fB, int *\fR\fIu\fR\fB);\fR .fi .LP .nf \fBvoid\fR \fBu_lcrans_(unsigned\fR \fB*\fR\fIx\fR\fB,\fR \fBint *\fR\fIn\fR\fB, unsigned *\fR\fIl\fR\fB, unsigned\fR \fB*\fR\fIu\fR\fB);\fR .fi .LP .nf \fBvoid r_lcrans_(float *\fR\fIx\fR\fB, int *\fR\fIn\fR\fB, float *\fR\fIl\fR\fB, float *\fR\fIu\fR\fB);\fR .fi .LP .nf \fBvoid d_lcrans_(double *\fR\fIx\fR\fB, int *\fR\fIn\fR\fB, double *\fR\fIl\fR\fB, double *\fR\fIu\fR\fB);\fR .fi .LP .nf \fBvoid i_get_lcrans_(int *\fR\fIx\fR\fB);\fR .fi .LP .nf \fBvoid i_set_lcrans_(int *\fR\fIx\fR\fB);\fR .fi .LP .nf \fBvoid i_init_lcrans_(void);\fR .fi .SH DESCRIPTION .sp .LP These functions generate uniformly distributed random numbers of types \fBint\fR, \fBunsigned int\fR, \fBfloat\fR, or \fBdouble\fR. They share a common internal generator that produces a sequence of integers between 1 and LCRAN_MODULUS - 1 using the recurrence .sp .in +2 .nf \fInext = (multiplier * last) % LCRAN\fR\fB_\fR\fIMODULUS\fR .fi .in -2 .sp .sp .LP \fBLCRAN_MODULUS\fR is defined in \fB<sunmath.h>\fR and has the value 2**32 - 1. The multiplier depends on which function is called as described below. .sp .LP \fBi_lcran_()\fR returns a random integer between 1 and LCRAN_MODULUS - 1 = 2**32 - 2. It always uses the value 16807 as a multiplier. .sp .LP \fBr_lcran_()\fR returns a random single precision floating point number between 1 / LCRAN_MODULUS and 1. It always uses the value 16807 as a multiplier. .sp .LP \fBd_lcran_()\fR returns a random double precision floating point number between 1 / LCRAN_MODULUS and 1 - (1 / LCRAN_MODULUS). It always uses the value 16807 as a multiplier. .sp .LP \fBi_lcrans_(\fR\fIn\fR\fB,\fR \fIx\fR\fB,\fR \fIl\fR\fB,\fR \fIu\fR\fB)\fR, \fBu_lcrans_(\fR\fIn\fR\fB,\fR \fIx\fR\fB,\fR \fIl\fR\fB,\fR \fIu\fR\fB)\fR, \fBr_lcrans_(\fR\fIn\fR\fB,\fR \fIx\fR\fB,\fR \fIl\fR\fB,\fR \fIu\fR\fB)\fR, and \fBd_lcrans_(\fR\fIn\fR\fB,\fR \fIx\fR\fB,\fR \fIl\fR\fB,\fR \fIu\fR\fB)\fR each fill the array elements \fIx\fR[0], ..., \fIx\fR[*\fIn\fR-1] with random 32-bit signed integers, 32-bit unsigned integers, single precision floating point numbers and double precision floating point numbers, respectively. The numbers are scaled and offset so as to be uniformly distributed over the interval [*\fIl\fR, *\fIu\fR]. These functions use the multiplier supplied in the most recent call to \fBi_set_lcrans_\fR; the default multiplier, which is also reset by \fBi_init_lcrans_\fR, is 16807. .sp .LP \fBi_get_lcrans_(\fR\fIx\fR\fB)\fR sets \fIx\fR[0] to the last value produced by the internal generator and \fIx\fR[1] to the current multiplier used by \fBi_lcrans_\fR, \fBu_lcrans_\fR, \fBr_lcrans_\fR, and \fBd_lcrans_\fR. .sp .LP \fBi_set_lcrans_(\fR\fIx\fR\fB)\fR sets the value used by the internal generator to compute the next random number (i.e., the value of \fIlast\fR in the recurrence above) to \fIx\fR[0] and the mulitplier used by \fBi_lcrans_\fR, \fBu_lcrans_\fR, \fBr_lcrans_\fR, and \fBd_lcrans_\fR to \fIx\fR[1]. The value of \fIlast\fR should be between 1 and LCRAN_MODULUS - 1. Only the least significant 22 bits of the multiplier are used. .sp .LP \fBi_init_lcrans_()\fR resets the value of \fIlast\fR to 1 and the multiplier to 16807. .sp .LP All of the functions listed above use the same internal generator. Consequently, calling \fBi_lcran_\fR immediately after calling \fBi_init_lcrans_\fR will give a different result than calling \fBi_init_lcrans_\fR, then \fBu_lcrans_\fR, then \fBi_lcran_\fR. Different threads within a program use different generators, however, so calling one of these functions in one thread will not affect the values delivered when the same function is called from another thread. .SH EXAMPLES .sp .LP To generate 1000 random double precision numbers in [0,1): .sp .in +2 .nf \fBdouble x[1000];\fR \fBint i;\fR \fBfor (i = 0; i < 1000; i++)\fR \fBx[i] = d_lcran_();\fR .fi .in -2 .sp .sp .LP The same numbers can be generated more efficiently using: .sp .in +2 .nf \fBdouble x[1000], lb, ub;\fR \fBint n = 1000;\fR \fBlb = D_LCRAN_LB; /* defined in <sunmath.h> */\fR \fBub = D_LCRAN_UB; /* defined in <sunmath.h> */\fR \fBd_lcrans_(x, &n, &lb, &ub);\fR .fi .in -2 .sp .sp .LP To generate 1000 random integers between -10 and 10: .sp .in +2 .nf \fBint x[1000], n = 1000, lb = -10, ub = 10;\fR \fBi_lcrans_(x, &n, &lb, &ub);\fR .fi .in -2 .sp .SH ATTRIBUTES .sp .LP See \fBattributes\fR(7) for descriptions of the following attributes: .sp .TS tab( ) box; lw(2.75i) |lw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPE ATTRIBUTE VALUE _ Interface Stability Committed _ MT-Level MT-Safe _ Availability system/library/math .TE .sp .SH SEE ALSO .sp .LP \fBaddrans\fR(3SUNMATH), \fBdrand48\fR(3C), \fBmwcrans\fR(3SUNMATH), \fBrand\fR(3C), \fBrandom\fR(3C), \fBshufrans\fR(3SUNMATH), \fBattributes\fR(7) .sp .LP Knuth, \fISeminumerical Algorithms,\fR 1981, Addison-Wesley. .sp .LP Park and Miller, \fIRandom Number Generators: Good Ones are Hard to Find,\fR Communications of the ACM, October 1988. .SH NOTES .sp .LP Typically, the \fBaddrans\fR(3SUNMATH) generators are faster than either the \fBlcrans\fR(3SUNMATH) or the \fBmwcrans\fR(3SUNMATH) generators.