GMP Native Interface for .NET
gmp_libmpn_random2 Method |
Generate a random number of length r1n and store it at r1p.
Namespace: Math.Gmp.Native
Assembly: Math.Gmp.Native (in Math.Gmp.Native.dll) Version: 1.0.0.0 (1.0.0.0)

public static void mpn_random2( mp_ptr r1p, mp_size_t r1n )
Public Shared Sub mpn_random2 ( r1p As mp_ptr, r1n As mp_size_t )
public: static void mpn_random2( mp_ptr^ r1p, mp_size_t r1n )
static member mpn_random2 : r1p : mp_ptr * r1n : mp_size_t -> unit
Parameters
- r1p
- Type: Math.Gmp.Nativemp_ptr
The result integer. - r1n
- Type: Math.Gmp.Nativemp_size_t
The number of limbs of r1p.

The most significant limb is always non-zero. mpn_random generates uniformly distributed limb data, mpn_random2 generates long strings of zeros and ones in the binary representation.
mpn_random2 is intended for testing the correctness of the mpn routines.

// Create multi-precision operand. mp_ptr r1p = new mp_ptr(new uint[2]); // Generate random number. gmp_lib.mpn_random2(r1p, gmp_lib.mp_bytes_per_limb == 4 ? 2 : 1); // Release unmanaged memory. gmp_lib.free(r1p);
' Create multi-precision operand. Dim r1p As New mp_ptr(New UInteger(1) { }) ' Generate random number. gmp_lib.mpn_random2(r1p, If(gmp_lib.mp_bytes_per_limb = 4, 2, 1)) ' Release unmanaged memory. gmp_lib.free(r1p)
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.
