LRCW_R 3CW "20 March 2008" "mathcw-1.00"

Table of contents


NAME

lrcwf_r, lrcw_r, lrcwl_r, lrcww_r, lrcwq_r, lrcwll_r, lrcwdf_r, lrcwd_r, lrcwdl_r, lrcwdll_r - logarithmically-distributed random numbers with external state

SYNOPSIS

cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]

#include <mathcw.h>

extern float lrcwf_r (randcw_state_t state, float a, float b);

extern double lrcw_r (randcw_state_t state, double a, double b);

extern long double lrcwl_r (randcw_state_t state, long double a, long double b);

extern __float80 lrcww_r (randcw_state_t state, __float80 a, __float80 b);

extern __float128 lrcwq_r (randcw_state_t state, __float128 a, __float128 b);

extern long_long_double lrcwll_r (randcw_state_t state, long_long_double a, long_long_double b);

extern decimal_float lrcwdf_r (randcw_state_t state, decimal_float a, decimal_float b);

extern decimal_double lrcwd_r (randcw_state_t state, decimal_double a, decimal_double b);

extern decimal_long_double lrcwdl_r (randcw_state_t state, decimal_long_double a,
                                                           decimal_long_double b);

extern decimal_long_long_double lrcwdll_r (randcw_state_t state, decimal_long_long_double a,
                                                                 decimal_long_long_double b);

NB: Functions with prototypes containing underscores in type names may be available only with certain extended compilers.


DESCRIPTION

Compute a logarithmically-distributed random number in the range [a,b]. The range must not contain zero.

The generator state is keep externally in the state argument, a vector of four UINT_LEAST32_T values, most conveniently initialized with incw_r(). This makes the functions thread safe, and allows creation of a practically-unlimited number of independent families of generators, each with its own state.

Execution is fastest when the arguments remain fixed over a series of calls, since recomputation of their logarithms can then be avoided.

Because floating-point numbers are logarithmically distributed, the best way to produce random test values for function arguments in a given range is to use a function like lrcw(), rather than scaling the results from a generator like urcw() for a uniform distribution.


RETURN VALUES

Return the random number.

ERRORS

If either argument is a NaN, return that NaN. If the argument range contains zero, return a NaN. If either argument is Infinity, return that Infinity.

SEE ALSO

ercw(3CW), ercw_r(3CW), gscw(3CW), incw_r(3CW), llrancw(3CW), llrancw_r(3CW), llrincw(3CW), llrincw_r(3CW), lrancw(3CW), lrancw_r(3CW), lrcw(3CW), lrincw(3CW), lrincw_r(3CW), mscw(3CW), nrcw(3CW), nrcw_r(3CW), sccw(3CW), sscw(3CW), urcw(3CW), urcw1(3CW), urcw1_r(3CW), urcw2(3CW), urcw2_r(3CW), urcw3(3CW), urcw3_r(3CW), urcw4(3CW), urcw4_r(3CW), urcw_r(3CW), vercw(3CW), vercw_r(3CW), vllrancw(3CW), vllrancw_r(3CW), vllrincw(3CW), vllrincw_r(3CW), vlrancw(3CW), vlrancw_r(3CW), vlrcw(3CW), vlrcw_r(3CW), vlrincw(3CW), vlrincw_r(3CW), vnrcw(3CW), vnrcw_r(3CW), vurcw(3CW), vurcw1(3CW), vurcw1_r(3CW), vurcw2(3CW), vurcw2_r(3CW), vurcw3(3CW), vurcw3_r(3CW), vurcw4(3CW), vurcw4_r(3CW), vurcw_r(3CW).