gmp_lib.mpz_bin_ui Method

GMP Native Interface for .NET

gmp_libmpz_bin_ui Method
Compute the binomial coefficient n over k and store the result in rop.

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_bin_ui(
	mpz_t rop,
	mpz_t n,
	uint k
)
Public Shared Sub mpz_bin_ui ( 
	rop As mpz_t,
	n As mpz_t,
	k As UInteger
)
public:
static void mpz_bin_ui(
	mpz_t^ rop, 
	mpz_t^ n, 
	unsigned int k
)
static member mpz_bin_ui : 
        rop : mpz_t * 
        n : mpz_t * 
        k : uint32 -> unit 

Parameters

rop
Type: Math.Gmp.Nativempz_t
The result integer.
n
Type: Math.Gmp.Nativempz_t
The first operand integer.
k
Type: SystemUInt32
The second operand integer.
Remarks

Negative values of n are supported by mpz_bin_ui, using the identity bin(-n, k) = (-1)^k * bin(n + k - 1, k), see Knuth volume 1 section 1.2.6 part G.

Examples
// Create, initialize, and set the value of n to 4.
mpz_t n = new mpz_t();
gmp_lib.mpz_init_set_si(n, 4);

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

// Set rop to the binomial coefficient (n:2).
gmp_lib.mpz_bin_ui(rop, n, 2U);

// Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) == 6);

// Release unmanaged memory allocated for n and rop.
gmp_lib.mpz_clears(n, rop, null);
' Create, initialize, and set the value of n to 4.
Dim n As New mpz_t()
gmp_lib.mpz_init_set_si(n, 4)

' Create, initialize, and set the value of rop to 0.
Dim rop As New mpz_t()
gmp_lib.mpz_init(rop)

' Set rop to the binomial coefficient (n:2).
gmp_lib.mpz_bin_ui(rop, n, 2UI)

' Assert that rop is 6.
Assert.IsTrue(gmp_lib.mpz_get_si(rop) = 6)

' Release unmanaged memory allocated for n and rop.
gmp_lib.mpz_clears(n, rop, Nothing)

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