Go to main content

man pages section 3: Extended Library Functions, Volume 4

Exit Print View

Updated: Thursday, June 13, 2019
 
 

shufrans (3SUNMATH)

Name

shufrans - random number shufflers

Synopsis

cc [ flag ... ] file ...  -lsunmath -lm [ library ... ]
#include <sunmath.h>
void i_shufrans_(int *x, int *n, int *l, int *u);
void  u_shufrans_(unsigned *x, int *n, unsigned *l, unsigned*u);
void r_shufrans_(float *x, int *n, float *l, float *u);
void d_shufrans_(double *x, int *n, double *l, double *u);

Description

These functions shuffle the random numbers x[0], ..., x[*n-1] in place. The numbers may have been generated by any method but are assumed to be uniformly distributed over the interval [*l,*u]. (If any number lies outside this interval, the results are undefined.)

These routines use the method called "Algorithm B" by Knuth. They use an internal table of between 4 and 256 elements depending on *n.

Examples

To shuffle 1000 double precision random numbers in [lb, ub]:

 
double x[1000], lb, ub;
int n = 1000;

d_shufrans_(x, &n, &lb, &ub);

Attributes

See attributes(7) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Committed
MT-Level
MT-Safe
Availability
system/library/math

See Also

addrans(3SUNMATH), drand48(3C), lcrans(3SUNMATH), mwcrans(3SUNMATH), rand(3C), random(3C), attributes(7)

Knuth, Seminumerical Algorithms, 1981, Addison-Wesley.

Park and Miller, Random Number Generators: Good Ones are Hard to Find, Communications of the ACM, October 1988.