gmp_lib.mpz_random Method

GMP Native Interface for .NET

gmp_libmpz_random Method
Generate a random integer of at most max_size limbs.

Namespace:  Math.Gmp.Native
Assembly:  Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static void mpz_random(
	mpz_t rop,
	mp_size_t max_size
)
Public Shared Sub mpz_random ( 
	rop As mpz_t,
	max_size As mp_size_t
)
public:
static void mpz_random(
	mpz_t^ rop, 
	mp_size_t max_size
)
static member mpz_random : 
        rop : mpz_t * 
        max_size : mp_size_t -> unit 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
max_size
Type: Math.Gmp.Nativemp_size_t
The maximum number of limbs.
Remarks

The generated random number doesn’t satisfy any particular requirements of randomness. Negative random numbers are generated when max_size is negative.

This function is obsolete. Use mpz_urandomb or mpz_urandomm instead.

The random number functions of GMP come in two groups; older function that rely on a global state, and newer functions that accept a state parameter that is read and modified. Please see the GNU MP - Random Number Functions for more information on how to use and not to use random number functions.

Examples
// Create, initialize, and set the value of rop to 0.
mpz_t rop = new mpz_t();
gmp_lib.mpz_init(rop);

// Generate a random integer.
gmp_lib.mpz_random(rop, 500);

// Free all memory occupied by state and rop.
gmp_lib.mpz_clear(rop);
' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Generate a random integer.
gmp_lib.mpz_random(rop, 500)

' Free all memory occupied by state and rop.
gmp_lib.mpz_clear(rop)

No code example is currently available or this language may not be supported.

No code example is currently available or this language may not be supported.

See Also